Hello All,
I am getting error (javax.net.ssl.SSLHandshakeException: Error signing certificate verify)
Please look at Below code fragment
I am trying to connect a server(Client SSL enabled), for which i have a SSL certificate.
I am able to get handle to the private key of this certificate(Certificate is in smart card), which i am returning from getPrivateKey() method. And all other methods works fine... like returning certificate chain etc.
Can any one please resolve why i am getting this error.
KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
KeyStoreUtil objKU = new KeyStoreUtil();
KeyStore keyStore = objKU.getKeyStoreInstance(); //Will return keystore(I have my own provider)
keyManagerFactory.init(keyStore, null);
KeyManager[] keyManagers = keyManagerFactory.getKeyManagers();
for (int i = 0; i < keyManagers.length; ++i)
{
keyManagers[i] = new EX509KeyManager((X509KeyManager)keyManagers, "AliasName");
}
//Using this key manager i have created SSLContext object.
//Using KeyStore I am able to get private Key handle
static class EX509KeyManager implements X509KeyManager
{
private X509KeyManager B;
private String A;
public EX509KeyManager(X509KeyManager keyManager, String alias)
{
this.B = keyManager;
this.A = alias;
}
public String chooseClientAlias(String[] keyType, Principal[] issuers, Socket socket)
{
return this.A;
}
public String chooseServerAlias(String keyType, Principal[] issuers, Socket socket)
{
return this.B.chooseServerAlias(keyType, issuers, socket);
}
public X509Certificate[] getCertificateChain(String alias)
{
return this.B.getCertificateChain(alias);
}
public String[] getClientAliases(String keyType, Principal[] issuers)
{
return this.B.getClientAliases(keyType, issuers);
}
public PrivateKey getPrivateKey(String alias)
{
return this.B.getPrivateKey(alias);
}
public String[] getServerAliases(String keyType, Principal[] issuers)
{
return this.B.getServerAliases(keyType, issuers);
}
}