【问题标题】:How to ignore SSL check while using com.google.api.client.http.HttpRequest使用 com.google.api.client.http.HttpRequest 时如何忽略 SSL 检查
【发布时间】: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();

'''

【问题讨论】:

标签: java ssl httprequest


【解决方案1】:

终于明白了。谢谢希瓦姆普里。我用了下面的代码

'''

ApacheHttpTransport.Builder transBuilder = new ApacheHttpTransport.Builder(); ApacheHttpTransport httpTransport =

transBuilder.doNotValidateCertificate().build();

'''

【讨论】:

    猜你喜欢
    • 2021-09-26
    • 1970-01-01
    • 1970-01-01
    • 2015-06-23
    • 2018-06-08
    • 2023-03-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多