Package io.github.stevenjdh.simple.ssl
Interface PEMContext.Builder
- All Known Implementing Classes:
PEMContextBuilderImpl
- Enclosing interface:
- PEMContext
public static interface PEMContext.Builder
A builder of PEM derived SSLContext instances.
PEM derived SSLContext
instances are created through the
PEMContext.Builder
. Each of the setter methods modifies the state
of the builder and returns the same instance. Builders are not
thread-safe and should not be used concurrently from multiple threads
without external synchronization.
- Since:
- 1.0
-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Returns a newSSLContext
instance built from the current state of this builder.Optionally sets the keystore type being built with PKCS12 being the default.saveKeyStore
(Path keyMaterialPath, char[] password) Optionally saves the built keystore to the provided path, and protects its integrity with a password.saveTrustStore
(Path trustMaterialPath, char[] password) Optionally saves the built truststore to the provided path, and protects its integrity with a password.Optionally sets the truststore type being built with PKCS12 being the default.withPrivateKey
(Path keyPath, Path certPath) Optionally sets the keystore configuration using a Base64 encoded private key for building anSSLContext
.withPrivateKeyPassword
(char[] password) Optionally sets the password for the encrypted private key material.withPublicKey
(Path certPath) Optionally sets the truststore configuration using a Base64 encoded certificate or certificate chain for building anSSLContext
.
-
Method Details
-
withPublicKey
Optionally sets the truststore configuration using a Base64 encoded certificate or certificate chain for building anSSLContext
.- Parameters:
certPath
- The path to the file containing one or more certificates.- Returns:
- This builder.
-
withPrivateKey
Optionally sets the keystore configuration using a Base64 encoded private key for building anSSLContext
.- Parameters:
keyPath
- The path to the file containing the private key material.certPath
- The path to the file containing the certificate or certificate chain with the corresponding public key that pairs with the private key.- Returns:
- This builder.
-
withPrivateKeyPassword
Optionally sets the password for the encrypted private key material.- Parameters:
password
- The password used to decrypt the encrypted key. If this is set to null or an empty char[], it will be assumed that decryption is not needed.- Returns:
- This builder.
-
saveKeyStore
Optionally saves the built keystore to the provided path, and protects its integrity with a password.- Parameters:
keyMaterialPath
- The path used for saving the keystore.password
- The password to set when saving the keystore, which has a minimum length of 4 characters.- Returns:
- This builder.
-
saveTrustStore
Optionally saves the built truststore to the provided path, and protects its integrity with a password.- Parameters:
trustMaterialPath
- The path used for saving the truststore.password
- The password to set when saving the truststore, which has a minimum length of 4 characters.- Returns:
- This builder.
-
keyStoreType
Optionally sets the keystore type being built with PKCS12 being the default.- Parameters:
type
- The keystore type such as PKCS12 or the legacy JKS.- Returns:
- This builder.
-
trustStoreType
Optionally sets the truststore type being built with PKCS12 being the default.- Parameters:
type
- The truststore type such as PKCS12 or the legacy JKS.- Returns:
- This builder.
-
build
SSLContext build()Returns a newSSLContext
instance built from the current state of this builder.- Returns:
- A new
SSLContext
.
-