axis2 で作成された「Hello World」Web サービスがあります。https
このサービスを自己署名証明書で使用できるクライアント API を作成したいと考えています。自己署名証明書myCertificate.cer
とkeystore
それを含む があります。
ここに私のクライアントAPIがあります:
public class MyApi{
public Object callMyService(){
Axis2TestStub stub = new Axis2TestStub(
"https://localhost:8443/axis2/services/Axis2Test");
System.setProperty("javax.net.ssl.trustStore",
"src/main/resources/myKeystore.jks")
System.setProperty("javax.net.ssl.trustStorePassword", "changeit");
Hello request = new Hello();
request.setMot("World");
HelloResponse response = stub.hello(request);
Object mot = response.get_return();
return mot;
それは機能しますが、それを含むのでmyCertificate.cer
はなく、使用したいと思います。keystore
誰かがそれを行う方法を知っていますか? https
プロトコルをオーバーライドしようとしましたが成功しませんでした:
HttpSecureProtocol myHttpsProtocol = new HttpSecureProtocol();
myHttpsProtocol .setCheckHostname(false);
myHttpsProtocol .addTrustMaterial(new TrustMaterial("myCertificate.cer"));
Protocol customHttps = new Protocol("https",
(ProtocolSocketFactory) myHttpsProtocol , 8443);
Protocol.registerProtocol("https", customHttps);