Problems with create pkcs12 file - "No private key was found"

255 views
Skip to first unread message

Sam Jascott

unread,
Aug 3, 2020, 8:50:38 AM8/3/20
to JSignPdf
Hi there

I'm having problems creating a suitable pkcs12 file for use with JSignPDF. I create the key and cert like this:

openssl req -newkey rsa:4096 -x509 -keyout cakey.pem -out cacert.pem -days 3650 -nodes
Generating a 4096 bit RSA private key
.............................++++
........................................................................................................++++
writing new private key to 'cakey.pem'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) []:XX
State or Province Name (full name) []:state
Locality Name (eg, city) []:city
Organization Name (eg, company) []:company
Organizational Unit Name (eg, section) []:section
Common Name (eg, fully qualified host name) []:fqhn
Email Address []:xxxx

Afterwards I create the pkcs12 store like this:

openssl pkcs12 -export -in cacert.pem -inkey cakey.pem -out identity.p12 -name "mykey"
Enter Export Password:
Verifying - Enter Export Password:

Then I tried to run JSignPdf

/nix/store/p97kg0dww481x0s0nfqpjpl70ba24hi9-openjdk-8u242-b08-jre/lib/openjdk/jre/bin/java -jar JSignPdf.jar -kst PKCS12 -ksf /tmp/timestamp/jsignpdf-1.6.4/identity.p12 -kp xxx /tmp/times
tamp
/file.pdf
WARN  net
.sf.jsignpdf.utils.PropertyProvider$ProperyProviderException: Property file /root/.JSignPdf doesn't exist.
DEBUG Relaxing SSL security.
INFO  Checking input and output PDF paths.
INFO  Getting key alias
INFO  Used key alias: mykey
INFO  Loading private key
INFO  Getting certificate chain
INFO  No private key was found. Check the keystore settings (keystore type, filepath, password, key alias).
INFO  Finished: Creating of signature failed.


Then I did create the pkcs12 file according to the java docs

openssl pkcs12 -export -in mykeycert.pem.txt -out my.pkcs12 -name myStore -noiter -nomaciter
Enter Export Password:
Verifying - Enter Export Password:

I tried to run it again:

/nix/store/p97kg0dww481x0s0nfqpjpl70ba24hi9-openjdk-8u242-b08-jre/lib/openjdk/jre/bin/java -jar JSignPdf.jar -kst PKCS12 -ksf /tmp/timestamp/jsignpdf-1.6.4/my.pkcs12 -kp xxx /tmp/timestam
p
/file.pdf
WARN  net
.sf.jsignpdf.utils.PropertyProvider$ProperyProviderException: Property file /root/.JSignPdf doesn't exist.
DEBUG Relaxing SSL security.
INFO  Checking input and output PDF paths.
INFO  Getting key alias
INFO  Used key alias: mystore
INFO  Loading private key
INFO  Getting certificate chain
INFO  No private key was found. Check the keystore settings (keystore type, filepath, password, key alias).
INFO  Finished: Creating of signature failed.

So, where did I go wrong?


Reply all
Reply to author
Forward
0 new messages