Hi,
Consider following configuration:
<!-- Using net.jsign:jsign-maven-plugin:7.4 -->
<configuration>
<storetype>PKCS11</storetype>
<keystore>${project.basedir}/digicert-pkcs11.cfg</keystore>
<replace>true</replace>
<storepass/>
<alias>My Existing Alias</alias>
<tsaurl>http://timestamp.digicert.com</tsaurl>
<algorithm>SHA-256</algorithm>
</configuration>
with cfg:
name = eToken
library = C:/Windows/System32/eTPKCS11.dll
slotListIndex = 1
showInfo = false
It seems like 8 out of 10 times in run mode, this fails with No certificate found in the keystore SunPKCS11-eToken.
After running with breakpoints, I spotted the issue here :
|
ks.load(in, params.storepass() != null ? params.storepass().toCharArray() : null); |
In case of loading failure, the only difference is the field ((P11KeyStore)ks.keyStoreSpi).aliasMap being empty instead of size=1. The token info is always here.
It always succeeds ([INFO] Adding Authenticode signature to C:\Users\codesigning\IdeaProjects\jsign\javaw.exe) when I stop at this line, which makes me think it's a race condition, the try-with-resource seems not enough to guarantee the keystore has been properly loaded from the pkcs11 token.
Is there any recommandation or known issue to workaround this limitation ? Is it related to the eTPKCS11.dll dll ? Otherwise I planned to fork the project just to retry the ks.load more than 1 time which I'd hate to...
NB: running the same cfg file over keytool though always works and gets the alias and its certificate properly
keytool -list -keystore NONE -storetype PKCS11 -providerclass sun.security.pkcs11.SunPKCS11 -providerArg .\digicert-pkcs11.cfg -v -alias "My Existing Alias"
Thank you.
Hi,
Consider following configuration:
with cfg:
name = eToken library = C:/Windows/System32/eTPKCS11.dll slotListIndex = 1 showInfo = falseIt seems like 8 out of 10 times in run mode, this fails with
No certificate found in the keystore SunPKCS11-eToken.After running with breakpoints, I spotted the issue here :
jsign/jsign-crypto/src/main/java/net/jsign/KeyStoreType.java
Line 697 in d18f06d
In case of loading failure, the only difference is the field
((P11KeyStore)ks.keyStoreSpi).aliasMapbeing empty instead of size=1. The token info is always here.It always succeeds (
[INFO] Adding Authenticode signature to C:\Users\codesigning\IdeaProjects\jsign\javaw.exe) when I stop at this line, which makes me think it's a race condition, the try-with-resource seems not enough to guarantee the keystore has been properly loaded from the pkcs11 token.Is there any recommandation or known issue to workaround this limitation ? Is it related to the eTPKCS11.dll dll ? Otherwise I planned to fork the project just to retry the ks.load more than 1 time which I'd hate to...
NB: running the same cfg file over
keytoolthough always works and gets the alias and its certificate properlyThank you.