Hi all,
Using a link to Sun code that a few people have posted before, I have client authentication working using HttpClient by creating my own SecureProtocolSocketFactory.
The problem i'm having is that it seems to automatically choose a certificate without asking me which one to use. Does anyone know how to modify the following code to retrieve a cert by name? Even a way to work out which client cert is loaded would be great.
Thanks
Tim
SSLSocketFactory factory = null; SSLSocket socket = null; try { SSLContext ctx; KeyManagerFactory kmf; KeyStore ks; char[] passphrase = "password".toCharArray();
ctx = SSLContext.getInstance("TLS"); kmf = KeyManagerFactory.getInstance("SunX509"); ks = KeyStore.getInstance("JKS");
File f = new File(".keystore"); FileInputStream fis = new FileInputStream(f); ks.load(fis, passphrase);
kmf.init(ks, passphrase); ctx.init(kmf.getKeyManagers(), null, null); factory = ctx.getSocketFactory();
socket = (SSLSocket) factory.createSocket(host, port);
} catch (Exception e) { e.printStackTrace(); }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]