Hello,
I need to call a https secured web application from within JBoss. Establishing a https
connection is no problem, but the web application I call requires client authentication
and I did not manage to specify a certificate.
My code is as follows SSLContext context;
| KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType());
| KeyStore truststore = KeyStore.getInstance(KeyStore
| .getDefaultType());
| char[] password = "secret".toCharArray();
| String keyStoreLocation = "META-INF/keystore";
| String trustStoreLocation = "META-INF/truststore";
| InputStream is = getClass().getResourceAsStream(keyStoreLocation);
| keystore.load(is, password);
| is = getClass().getResourceAsStream(trustStoreLocation);
| truststore.load(is, password.toCharArray());
| KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
| kmf.init(keystore, password);
| TrustManagerFactory tmf = TrustManagerFactory
| .getInstance("SunX509");
| tmf.init(truststore);
|
| context = SSLContext.getInstance("TLS");
| context.init(kmf.getKeyManagers(), tmf.getTrustManagers(),
| new SecureRandom());
| HttpsURLConnection.setDefaultSSLSocketFactory(context
| .getSocketFactory());
|
| HttpsURLConnection conn = (HttpsURLConnection) new
URL("https://...").openConnection();
| conn.connect();
| Certificate[] clientCerts = conn.getLocalCertificates();
| [...]
If I understand things right, the clientCerts array in my code should contain at least one
element, but it is always empty.
Can anybody help me how to configure the certificates correctly?
Regards,
Martin
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4008251#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...