不能在HttpBuilder版本0.7.1中使用ignoreSSLIssues

时间:2017-05-10 07:34:13

标签: groovy ssl-certificate httpbuilder

Java 8 | Groovy语言|
IDE:IntelliJ IDEA | Gradle 3

我遇到SSL问题

代码:

import groovyx.net.http.RESTClient

def client = new RESTClient()
client.ignoreSSLIssues()
def result = client.get(uri: "https://sacvo76l6b.execute-api.ap-northeast-
1.amazonaws.com/")

它抛出异常

  

javax.net.ssl.SSLPeerUnverifiedException:peer not authenticated

     

at sun.security.ssl.SSLSessionImpl.getPeerCertificates(SSLSessionImpl.java:431)     在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)     在org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:479)     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:906)     在org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:1066)     在org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:1044)     at groovyx.net.http.HTTPBuilder.doRequest(HTTPBuilder.java:515)     at groovyx.net.http.RESTClient.get(RESTClient.java:119)     在Test.getAuthCode_(Test.groovy:53)

虽然我正在使用ignoreSSLIssues(),但似乎对我不起作用。

我还下载了0.7.2版来验证这个问题,但它也是同样的问题

PS1:如果我使用Postman

,Uri对我来说很好

PS2:HttpURLConnection库也适用于我

你知道吗?非常感谢

1 个答案:

答案 0 :(得分:4)

解决“javax.net.ssl.SSLPeerUnverifiedException:peer not authenticated”问题  我只是将最新版本的httpclient导入Gradle / Maven

compile 'org.apache.httpcomponents:httpclient:4.5.3'

我花了2天时间才解决。我希望这会对像我这样的人有所帮助。