Feature #183

DefaultSslContextFactory: accept keystore stream

Added by achristian over 4 years ago. Updated over 4 years ago.

Status:ClosedStart date:02/20/2014
Priority:NormalDue date:
Assignee:achristian% Done:

100%

Category:CoreEstimated time:0.75 h
Target version:1.2.0Spent time:0.25 h

Description

Add the following constructor to allow specifying a keystore-stream to load keystore from jar:

public DefaultSslContextFactory(InputStream keystoreStream,
            String keystorePass) throws NoSuchAlgorithmException, FileNotFoundException, KeyStoreException, CertificateException, IOException, UnrecoverableKeyException, KeyManagementException {

        TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
        KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType());
        keystore.load(keystoreStream, keystorePass.toCharArray());
        trustManagerFactory.init(keystore);
        TrustManager[] trustManagers = trustManagerFactory.getTrustManagers();
        SSLContext ctx = SSLContext.getInstance("TLS");
        KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
        kmf.init(keystore, keystorePass.toCharArray());
        ctx.init(kmf.getKeyManagers(), trustManagers, null);
        //System.out.println("keystoreStream length=" + keystoreStream.available() + " type=" + keystore.getType() + " cert=" + keystore.getCertificate("selfsigned"));
        sslContext = ctx;

        logger.debug("ssl context initialized");

    }

History

#1 Updated by achristian over 4 years ago

  • Status changed from New to Resolved
  • % Done changed from 0 to 80

Implemented...

#2 Updated by achristian over 4 years ago

  • Status changed from Resolved to Closed
  • % Done changed from 80 to 100

Also available in: Atom PDF