public class HttpClientOptions
extends java.lang.Object
Options for customizing the HttpClient. The available HttpClient options provided by this class are:
1. Trust All Certificates
2. Keystore Provided (containing your client certificate and private key)
NOTE: These options default to 'false' if not set.
Trust All Certificates: By default, SSL certificate verification is performed using a CA certificate store. Ensuring
that the certificate is signed by a CA that is present in the store is how to verify that the remote server is who it claims
it is. In the case of self-signed certificates, the server is using a certificate that may not be signed by one of the
CAs in the store. In this case, attempting to establish a connection to the server will result in an SSLHandshakeException.
By configuring your HTTP Client options with 'trust all certificates' is one way to deal with self-signed certificates.
NOTE: This mode is considered insecure with the possibility for a man-in-the-middle attack.
Usage Example: HttpClientOptions httpOptions = new HttpClientOptions.Builder().trustAllCertificates(true).build();
Keystore Provided: If the endpoint that you are connecting to has Mutual TLS configured, as a Java client, you will be
required to provide a keystore. The keystore will need to contain your client certificate and private key. For reference, a
PKCS12 keystore can be created using the 'openssl' utility:
openssl pkcs12 -export -in (file_containing_your_client_certificate) -inkey (file_containing_your_private_key)
-out (desired_keystore_filename.p12)
The keystore file, keystore password, and keystore type can be configured one of two ways:
1. System properties
-Djavax.net.ssl.keyStore=$your_keystore_filename
-Djavax.net.ssl.keyStorePassword=$your_keystore_password
-Djavax.net.ssl.keyStoreType=$your_keystore_type
2. HttpClientOptions.Builder keyStoreFile(), keyStorePassword(), and keyStoreType() methods
NOTE: When customizing your HttpClient with a keystore, the Builder keyStoreProvided() method must be set to 'true'.
Usage Example: HttpClientOptions httpOptions = new HttpClientOptions.Builder().keyStoreProvided(true).build()
-- In this example, keyStoreProvided() is 'true', and since the Builder's keyStoreFile(), keyStorePassword(), and
keyStoreType() were not included, the code will look in the system properties for the keyStoreFile, keyStorePassword,
and keyStoreType.