duansanzi5265 2013-01-02 19:25
浏览 76
已采纳

PHP SoapClient,带有Java中的自签名证书

One of WS which we need to connect to has sample code in PHP. They are signed for us CSR ... so we have now PRIVATE KEY and CERTIFICATE for authentication.

They suggest to put both, PRIVATE KEY, and signed CERTIFICATE to one .pem file, and in PHP to have code like this one:

$client = new SoapClient('https://www.example.com/api/server.php?wsdl', array('local_cert' => "custom-pc.pem", "trace"=>1));
$result = $client->Login();

and that works fine.

But we are using Java, no PHP gurus here - so I imported both PRIVATE KEY and CERTIFICATE to cacerts (exported to PKCS12 and then merged keystore).

openssl pkcs12 -export -in signed.pem -inkey server.key -out signed.p12 -name custom -CAfile ca.crt -caname root
sudo keytool -importkeystore -deststorepass changeit -destkeypass changeit -destkeystore /Library/Java/JavaVirtualMachines/jdk1.7.0_06.jdk/Contents/Home/jre/lib/security/cacerts -srckeystore signed.p12 -srcstoretype PKCS12 -srcstorepass changeit -alias custom

But, no luck :(

All the time got exception:

javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
    at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
    at sun.security.ssl.Alerts.getSSLException(Alerts.java:154)
    at sun.security.ssl.SSLSocketImpl.recvAlert(SSLSocketImpl.java:1977)
    at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1093)
    at sun.security.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:884)
    at sun.security.ssl.AppInputStream.read(AppInputStream.java:102)

any idea what we did wrong?

  • 写回答

1条回答 默认 最新

  • dongwen6743 2013-01-02 22:37
    关注

    javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
    This is usually encountered when the server is inaccesible. Perhaps firewall issue?
    You could run your client with java -Djavax.net.debug=ssl or see the handshake via wireshark to get an idea where the problem is at

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 做个有关计算的小程序
  • ¥15 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化