所有与密钥库相关的方法在Jetty文档中都被标记为已弃用,但它并未引用替换API。应该使用什么API?
http://download.eclipse.org/jetty/stable-7/apidocs/org/eclipse/jetty/client/HttpClient.html
答案 0 :(得分:4)
请改用ssl上下文工厂。 e.g。
SslContextFactory sslContextFactory = new SslContextFactory();
URL keyStoreUrl = this.getClass().getClassLoader().getResource("XXXXXX.pfx");
URL trustStoreUrl = this.getClass().getClassLoader().getResource("XXXX.jks");
sslContextFactory.setKeyStoreType("pkcs12");
sslContextFactory.setTrustStoreType("jks");
sslContextFactory.setKeyStore(keyStoreUrl.toString());
sslContextFactory.setKeyStorePassword(KEY_STORE_PASS);
sslContextFactory.setNeedClientAuth(true);
sslContextFactory.setValidateCerts(false);
sslContextFactory.setTrustStore(trustStoreUrl.toString());
sslContextFactory.setTrustStorePassword(KEY_STORE_PASS);
sslContextFactory.setKeyManagerPassword(KEY_STORE_PASS);
httpClient = new HttpClient(sslContextFactory);