对等方未在 Web 服务中进行身份验证? [英] peer not authenticated in web service?

查看:63
本文介绍了对等方未在 Web 服务中进行身份验证?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在 Tomcat 7 上运行的 Java 1.7 中使用 Spring 的 REST Web 服务.我在我的开发机器上有自签名证书.当我尝试使用 rest 客户端调用 API 时,出现以下错误:

I've a REST web service using Spring in Java 1.7 running on Tomcat 7. I've self signed cert on my dev machine. When I try to invoke the API using rest client, it gives below error:

    peer not authenticated
    javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated
        at sun.security.ssl.SSLSessionImpl.getPeerCertificates(SSLSessionImpl.java:397)
        at org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:128)
        at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:572)
        at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:180)
        at org.apache.http.impl.conn.ManagedClientConnectionImpl.open(ManagedClientConnectionImpl.java:294)
        at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:640)
        at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:479)
        at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:906)
        at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:805)
        at org.wiztools.restclient.HTTPClientRequestExecuter.execute(HTTPClientRequestExecuter.java:387)
        at org.wiztools.restclient.ui.RESTViewImpl$2.run(RESTViewImpl.java:320)

谁能告诉我如何在不更改任何 Java 代码的情况下摆脱此错误?

Can any one tell me how to get rid of this error without making any java code changes?

注意:我已经在我的环境中运行了以下命令:

Note: I've run below command in my env already:

keytool -genkey -v -keyalg RSA -alias tomcat -keypass 12345 -storepass 12345

推荐答案

看起来服务器正在请求客户端身份验证,而您并未从客户端向服务器发送一个证书.尝试使用 -Djavax.net.debug=all 参数运行 VM.

It looks like the server is requesting client authetication and you are not send one certificate from the client to the server. Try to run the VM with -Djavax.net.debug=all parameter.

而且我认为不更改您的代码就不可能做到这一点.

And I don't think it is possible to do that without make changes to your code.

这篇关于对等方未在 Web 服务中进行身份验证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆