【发布时间】:2020-04-03 17:30:23
【问题描述】:
我正在使用 com.google.api.client.http.HttpRequest 对象来访问 Akamai Purge 的 URL。但是,我收到 SSL 握手错误,但由于它处于较低的环境中,所以我可以忽略它。互联网上有多个示例忽略了 Spring REST 模板和 Apache HTTPRequest 的 SSL 握手。但我在 google HttpRequest 上找不到太多。我需要一种在我的代码中忽略 SSL 证书的方法。以下是我的代码:
'''
HttpTransport httpTransport = new ApacheHttpTransport();
HttpRequestFactory requestFactory = httpTransport.createRequestFactory();
URI uri = URI.create(url1);
String requestBody = "{\"objects\": [471642]}";
HttpRequest 请求 = requestFactory.buildPostRequest(new GenericUrl(uri),
ByteArrayContent.fromString("application/json", requestBody));
GoogleHttpClientEdgeGridRequestSigner requestSigner = new GoogleHttpClientEdgeGridRequestSigner(凭据);
requestSigner.sign(request);
HttpResponse 响应 = request.execute();
'''
【问题讨论】:
-
这有帮助吗? stackoverflow.com/a/45971951/11226302。有一个选项 doNotValidateCertificate() 显然可以使用!
标签: java ssl httprequest