Hi,
I recently opened the thread "Could not open certificate store". Since the problem I've encountered now is a new one I chosed to open a new thread.
I'm trying to make client authentication work with a smart card. I've modified the main method of demo class SSLClient so that the invokation of getSSLSocketFactory() takes the keystore alias of the cert on my smart card as the first parameter. I then get an exeption when calling the method. I've also set the debugging on and it says:
-----------------
JCAPI_SSL_LOG: Key manager will use the following PKCS#11 settings:
name = Posten_eID_v1_(identification)_1
library = C:\WINNT\system32\SmartP11.dll
slotListIndex = 1
---------------------
Isn't the value of 'name' quite strange? Shouldn't it be the name of the CSP, in this case "SmartTrust Cryptographic Service Provider"? It must be something that is set from JCAPI since the PKCS#11 provider isn't mentioned in the java.security file.
As I wrote in the other thread I'm using SmartTrust Personal 3.0.2 on Win2000 SP4 and is running the demo in IntelliJ IDEA 5. The Java platform is JDK1.5.0_06.
I would be very grateful for help with this. Below is the code and the result of the test.
Regards
Mattias
--------------------------------------------------
static public void main(String[] args)
{
String aliasOfMyCertInStore = "My|8CDuyGNSJkaFLVCffsJU4FKv2ak=";
try {
Security.addProvider(new JCAPIProvider());
String alias = getServerCertAlias();
//Get JCAPI SSL plug-in.
JCAPISSLFactory f = JCAPIProperties.getInstance().getSSLFactory();
if(f == null)
throw new Exception("The JCAPI SSL plug-in is not loaded into the JVM.");
//Get a JCAPI SSL configured SSL socket factory based on:
//1. Ignore (i.e. use JSSE's key manager instead) the key store
// since we'll not use client authentication.
//2. Tell JCAPI SSL socket factory to only consider the certificate
// associated with the given alias to be trusted.
//3. Use protocol "SSL".
//For more information about the JCAPI SSL plug-in, see the JCAPI
//Javadocs for interface 'JCAPISSLFactory'.
// SSLSocketFactory sf = f.getSSLSocketFactory(null, alias, "SSL");
f.setLogging(true);
SSLSocketFactory sf = f.getSSLSocketFactory(aliasOfMyCertInStore, alias, "SSL");
sendRequest(sf, "Hello");
sendRequest(sf, "Goodbye");
sendRequest(sf, "SHUTDOWN"); //Tell server to shutdown on next request.
sendRequest(sf, ""); //Just send a dummy request.
} catch(Throwable t) {
t.printStackTrace();
System.err.println("Test prog failed. Exiting...");
}
}
------------------------------------------------------------------------
-----------------------------------------------------
JCAPI_SSL_LOG: Key store alias given for SSL socket factory. Use JCAPI key store.
JCAPI_SSL_LOG: Key manager will use key entry with alias: My|8CDuyGNSJkaFLVCffsJU4FKv2ak=
JCAPI_SSL_LOG: Key manager will use the following key entry issuer: CN=Posten Sverige AB EID Rollkort CA v1, O=Posten Sverige AB, C=SE
JCAPI_SSL_LOG: Check if we shall use MS CAPI or PKCS#11 to access the private key.
JCAPI_SSL_LOG: Key manager will use PKCS#11 to access the private key.
JCAPI_SSL_LOG: Key manager will use the following PKCS#11 settings:
name = Posten_eID_v1_(identification)_1
library = C:\WINNT\system32\SmartP11.dll
slotListIndex = 1
JCAPI_SSL_LOG: Key manager adding PKCS#11 provider.
JCAPI_SSL_LOG: Error, key manager failed to initiate PKCS#11 provider.
JCAPI_SSL_LOG: Error configuring key entry in SSL key manager.
java.lang.RuntimeException: Could not initiate Java PKCS#11 provider.
at com.pheox.jcapi.plugins.ssl5.e.a(Unknown Source)
at com.pheox.jcapi.plugins.ssl5.e.<init>(Unknown Source)
at com.pheox.jcapi.plugins.ssl5.SSLKeyManager.<init>(Unknown Source)
at com.pheox.jcapi.plugins.ssl5.b.a(Unknown Source)
at com.pheox.jcapi.plugins.ssl5.SSLFactory.getSSLSocketFactory(Unknown Source)
at SSLClient.main(SSLClient.java:8
Caused by: java.security.ProviderException: Error parsing configuration
at sun.security.pkcs11.Config.getConfig(Config.java:71)
at sun.security.pkcs11.SunPKCS11.<init>(SunPKCS11.java:100)
... 6 more
Caused by: sun.security.pkcs11.ConfigurationException: Unexpected token: Token['('], line 1
at sun.security.pkcs11.Config.excToken(Config.java:269)
at sun.security.pkcs11.Config.parse(Config.java:286)
at sun.security.pkcs11.Config.<init>(Config.java:156)
at sun.security.pkcs11.Config.getConfig(Config.java:67)
... 7 more
java.lang.IllegalArgumentException: Could not get public key info for alias 'My|8CDuyGNSJkaFLVCffsJU4FKv2ak='.
at com.pheox.jcapi.plugins.ssl5.e.<init>(Unknown Source)
at com.pheox.jcapi.plugins.ssl5.SSLKeyManager.<init>(Unknown Source)
at com.pheox.jcapi.plugins.ssl5.b.a(Unknown Source)
at com.pheox.jcapi.plugins.ssl5.SSLFactory.getSSLSocketFactory(Unknown Source)
at SSLClient.main(SSLClient.java:8
Test prog failed. Exiting...
----------------------------------------------------