public class SslConfig
extends java.lang.Object
implements java.io.Serializable
A container for SSL-related configuration options, meant to be stored within a VaultConfig instance.
Construct instances of this class using a builder pattern, calling setter methods for each value and then terminating with a call to build().
| Constructor and Description |
|---|
SslConfig() |
| Modifier and Type | Method and Description |
|---|---|
SslConfig |
build()
This is the terminating method in the builder pattern.
|
SslConfig |
clientKeyPemFile(java.io.File clientKeyPemFile)
An RSA private key, for use with Vault's TLS Certificate auth backend.
|
SslConfig |
clientKeyPemResource(java.lang.String classpathResource)
An RSA private key, for use with Vault's TLS Certificate auth backend.
|
SslConfig |
clientKeyPemUTF8(java.lang.String clientKeyPemUTF8)
An RSA private key, for use with Vault's TLS Certificate auth backend.
|
SslConfig |
clientPemFile(java.io.File clientPemFile)
An X.509 client certificate, for use with Vault's TLS Certificate auth backend.
|
SslConfig |
clientPemResource(java.lang.String classpathResource)
An X.509 certificate, for use with Vault's TLS Certificate auth backend.
|
SslConfig |
clientPemUTF8(java.lang.String clientPemUTF8)
An X.509 client certificate, for use with Vault's TLS Certificate auth backend.
|
protected SslConfig |
environmentLoader(EnvironmentLoader environmentLoader)
The code used to load environment variables is encapsulated here, so that a mock version of that environment
loader can be used by unit tests.
|
SslConfig |
keyStore(java.security.KeyStore keyStore,
java.lang.String password)
A Java keystore, containing a client certificate that's registered with Vault's TLS Certificate auth backend.
|
SslConfig |
keyStoreFile(java.io.File keyStoreFile,
java.lang.String password)
A Java keystore, containing a client certificate that's registered with Vault's TLS Certificate auth backend.
|
SslConfig |
keyStoreResource(java.lang.String classpathResource,
java.lang.String password)
A Java keystore, containing a client certificate that's registered with Vault's TLS Certificate auth backend.
|
SslConfig |
pemFile(java.io.File pemFile)
An X.509 certificate, to use when communicating with Vault over HTTPS.
|
SslConfig |
pemResource(java.lang.String classpathResource)
An X.509 certificate, to use when communicating with Vault over HTTPS.
|
SslConfig |
pemUTF8(java.lang.String pemUTF8)
An X.509 certificate, to use when communicating with Vault over HTTPS.
|
SslConfig |
trustStore(java.security.KeyStore trustStore)
A Java keystore, containing the X509 certificate used by Vault.
|
SslConfig |
trustStoreFile(java.io.File trustStoreFile)
A Java keystore, containing the X509 certificate used by Vault.
|
SslConfig |
trustStoreResource(java.lang.String classpathResource)
A Java keystore, containing the X509 certificate used by Vault.
|
SslConfig |
verify(java.lang.Boolean verify)
Whether or not HTTPS connections to the Vault server should verify that a valid SSL certificate is being
used.
|
protected SslConfig environmentLoader(EnvironmentLoader environmentLoader)
The code used to load environment variables is encapsulated here, so that a mock version of that environment loader can be used by unit tests.
This method is used by unit tests, to inject a mock environment variable when constructing a
SslConfig instance using the builder pattern approach rather than the convenience constructor.
There really shouldn't ever be a need to call this method outside of a unit test context (hence the
protected access level).
environmentLoader - An environment variable loader implementation (presumably a mock)public SslConfig verify(java.lang.Boolean verify)
Whether or not HTTPS connections to the Vault server should verify that a valid SSL certificate is being
used. Unless this is set to false, the default behavior is to always verify SSL certificates.
SSL CERTIFICATE VERIFICATION SHOULD NOT BE DISABLED IN PRODUCTION! This feature is made available to
facilitate development or testing environments, where you might be using a self-signed cert that will not
pass verification. However, even if you are using a self-signed cert on your Vault server, you can still leave
SSL verification enabled and have your application supply the cert using pemFile(),
pemResource(), or pemUTF8().
If no verify is explicitly set, either by this method in a builder pattern approach or else by one of the
convenience constructors, then SslConfig will look to the VAULT_SSL_VERIFY
environment variable.
verify - Whether or not to verify the SSL certificate used by Vault with HTTPS connections. Default is true.public SslConfig keyStore(java.security.KeyStore keyStore, java.lang.String password)
A Java keystore, containing a client certificate that's registered with Vault's TLS Certificate auth backend. If you are not using certificate based client auth, then this field may remain un-set.
Note that you cannot mix-and-match JKS based config with PEM based config. If any of the keyStore or trustStore setters are used, then the build() method will complete ignore any PEM data that was set.
keyStore - A keystore, containing a client certificate registered with Vault's TLS Certificate auth backendpassword - The password needed to access the keystore (can be null)public SslConfig keyStoreFile(java.io.File keyStoreFile, java.lang.String password) throws VaultException
A Java keystore, containing a client certificate that's registered with Vault's TLS Certificate auth backend. If you are not using certificate based client auth, then this field may remain un-set. This method loads the keystore from a JKS file on the filesystem.
Note that you cannot mix-and-match JKS based config with PEM based config. If any of the keyStore or trustStore setters are used, then the build() method will complete ignore any PEM data that was set.
keyStoreFile - A JKS keystore file, containing a client certificate registered with Vault's TLS Certificate auth backendpassword - The password needed to access the keystore (can be null)VaultException - If any error occurs while loading the keystorepublic SslConfig keyStoreResource(java.lang.String classpathResource, java.lang.String password) throws VaultException
A Java keystore, containing a client certificate that's registered with Vault's TLS Certificate auth backend. If you are not using certificate based client auth, then this field may remain un-set. This method loads the keystore from a classpath resource (e.g. you've bundled the JKS file into your library or application's JAR/WAR/EAR file).
Note that you cannot mix-and-match JKS based config with PEM based config. If any of the keyStore or trustStore setters are used, then the build() method will complete ignore any PEM data that was set.
classpathResource - A JKS keystore file, containing a client certificate registered with Vault's TLS Certificate auth backendpassword - The password needed to access the keystore (can be null)VaultException - If any error occurs while loading the keystorepublic SslConfig trustStore(java.security.KeyStore trustStore)
A Java keystore, containing the X509 certificate used by Vault. Used by the driver to trust SSL connections from the server using this cert.
Note that you cannot mix-and-match JKS based config with PEM based config. If any of the keyStore or trustStore setters are used, then the build() method will complete ignore any PEM data that was set.
trustStore - A truststore, containing the Vault server's X509 certificatepublic SslConfig trustStoreFile(java.io.File trustStoreFile) throws VaultException
A Java keystore, containing the X509 certificate used by Vault. Used by the driver to trust SSL connections from the server using this cert. This method load the truststore from a JKS file on the filesystem.
Note that you cannot mix-and-match JKS based config with PEM based config. If any of the keyStore or trustStore setters are used, then the build() method will complete ignore any PEM data that was set.
trustStoreFile - A JKS truststore file, containing the Vault server's X509 certificateVaultException - If any error occurs while loading the truststorepublic SslConfig trustStoreResource(java.lang.String classpathResource) throws VaultException
A Java keystore, containing the X509 certificate used by Vault. Used by the driver to trust SSL connections from the server using this cert. This method load the truststore from a classpath resource (e.g. you've bundled the JKS file into your library or application's JAR/WAR/EAR file).
Note that you cannot mix-and-match JKS based config with PEM based config. If any of the keyStore or trustStore setters are used, then the build() method will complete ignore any PEM data that was set.
classpathResource - A JKS truststore file, containing the Vault server's X509 certificateVaultException - If any error occurs while loading the truststorepublic SslConfig pemUTF8(java.lang.String pemUTF8)
An X.509 certificate, to use when communicating with Vault over HTTPS. This method accepts a string containing the certificate data. This string should meet the following requirements:
If no certificate data is provided, either by this method or pemFile()
or pemResource(), then SslConfig will look to the
VAULT_SSL_CERT environment variable.
pemUTF8 - An X.509 certificate, in unencrypted PEM format with UTF-8 encoding.public SslConfig pemFile(java.io.File pemFile) throws VaultException
An X.509 certificate, to use when communicating with Vault over HTTPS. This method accepts the path of a file containing the certificate data. This file's contents should meet the following requirements:
If no certificate data is provided, either by this method or pemResource()
or pemUTF8(), then SslConfig will look to the
VAULT_SSL_CERT environment variable.
pemFile - The path of a file containing an X.509 certificate, in unencrypted PEM format with UTF-8 encoding.VaultException - If any error occurs while loading and parsing the PEM filepublic SslConfig pemResource(java.lang.String classpathResource) throws VaultException
An X.509 certificate, to use when communicating with Vault over HTTPS. This method accepts the path of a classpath resource containing the certificate data (e.g. you've bundled the cert into your library or application's JAR/WAR/EAR file). This resource's contents should meet the following requirements:
If no certificate data is provided, either by this method or pemFile()
or pemUTF8(), then SslConfig will look to the
VAULT_SSL_CERT environment variable.
classpathResource - The path of a classpath resource containing an X.509 certificate, in unencrypted PEM format with UTF-8 encoding.VaultException - If any error occurs while loading and parsing the PEM filepublic SslConfig clientPemUTF8(java.lang.String clientPemUTF8)
An X.509 client certificate, for use with Vault's TLS Certificate auth backend. This string should meet the same formatting requirements as pemUTF8(String).
clientPemUTF8 - An X.509 client certificate, in unencrypted PEM format with UTF-8 encoding.Auth.loginByCert()public SslConfig clientPemFile(java.io.File clientPemFile) throws VaultException
An X.509 client certificate, for use with Vault's TLS Certificate auth backend. This method accepts the path of a file containing the certificate data. This file should meet the same requirements as pemFile(File).
clientPemFile - The path of a file containing an X.509 certificate, in unencrypted PEM format with UTF-8 encoding.VaultException - If any error occurs while loading and parsing the PEM fileAuth.loginByCert()public SslConfig clientPemResource(java.lang.String classpathResource) throws VaultException
An X.509 certificate, for use with Vault's TLS Certificate auth backend. This method accepts the path of a classpath resource containing the certificate data (e.g. you've bundled the cert into your library or application's JAR/WAR/EAR file). This resource's contents should meet the same requirements as pemResource(String).
classpathResource - The path of a classpath resource containing an X.509 certificate, in unencrypted PEM format with UTF-8 encoding.VaultException - If any error occurs while loading and parsing the PEM fileAuth.loginByCert()public SslConfig clientKeyPemUTF8(java.lang.String clientKeyPemUTF8)
An RSA private key, for use with Vault's TLS Certificate auth backend. The string should meet the following requirements:
clientKeyPemUTF8 - An RSA private key, in unencrypted PEM format with UTF-8 encoding.public SslConfig clientKeyPemFile(java.io.File clientKeyPemFile) throws VaultException
An RSA private key, for use with Vault's TLS Certificate auth backend. This method accepts the path of a file containing the private key data. This file's contents should meet the following requirements:
clientKeyPemFile - The path of a file containing an RSA private key, in unencrypted PEM format with UTF-8 encoding.VaultException - If any error occurs while loading and parsing the PEM filepublic SslConfig clientKeyPemResource(java.lang.String classpathResource) throws VaultException
An RSA private key, for use with Vault's TLS Certificate auth backend. This method accepts the path of a classpath resource containing the private key data (e.g. you've bundled the private key into your library or application's JAR/WAR/EAR file). This file's contents should meet the following requirements:
classpathResource - The path of a classpath resource containing an RSA private key, in unencrypted PEM format with UTF-8 encoding.VaultException - If any error occurs while loading and parsing the PEM filepublic SslConfig build() throws VaultException
This is the terminating method in the builder pattern. The method that validates all of the fields that
has been set already, uses environment variables when available to populate any unset fields, and returns
a SslConfig object that is ready for use.
VaultException - If SSL certificate verification is enabled, and any problem occurs while trying to build an SSLContext