【问题标题】:How to setup Apache Wink Client keystore and truststore如何设置 Apache Wink 客户端密钥库和信任库
【发布时间】:2014-01-28 21:32:52
【问题描述】:

如何在 Apache Wink 客户端中设置客户端密钥库和信任库

我找不到任何有关如何操作的文档。

http://wink.apache.org/documentation/1.2.1/Apache_Wink_User_Guide.pdf

【问题讨论】:

    标签: java ssl keystore truststore apache-wink


    【解决方案1】:

    我认为初始化SSLContext 的“常规”代码会起作用。

    如何加载信任库的示例:

    String path = ....
    char[] password = ....
    KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
    keyStore.load(new FileInputStream(path), password );
    TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
    tmf.init(keyStore);
    SSLContext ctx = SSLContext.getInstance("SSL");
    ctx.init(null, tmf.getTrustManagers(), null);
    

    如果您还需要客户端证书的密钥库,请以类似方式使用 KeyStoreFactory 或实现KeyManager

    【讨论】:

    • 我不需要像 Jersey Client 一样将 KeyStore 和 TrustStore 添加到 ClientConfig 吗? // 导入 com.sun.jersey.api.client.config.ClientConfig; // 导入 com.sun.jersey.api.client.config.DefaultClientConfig; ClientConfig 配置 = 新的 DefaultClientConfig(); // 导入 com.sun.jersey.client.urlconnection.HTTPSProperties config.getProperties().put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES, new HTTPSProperties(getHostnameVerifier(), getSSLContext()));
    • 据我记得,Wink默认使用HttpsURLConnection,也就是说会使用默认的SSLContext。
    • 您可以配置 Wink 使用 Apache HTTP 客户端,此时您需要将 SSL 配置传递给客户端
    • 我得到了这个使用 org.apache.http.impl.client.DefaultHttpClient org.apache.wink.client.httpclient.ApacheHttpClientConfig 但我必须设置 https 端口:httpClient.getConnectionManager()。 getSchemeRegistry().register(new Scheme("https", 9443, socketFactory));无论如何,为了避免每次都这样做,因为我不会事先知道端口
    猜你喜欢
    • 1970-01-01
    • 2018-05-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-09-24
    • 2018-11-11
    • 1970-01-01
    相关资源
    最近更新 更多