I'm using Google's HTTP Client for Java in my Android app. My server is temporarily using a self-signed certificate while we do QA testing. We'll have a properly signed cert when we release, but for now I just need to ignore the...
CertPathValidatorException: Trust anchor for certification path not found.
... error message and tell the api to continue processing the http request/response.
I can't find anything in Google's documentation on where I can disable this check. I found several StackOverflow posts for other apis, but not the Google HTTP Client. Any help?
import com.google.api.client.http.GenericUrl;
import com.google.api.client.http.HttpRequest;
import com.google.api.client.http.HttpRequestFactory;
import com.google.api.client.http.HttpRequestInitializer;
import com.google.api.client.http.HttpResponse;
import com.google.api.client.http.HttpTransport;
import com.google.api.client.http.UrlEncodedContent;
import com.google.api.client.http.javanet.NetHttpTransport;
import com.google.api.client.json.JsonFactory;
import com.google.api.client.json.JsonObjectParser;
import com.google.api.client.json.jackson2.JacksonFactory;
import com.google.api.client.util.Maps;
import com.google.api.client.util.escape.CharEscapers;
...
static final HttpTransport HTTP_TRANSPORT = new NetHttpTransport();
HttpRequestFactory requestFactory =
HTTP_TRANSPORT.createRequestFactory(new HttpRequestInitializer() {
@Override
public void initialize(HttpRequest request) {
request.setParser(new JsonObjectParser(JSON_FACTORY));
request.setConnectTimeout(defaultTimeoutSeconds()*1000);
request.setReadTimeout(defaultTimeoutSeconds()*1000);
}
});