【发布时间】:2017-11-07 21:22:01
【问题描述】:
我正在尝试使用 Vert.x Web 客户端 3.5.0(和 Java 8)通过 HTTPS 发送 GET 请求。
Vertx vertx = Vertx.vertx();
WebClientOptions clientOptions = new WebClientOptions();
WebClient webClient = WebClient.create(vertx, clientOptions);
Handler<AsyncResult<HttpResponse<Buffer>>> testHandler = asyncResult -> {
System.out.println("async = " + asyncResult);
System.out.println("async result = " + asyncResult.result());
System.out.println("async failed = " + asyncResult.failed());
System.out.println("async succeeded = " + asyncResult.succeeded());
System.out.println("async cause = " + asyncResult.cause());
};
webClient.get(443, "oauth.vk.com", "/access_token").
addQueryParam("client_id", appId).
addQueryParam("client_secret", secureKey).
addQueryParam("v", apiVersion)
addQueryParam("grant_type", "client_credentials").
ssl(true).
send(testHandler);
它在我的本地机器 (Windows 10) 上工作,但在 Ubuntu (17.04 x64) 服务器上失败。 asyncResult.failed() 是 true。但是asyncResult.cause() 是null。
我使用 cURL 对此进行了测试,它工作正常;看起来是 Vert.x 和 OpenSSL 交互的问题。
这是我的 Maven 的 POM 文件的摘录:
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-core</artifactId>
<version>3.5.0</version>
</dependency>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-web-client</artifactId>
<version>3.5.0</version>
</dependency>
【问题讨论】:
-
尝试“信任所有人”?此外,尝试连接调试器以深入了解根本原因(例如,可能是密码问题)
-
@opyate
clientOptions.setTrustAll(true);没有区别,-Djavax.net.debug=all也一样。而且它不安全。我正在寻找setTrustOptions文档。希望远程调试能帮到我。 -
@opyate 对
-Djavax.net.debug=all做了重要的事情:系统属性 jdk.tls.client.cipherSuites 设置为 'null' 系统属性 jdk.tls.server.cipherSuites 设置为 'null ' 在服务器启动时。