使用ClientResource的HTTPS请求

时间:2016-08-23 22:19:40

标签: java restlet

当我为http创建请求时,它适用于此:

ClientResource resource = new ClientResource(protocol + "://localhost:" + port + path);

但是当我创建https个请求时,我收到了错误:

Starting the internal [HTTPS/1.1] server on port 8081
Starting the internal HTTP client
A recoverable error was detected (1001), attempting again in 2000 ms.
A recoverable error was detected (1001), attempting again in 2000 ms.
Stopping the internal server

我知道当我们使用Client对象时,我们应该设置:

Client client = new Client(Protocol.HTTPS);

所以,我怀疑为ClientResource设置类似的东西。我试过了,但没有解决:

resource.setProtocol(Protocol.HTTPS);

还试过:

Client client = new Client(Protocol.HTTPS);
resource.setProtocol(Protocol.HTTPS);
resource.setNext(client);

但是我得到了相同的日志。从日志中可以看出,它首先创建了一个HTTPS服务器但是HTTP客户端。

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

问题与证书有关。我已经设置了一个信任密钥库并将其用于我的示例。