hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tim Wild <tim.w...@solnetsolutions.co.nz>
Subject client certs - how to choose which cert to use?
Date Mon, 24 May 2004 02:15:31 GMT
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 

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.



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) {

To unsubscribe, e-mail: commons-httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org

View raw message