0

I am using com.google.api.client.http.HttpRequest object to hit a URL for Akamai Purge. However, I am getting an SSL Handshake error but as it is in a lower environment so I am allowed to ignore this. There are multiple examples on the internet ignoring SSL Handshake for Spring REST Template and Apache HTTPRequest. But I could not find much on google HttpRequest. I need a way to ignore SSL Cert in my code. Below is my code:

'''

HttpTransport httpTransport = new ApacheHttpTransport();

HttpRequestFactory requestFactory = httpTransport.createRequestFactory();

URI uri = URI.create(url1);

String requestBody = "{\"objects\": [471642]}";

HttpRequest request = requestFactory.buildPostRequest(new GenericUrl(uri),

ByteArrayContent.fromString("application/json", requestBody));

GoogleHttpClientEdgeGridRequestSigner requestSigner = new GoogleHttpClientEdgeGridRequestSigner(credential);

requestSigner.sign(request);

HttpResponse response = request.execute();

'''

nomadSK25
  • 2,350
  • 3
  • 25
  • 36
Vaibhav Bhardwaj
  • 179
  • 1
  • 1
  • 9
  • Does this help? https://stackoverflow.com/a/45971951/11226302. There is an option doNotValidateCertificate() that you can use apparently! – Shivam Puri Dec 10 '19 at 14:09

1 Answers1

0

Finally I got it. Thanks Shivam Puri. I used below code

'''

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

transBuilder.doNotValidateCertificate().build();

'''

Vaibhav Bhardwaj
  • 179
  • 1
  • 1
  • 9