SOAP Java 客户端 HTTPS/SSL

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/33807599/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-02 22:09:09  来源:igfitidea点击:

SOAP java client HTTPS/SSL

javasoaphttpssoap-client

提问by aminedev

Im trying to call a web service over https , the administrator send me the WSDL file and certificates for my server :

我试图通过 https 调用 Web 服务,管理员向我发送了我的服务器的 WSDL 文件和证书:

myserver.der
myserver.p7b 
myserver.pem
myserver-bundle.pem

I installed the certificate myserver.der :

我安装了证书 myserver.der :

keytool -import -trustcacerts -alias myserver -file myserver.der

Then, using wsimport, I generated the stubs.

然后,使用 wsimport,我生成了存根。

Before calling the web service, my client is doing this :

在调用 Web 服务之前,我的客户正在这样做:

String javaHomePath = System.getProperty("java.home");
String keystore = javaHomePath + "\lib\security\cacerts";
String storepass= "changeit";
String storetype= "JKS";

String[][] props = {
      { "javax.net.ssl.trustStore", keystore, },
      { "javax.net.ssl.keyStore", keystore, },
      { "javax.net.ssl.keyStorePassword", storepass, },
      { "javax.net.ssl.keyStoreType", storetype, },
    };
    for (int i = 0; i < props.length; i++)
      System.getProperties().setProperty(props[i][0], props[i][1]);

Questions :

问题 :

1) I don't know what to do with the other files (.p7b ; .pem) ?

1) 我不知道如何处理其他文件 (.p7b ; .pem) ?

2) It seems that the handshake works , but im getting this error :

2)似乎握手有效,但我收到此错误:

 com.sun.xml.internal.ws.client.ClientTransportException: The server sent    HTTP status code 407: Proxy Authentication Required

Thanks for Help

感谢帮助

采纳答案by Abhash Upadhyaya

Go through this link to understand the difference between different certificate formats - Different Certificate Formats

通过此链接了解不同证书格式之间的区别 -不同的证书格式

You can go through this link here - Java SOAP client with certificate authentication

您可以在此处浏览此链接 - Java SOAP client with certificate authentication

create keystore like this:

像这样创建密钥库:

keytool -import -trustcacerts -file myserver.p7b -keystore keystore -storepass <mypasswd> -alias "myalias"

Notethat myalias MUST be the same as the one used when the key was generated.

请注意, myalias 必须与生成密钥时使用的相同。

You can also verify if keystore has certificates

您还可以验证密钥库是否有证书

keytool -list -v -keystore keystore.jks

To debug the ssl handshake process and view the certificates, set the VM parameter -Djavax.net.debug=all

调试ssl握手过程和查看证书,设置VM参数 -Djavax.net.debug=all

PS: Also, go through this link which might help you resolve Proxy Authentication Required error - Proxy authentication in Java

PS:此外,通过此链接可能会帮助您解决需要代理身份验证的错误 - Java 中的代理身份验证