Grails:Groovy:SSLPeerUnverifiedException: 对等体未通过身份验证 [英] Grails:Groovy:SSLPeerUnverifiedException: peer not authenticated
问题描述
我想在本地系统中运行代码时向 url 发送 xml 请求,它运行良好我创建了一个 war 文件并将其部署在服务器中,但在服务器中运行时出现异常javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated'我用过 groovy http builder
I want to hit an xml request to a url while running the code in my local system it is working well i have created a war file and deployed the same in server,but while running in server getting an exception 'javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated'
i have used groovy http builder
def http = new HTTPBuilder(url)
http.auth.basic('username', 'password')
try {
http.request(Method.POST, ContentType.TEXT) {
req->
headers.accept = "application/xml"
body = request //xml request
response.success = {
resp,reader ->
Response = reader.text
}
}
}
catch(HttpResponseException ex) {
println ex;
}
在这种情况下我该如何解决这个问题..?
how can i solve this problem in this case..?
推荐答案
解决方法: 以下答案提供了解决此问题的方法:https://stackoverflow.com/a/25076888/782034
Workaround: The following answer provides a workaround for this issue: https://stackoverflow.com/a/25076888/782034
刚发现HttpBuilder的新版本(0.7.1)引入方法:
Just found out that new version (0.7.1) of HttpBuilder introduces method:
ignoreSSLIssues()
这解决了有关无效 SSL 证书的所有问题(当然你必须知道它也会降低安全性).
This solves all problems regarding invalid SSL certificates (of course you have to be aware that it also decrease security).
有关此方法的更多信息:http://groovy.codehaus.org/modules/http-builder/doc/ssl.html(部分在底部)
More information about this method: http://groovy.codehaus.org/modules/http-builder/doc/ssl.html (section at the bottom)
即
def http = new HTTPBuilder(url)
http.ignoreSSLIssues()
解决方案:如果您想以正确"的方式做事,请查看有关导入服务器证书的其他解决方案.例如SSLPeerUnverifiedException:对等体未通过身份验证
Solution: If you want to do things the 'proper' way, checkout the other solutions regarding importing the server's certificates. e.g. SSLPeerUnverifiedException: peer not authenticated
这篇关于Grails:Groovy:SSLPeerUnverifiedException: 对等体未通过身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!