我能够使用Advanced REST客户端成功请求。在ARC中,我使用了以下config
使用下面的scala代码,输出为"异常:java.net.ConnectException:常规SSLEngine问题"
import gigahorse.{ AuthScheme, Gigahorse, MimeTypes }
val request = Gigahorse
.url("https://<url>").post(xml)
.withAuth("<uid>", "<pwd>", AuthScheme.Basic)
.withContentType(MimeTypes.XML, Gigahorse.utf8)
.withRequestTimeout(5000.millis)
val client = SSLManager(None, None, "TLSv1").createSSLHttpClient
val resp = client.run(request)
resp.onComplete({
case Success(listInt) => {
log.info(s"Result:${listInt}")
}
case Failure(exception) => {
log.info(s"Exception:${exception}")
}
})
此代码有什么问题?
完整的例外:
[error] Caused by: javax.net.ssl.SSLHandshakeException: General SSLEngine problem
[error] at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
[error] at sun.security.ssl.SSLEngineImpl.fatal(SSLEngineImpl.java:1728)
[error] at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:304)
[error] at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:296)
[error] at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1514)
[error] at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:216)
[error] at sun.security.ssl.Handshaker.processLoop(Handshaker.java:1026)
[error] at sun.security.ssl.Handshaker$1.run(Handshaker.java:966)
[error] at sun.security.ssl.Handshaker$1.run(Handshaker.java:963)
[error] at java.security.AccessController.doPrivileged(Native Method)
[error] at sun.security.ssl.Handshaker$DelegatedTask.run(Handshaker.java:1416)
[error] at org.jboss.netty.handler.ssl.SslHandler.runDelegatedTasks(SslHandler.java:1392)
[error] at org.jboss.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:1255)
[error] ... 18 more
[error] Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
[error] at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:397)
[error] at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:302)
[error] at sun.security.validator.Validator.validate(Validator.java:260)
[error] at sun.security.ssl.X509TrustManagerImpl.validate(X509TrustManagerImpl.java:324)
[error] at sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:281)
[error] at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:136)
[error] at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1501)
[error] ... 26 more
[error] Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
[error] at sun.security.provider.certpath.SunCertPathBuilder.build(SunCertPathBuilder.java:141)
[error] at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:126)
[error] at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:280)
[error] at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:392)