-
Notifications
You must be signed in to change notification settings - Fork 133
Description
Hello,
I can't get PKCS11 provider to work with jsignpdf tool, but I can see smartcard with keytool, pkcs11-tool and clojure code.
It all started once I've got a new Electronic ID that I would like to use to sign PDF's.
I can see the certificates using keytool and a provider config but only after it asks for a PIN.
I think this is the weak link :)
I can't see the PKCS11 provider in my jsignpdf list.
./jsignpdf.sh -lkt
FINE Relaxing SSL security.
INFO Available key store types:
BCFKS
BCFKS-DEF
BCPKCS12
BKS
BOUNCYCASTLE
CASEEXACTJKS
CloudFoxy
DKS
FIPS
FIPS-DEF
IBCFKS
IBCFKS-DEF
IFIPS
IFIPS-DEF
JCEKS
JKS
PKCS12
PKCS12-3DES-3DES
PKCS12-3DES-40RC2
PKCS12-DEF
PKCS12-DEF-3DES-3DES
PKCS12-DEF-3DES-40RC2
So I think the algorithm in keytool is working a bit better.
And trying to list the keys I get this:
./jsignpdf.sh -kst PKCS11 -lk
FINE Relaxing SSL security.
INFO Getting keystore type instance: PKCS11
java.security.KeyStoreException: PKCS11 not found
at java.base/java.security.KeyStore.getInstance(KeyStore.java:873)
at net.sf.jsignpdf.utils.KeyStoreUtils.loadKeyStore(KeyStoreUtils.java:355)
at net.sf.jsignpdf.utils.KeyStoreUtils.getKeyAliases(KeyStoreUtils.java:112)
at net.sf.jsignpdf.Signer.main(Signer.java:127)
Caused by: java.security.NoSuchAlgorithmException: PKCS11 KeyStore not available
at java.base/sun.security.jca.GetInstance.getInstance(GetInstance.java:159)
at java.base/java.security.Security.getImpl(Security.java:655)
at java.base/java.security.KeyStore.getInstance(KeyStore.java:870)
... 3 more
Exception in thread "main" java.lang.NullPointerException: Keystore was not loaded succesfully. Check if the keystore type, path and password are valid.
at net.sf.jsignpdf.utils.KeyStoreUtils.getKeyAliases(KeyStoreUtils.java:114)
at net.sf.jsignpdf.Signer.main(Signer.java:127)
keytool -keystore NONE -storetype PKCS11 -providerClass sun.security.pkcs11.SunPKCS11 -providerArg pkcs11.cfg -list
Enter keystore password:
Keystore type: PKCS11
Keystore provider: SunPKCS11-RoIdPlug
Your keystore contains 3 entries
CA certificate Common Name/cn=ro cei mai root-ca,ou=dgep,o=ministerul afacerilor interne,c=ro/1[REDACTED]9, trustedCertEntry,
Certificate fingerprint (SHA-256): B5:[REDACTED]:80
CA certificate Common Name/cn=ro cei mai root-ca,ou=dgep,o=ministerul afacerilor interne,c=ro/2[REDACTED]4, trustedCertEntry,
Certificate fingerprint (SHA-256): B7:[REDACTED]:1D
Certificate ECC Authentication, PrivateKeyEntry,
Certificate fingerprint (SHA-256): 27:[REDACTED]:BE
The pkcs11.cfg file contains:
name = RoIdPlug
library = /usr/lib/idplugclassic/libidplug-pkcs11.so
I've also tried to configure security via file so jsignpdf loads the SunPKCS11 provider with the smartcard middleware so I can see PKCS11, but I did not manage to do that.
I updated jsignpdf.sh like:
"$JAVA" $JAVA_OPTS -Dsecurity.overridePropertiesFile=true -Djava.security.properties=file://$DIR/conf/extra.security -Djava.security.debug=pkcs11keystore -Djava.security.debug=sunpkcs11 "-Djsignpdf.home=$DIR" -jar "$DIR/JSignPdf.jar" "$@"
and extra.security
security.provider.13=sun.security.pkcs11.SunPKCS11 /home/ieugen/Descărcări/jsignpdf-2.3.0/conf/pkcs11.cfgAny idea what am I missing?
Do you think we can improve jsignpdf algorithm to dynamically load PKCS11 config with also loading the pin?
Thanks,
Eugen