Java SSL client not selecting a smartcard key

偶尔善良 提交于 2019-12-03 08:59:05

AFAIK the attributes only matter if you create objects in the PKCS#11 module, which is not the case with the smart card. Try to see with pkcs11-spy from OpenSC what kind of attributes are asked for and not implemented by the module.

Another option is to use the lower-layer PKCS#11 methods (C_*), which gives better control of PKCS#11 details.

Based solely on Martin's answer, building https://github.com/OpenSC/OpenSC from source and installing OpenSC-0.15.0.dmg gave an alternative driver that worked first time. I didn't use the pkcs11-spy because it just worked first time.

String config =
    "name=OpenSC\n" +
        "library=/Library/OpenSC/lib/opensc-pkcs11.so\n";

I was able to test against openssl

$ openssl s_server -verify 20 -key key.pem -cert cert.pem -accept 44330   -no_ssl3 -dhparam dhparam.pem -www 

Which responded with

---
Client certificate
Certificate:
    Data:
        Version: 3 (0x2)
        Serial Number:
            xxxxxxxxx
        Signature Algorithm: sha256WithRSAEncryption
        Issuer: C=EE, O=AS Sertifitseerimiskeskus, CN=ESTEID-SK 2011/emailAddress=pki@sk.ee
        Validity
            Not Before: Jul 15 09:51:27 20xx GMT
            Not After : Jul 13 20:59:59 20xx GMT
        Subject: C=EE, O=ESTEID, OU=authentication, CN=SCHIMKE,YURI,xxxxxxxx, SN=SCHIMKE, GN=YURI/serialNumber=xxxxxxxx
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!