I am obtaining this exception (client certificate not found) when trying to connect to a secure Web Service that requires a client certificate. I am using a web service client automatically generated by axis2, using the Eclipse wizard.

This is the calling code, that causes the exception in the last line:

System.setProperty("javax.net.ssl.trustStore","C:\\Archivos de programa\\Java\\jre7\\lib\\security\\cacerts");
System.setProperty("javax.net.ssl.trustStorePassword", "changeit");
System.setProperty("javax.net.ssl.keyStore","D:\\Perfil Usuario\\internet\\Escritorio\\workspace\\certificados\\clientes.jks");
System.setProperty("javax.net.ssl.keyStorePassword", "changeit");
ServicioBoletinStub lala = new ServicioBoletinStub();
ConsultaDeCatalogo cons = new ConsultaDeCatalogo();
cons.setArgs0("SECCIONES");
ConsultaDeCatalogoResponse conResp = lala.consultaDeCatalogo(cons);

The client certificate is imported in the "clientes.jks" keystore, and all the other required certificates for the authentication path are in "cacerts".

The only weird thing I had to do was to convert the client certificate from .p12 to .cer, because keytool was complaining that the .p12 file was not an x509 certificate. The .p12 file was encrypted with a password, but the .cer file is not, so I am afraid that something was missing during the conversion. I am very new to handling certificates so I do not know what I am missing.

I also used SSLPoke to test the connection, and no errors were given.

Thank you very much.

有帮助吗?

解决方案

Ok, the problem was in the import process of the client certificate, as suspected. Keytool was not importing the private key into the "clientes.jks" keystore.

I deleted everything from this keystore and followed this post (http://cunning.sharp.fm/2008/06/importing_private_keys_into_a.html) to import the client certificate plus the private key.

Anyway, I think Axis2 should have specified that the exception message was taken from the SOAP response message: I thought it was generating it by itself.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top