Example usage for javax.security.cert CertificateException printStackTrace

List of usage examples for javax.security.cert CertificateException printStackTrace

Introduction

In this page you can find the example usage for javax.security.cert CertificateException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:com.spacetimeinsight.webservice.ssl.EasySSLProtocolSocketFactory.java

public static SSLContext getContext(File pKeyFile, String pKeyPassword)
        throws NoSuchAlgorithmException, KeyStoreException, CertificateException, IOException,
        UnrecoverableKeyException, KeyManagementException {
    KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance("SunX509");
    KeyStore keyStore = KeyStore.getInstance("PKCS12");

    InputStream keyInput = new FileInputStream(pKeyFile);
    try {/*from   w  w w  .ja  v a 2  s .c o m*/
        keyStore.load(keyInput, pKeyPassword.toCharArray());
    } catch (java.security.cert.CertificateException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    keyInput.close();

    keyManagerFactory.init(keyStore, pKeyPassword.toCharArray());

    TrustManager[] trustAllCerts = new TrustManager[] {
            (X509TrustManager) new EasyX509SSLTrustManager(keyStore) };

    // javax.net.ssl.SSLContext context =  javax.net.ssl.getInstance("SSL");
    SSLContext context = SSLContext.getInstance("SSL");
    context.init(keyManagerFactory.getKeyManagers(), trustAllCerts, new SecureRandom());

    return context;
}