Beta
Disables validating server SSL certificates by setting the SSL socket factory using SslUtils#trustAllSSLContext() for the SSL context and SSLSocketFactory#ALLOW_ALL_HOSTNAME_VERIFIER for the host name verifier.
Be careful! Disabling certificate validation is dangerous and should only be done in
testing environments.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-28 UTC."],[],[],null,["# Class ApacheHttpTransport.Builder (2.0.0)\n\nVersion latestkeyboard_arrow_down\n\n- [2.0.0 (latest)](/java/docs/reference/google-http-client/latest/com.google.api.client.http.apache.ApacheHttpTransport.Builder)\n- [1.47.1](/java/docs/reference/google-http-client/1.47.1/com.google.api.client.http.apache.ApacheHttpTransport.Builder)\n- [1.46.3](/java/docs/reference/google-http-client/1.46.3/com.google.api.client.http.apache.ApacheHttpTransport.Builder)\n- [1.45.3](/java/docs/reference/google-http-client/1.45.3/com.google.api.client.http.apache.ApacheHttpTransport.Builder)\n- [1.44.2](/java/docs/reference/google-http-client/1.44.2/com.google.api.client.http.apache.ApacheHttpTransport.Builder)\n- [1.43.2](/java/docs/reference/google-http-client/1.43.2/com.google.api.client.http.apache.ApacheHttpTransport.Builder)\n- [1.42.3](/java/docs/reference/google-http-client/1.42.3/com.google.api.client.http.apache.ApacheHttpTransport.Builder)\n- [1.41.8](/java/docs/reference/google-http-client/1.41.8/com.google.api.client.http.apache.ApacheHttpTransport.Builder) \n\n public static final class ApacheHttpTransport.Builder\n\nBuilder for [ApacheHttpTransport](/java/docs/reference/google-http-client/latest/com.google.api.client.http.apache.ApacheHttpTransport).\n\nImplementation is not thread-safe. \n\nInheritance\n-----------\n\n[java.lang.Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \\\u003e ApacheHttpTransport.Builder \n\nInherited Members\n-----------------\n\n[Object.clone()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--) \n[Object.equals(Object)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-) \n[Object.finalize()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--) \n[Object.getClass()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--) \n[Object.hashCode()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--) \n[Object.notify()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--) \n[Object.notifyAll()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--) \n[Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--) \n[Object.wait()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--) \n[Object.wait(long)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-) \n[Object.wait(long,int)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-)\n\nConstructors\n------------\n\n### Builder()\n\n public Builder()\n\nMethods\n-------\n\n### build()\n\n public ApacheHttpTransport build()\n\nReturns a new instance of [ApacheHttpTransport](/java/docs/reference/google-http-client/latest/com.google.api.client.http.apache.ApacheHttpTransport) based on the options.\n\n### doNotValidateCertificate()\n\n public ApacheHttpTransport.Builder doNotValidateCertificate()\n\n[Beta](/java/docs/reference/google-http-client/latest/com.google.api.client.util.Beta) \n\nDisables validating server SSL certificates by setting the SSL socket factory using [SslUtils#trustAllSSLContext()](/java/docs/reference/google-http-client/latest/com.google.api.client.util.SslUtils#com_google_api_client_util_SslUtils_trustAllSSLContext__) for the SSL context and SSLSocketFactory#ALLOW_ALL_HOSTNAME_VERIFIER for the host name verifier.\n\nBe careful! Disabling certificate validation is dangerous and should only be done in\ntesting environments.\n\n### getHttpParams()\n\n public HttpParams getHttpParams()\n\nReturns the HTTP parameters.\n\n### getSSLSocketFactory()\n\n public SSLSocketFactory getSSLSocketFactory()\n\nReturns the SSL socket factory (SSLSocketFactory#getSocketFactory() by default).\n\n### setProxy(HttpHost proxy)\n\n public ApacheHttpTransport.Builder setProxy(HttpHost proxy)\n\nSets the HTTP proxy to use DefaultHttpRoutePlanner or `null` to use [#setProxySelector(ProxySelector)](/java/docs/reference/google-http-client/latest/com.google.api.client.http.apache.ApacheHttpTransport.Builder#com_google_api_client_http_apache_ApacheHttpTransport_Builder_setProxySelector_java_net_ProxySelector_) with ProxySelector#getDefault().\n\nBy default it is `null`, which uses the proxy settings from [system\nproperties](http://docs.oracle.com/javase/7/docs/api/java/net/doc-files/net-properties.html).\n\nFor example:\n\nsetProxy(new HttpHost(\"127.0.0.1\", 8080))\n\n### setProxySelector(ProxySelector proxySelector)\n\n public ApacheHttpTransport.Builder setProxySelector(ProxySelector proxySelector)\n\nSets the HTTP proxy selector to use ProxySelectorRoutePlanner or `null` for\nDefaultHttpRoutePlanner.\n\nBy default it is ProxySelector#getDefault() which uses the proxy settings from [system\nproperties](http://docs.oracle.com/javase/7/docs/api/java/net/doc-files/net-properties.html).\n\n### setSocketFactory(SSLSocketFactory socketFactory)\n\n public ApacheHttpTransport.Builder setSocketFactory(SSLSocketFactory socketFactory)\n\nSets the SSL socket factory (SSLSocketFactory#getSocketFactory() by default).\n\n### trustCertificates(KeyStore trustStore)\n\n public ApacheHttpTransport.Builder trustCertificates(KeyStore trustStore)\n\nSets the SSL socket factory based on a root certificate trust store.\n\n### trustCertificatesFromJavaKeyStore(InputStream keyStoreStream, String storePass)\n\n public ApacheHttpTransport.Builder trustCertificatesFromJavaKeyStore(InputStream keyStoreStream, String storePass)\n\nSets the SSL socket factory based on root certificates in a Java KeyStore.\n\nExample usage:\n\ntrustCertificatesFromJavaKeyStore(new FileInputStream(\"certs.jks\"), \"password\");\n\n### trustCertificatesFromStream(InputStream certificateStream)\n\n public ApacheHttpTransport.Builder trustCertificatesFromStream(InputStream certificateStream)\n\nSets the SSL socket factory based root certificates generated from the specified stream using\nCertificateFactory#generateCertificates(InputStream).\n\nExample usage:\n\ntrustCertificatesFromStream(new FileInputStream(\"certs.pem\"));"]]