获取i5 Keymanager和Trustmanager时出错

时间:2013-06-18 11:48:53

标签: ssl ibm-midrange

我试图使用发送到贝宝。

我收到一条错误消息,指出我的信任管理员尚未初始化。 (我想)。

这是我进入SSL的第一步,所以我可能没有正确设置。我得到了SSlConfigurationException。

public static SSLContext setupClientSSL(String certPath, String certPassword)
        throws SSLConfigurationException {
    SSLContext sslContext = null;
    try {
        KeyManagerFactory kmf =
                KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());

        KeyStore ks = p12ToKeyStore(certPath, certPassword);
        kmf.init(ks, certPassword.toCharArray());
        //sslContext = getSSLContext(kmf.getKeyManagers());
        sslContext = SSLContext.getInstance("SSL", "IBMJSSE2");
    } catch (NoSuchAlgorithmException e) {
        throw new SSLConfigurationException(e.getMessage(), e);
    } catch (KeyStoreException e) {
        throw new SSLConfigurationException(e.getMessage(), e);
    } catch (UnrecoverableKeyException e) {
        throw new SSLConfigurationException(e.getMessage(), e);
    } catch (CertificateException e) {
        throw new SSLConfigurationException(e.getMessage(), e);
    } catch (NoSuchProviderException e) {
        throw new SSLConfigurationException(e.getMessage(), e);
    } catch (IOException e) {
        throw new SSLConfigurationException(e.getMessage(), e);
    }
    return sslContext;
}

1 个答案:

答案 0 :(得分:1)

信息中心提供了使用Java Secure Socket Extension的文档,包括设置和示例代码。