Grails:Groovy:SSLPeerUnverifiedException:没有通过身份验证 [英] Grails:Groovy:SSLPeerUnverifiedException: peer not authenticated
问题描述
我希望在运行本地系统中的代码时向URL发出xml请求,它运行良好我创建了一个war文件并在服务器中部署了该文件,但在服务器中运行时发生异常'javax.net.ssl.SSLPeerUnverifiedException:peer not authenticated'
i已使用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;
}
在这种情况下,我该如何解决这个问题..?
解决方法:以下答案为此问题提供了解决方法: https://stackoverflow.com/a/25076888/782034
Just发现HttpBuilder的新版本(0.7.1)引入了
方法:
ignoreSSLIssues()
解决了无效SSL证书的所有问题(当然,
您必须意识到它也会降低安全性)。
有关此方法的更多信息:
http://groovy.codehaus.org/modules/http-builder/doc/ssl.html (底部的
部分)
ie
def http = new HTTPBuilder(url)
http.ignoreSSLIssues()
解决方案:如果您想以正确的方式执行操作,请查看有关导入服务器证书的其他解决方案。例如 SSLPeerUnverifiedException:未通过身份验证
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..?
Workaround: The following answer provides a workaround for this issue: https://stackoverflow.com/a/25076888/782034
Just found out that new version (0.7.1) of HttpBuilder introduces method:
ignoreSSLIssues()
This solves all problems regarding invalid SSL certificates (of course you have to be aware that it also decrease security).
More information about this method: http://groovy.codehaus.org/modules/http-builder/doc/ssl.html (section at the bottom)
i.e.
def http = new HTTPBuilder(url)
http.ignoreSSLIssues()
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屋!