Skip to content

Empty keystore with SafeNet eToken 5110+ FIPS accessed through PKCS#11 (eTPKCS11.dll) #345

@Macadoshis

Description

@Macadoshis

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions