public class SSLContextBuilder extends Object
SSLContext
instances.
Please note: the default Oracle JSSE implementation of SSLContext.init(KeyManager[], TrustManager[], SecureRandom)
accepts multiple key and trust managers, however only only first matching type is ever used.
See for example:
SSLContext.html#init
Constructor and Description |
---|
SSLContextBuilder() |
Modifier and Type | Method and Description |
---|---|
SSLContext |
build()
Builds a new SSLContext.
|
static SSLContextBuilder |
create() |
protected void |
initSSLContext(SSLContext sslContext,
Collection<KeyManager> keyManagers,
Collection<TrustManager> trustManagers,
SecureRandom secureRandom) |
SSLContextBuilder |
loadKeyMaterial(File file,
char[] storePassword,
char[] keyPassword) |
SSLContextBuilder |
loadKeyMaterial(File file,
char[] storePassword,
char[] keyPassword,
PrivateKeyStrategy aliasStrategy) |
SSLContextBuilder |
loadKeyMaterial(KeyStore keyStore,
char[] keyPassword) |
SSLContextBuilder |
loadKeyMaterial(KeyStore keyStore,
char[] keyPassword,
PrivateKeyStrategy aliasStrategy) |
SSLContextBuilder |
loadKeyMaterial(Path file,
char[] storePassword,
char[] keyPassword,
OpenOption... openOptions) |
SSLContextBuilder |
loadKeyMaterial(Path file,
char[] storePassword,
char[] keyPassword,
PrivateKeyStrategy aliasStrategy,
OpenOption... openOptions) |
SSLContextBuilder |
loadKeyMaterial(URL url,
char[] storePassword,
char[] keyPassword) |
SSLContextBuilder |
loadKeyMaterial(URL url,
char[] storePassword,
char[] keyPassword,
PrivateKeyStrategy aliasStrategy) |
SSLContextBuilder |
loadTrustMaterial(File file) |
SSLContextBuilder |
loadTrustMaterial(File file,
char[] storePassword) |
SSLContextBuilder |
loadTrustMaterial(File file,
char[] storePassword,
TrustStrategy trustStrategy) |
SSLContextBuilder |
loadTrustMaterial(KeyStore trustStore,
TrustStrategy trustStrategy) |
SSLContextBuilder |
loadTrustMaterial(Path file) |
SSLContextBuilder |
loadTrustMaterial(Path file,
char[] storePassword) |
SSLContextBuilder |
loadTrustMaterial(Path file,
char[] storePassword,
TrustStrategy trustStrategy,
OpenOption... openOptions) |
SSLContextBuilder |
loadTrustMaterial(TrustStrategy trustStrategy) |
SSLContextBuilder |
loadTrustMaterial(URL url,
char[] storePassword) |
SSLContextBuilder |
loadTrustMaterial(URL url,
char[] storePassword,
TrustStrategy trustStrategy) |
SSLContextBuilder |
setKeyManagerFactoryAlgorithm(String keyManagerFactoryAlgorithm)
Sets the key manager factory algorithm name.
|
SSLContextBuilder |
setKeyStoreProvider(Provider provider)
Sets the JCA provider to use for creating key stores.
|
SSLContextBuilder |
setKeyStoreProvider(String name)
Sets the JCA provider name to use for creating key stores.
|
SSLContextBuilder |
setKeyStoreType(String keyStoreType)
Sets the key store type.
|
SSLContextBuilder |
setProtocol(String protocol)
Sets the SSLContext algorithm name.
|
SSLContextBuilder |
setProvider(Provider provider) |
SSLContextBuilder |
setProvider(String name) |
SSLContextBuilder |
setSecureRandom(SecureRandom secureRandom) |
SSLContextBuilder |
setTrustManagerFactoryAlgorithm(String trustManagerFactoryAlgorithm)
Sets the trust manager factory algorithm name.
|
SSLContextBuilder |
setTrustStoreProvider(Provider provider)
Sets the JCA provider to use for creating trust stores.
|
SSLContextBuilder |
setTrustStoreProvider(String name)
Sets the JCA provider name to use for creating trust stores.
|
String |
toString() |
public static SSLContextBuilder create()
public SSLContextBuilder setProtocol(String protocol)
protocol
- the SSLContext algorithm name of the requested protocol. See
the SSLContext section in the Java
Cryptography Architecture Standard Algorithm Name
Documentation for more information.public SSLContextBuilder setProvider(Provider provider)
public SSLContextBuilder setProvider(String name)
public SSLContextBuilder setTrustStoreProvider(Provider provider)
provider
- provider to use for creating trust stores.public SSLContextBuilder setTrustStoreProvider(String name) throws NoSuchProviderException
name
- Name of the provider to use for creating trust stores, the provider must be registered with the JCA.NoSuchProviderException
- if no provider with the specified name is installed or if name is null.public SSLContextBuilder setKeyStoreProvider(Provider provider)
provider
- provider to use for creating key stores.public SSLContextBuilder setKeyStoreProvider(String name) throws NoSuchProviderException
name
- Name of the provider to use for creating key stores, the provider must be registered with the JCA.NoSuchProviderException
- if no provider with the specified name is installed or if name is null.public SSLContextBuilder setKeyStoreType(String keyStoreType)
keyStoreType
- the SSLkey store type. See
the KeyStore section in the Java
Cryptography Architecture Standard Algorithm Name
Documentation for more information.public SSLContextBuilder setKeyManagerFactoryAlgorithm(String keyManagerFactoryAlgorithm)
keyManagerFactoryAlgorithm
- the key manager factory algorithm name of the requested protocol. See
the KeyManagerFactory section in the Java
Cryptography Architecture Standard Algorithm Name
Documentation for more information.public SSLContextBuilder setTrustManagerFactoryAlgorithm(String trustManagerFactoryAlgorithm)
trustManagerFactoryAlgorithm
- the trust manager algorithm name of the requested protocol. See
the TrustManagerFactory section in the Java
Cryptography Architecture Standard Algorithm Name
Documentation for more information.public SSLContextBuilder setSecureRandom(SecureRandom secureRandom)
public SSLContextBuilder loadTrustMaterial(KeyStore trustStore, TrustStrategy trustStrategy) throws NoSuchAlgorithmException, KeyStoreException
trustStrategy
- custom trust strategy to use; can be null
in which case
only the default trust managers will be usedNoSuchAlgorithmException
- if no Provider supports a KeyManagerFactorySpi implementation for the specified algorithm.KeyStoreException
- if a TrustManagerFactory operation fails.public SSLContextBuilder loadTrustMaterial(Path file) throws NoSuchAlgorithmException, KeyStoreException, CertificateException, IOException
NoSuchAlgorithmException
- if no Provider supports a KeyManagerFactorySpi implementation for the specified algorithm.KeyStoreException
- if no Provider supports a KeyStoreSpi implementation for the specified type.CertificateException
- if any of the certificates in the keystore could not be loaded.IOException
- if an I/O exception occurs.public SSLContextBuilder loadTrustMaterial(Path file, char[] storePassword) throws NoSuchAlgorithmException, KeyStoreException, CertificateException, IOException
NoSuchAlgorithmException
- if no Provider supports a KeyManagerFactorySpi implementation for the specified algorithm.KeyStoreException
- if no Provider supports a KeyStoreSpi implementation for the specified type.CertificateException
- if any of the certificates in the keystore could not be loaded.IOException
- if an I/O exception occurs.public SSLContextBuilder loadTrustMaterial(Path file, char[] storePassword, TrustStrategy trustStrategy, OpenOption... openOptions) throws NoSuchAlgorithmException, KeyStoreException, CertificateException, IOException
NoSuchAlgorithmException
- if no Provider supports a KeyManagerFactorySpi implementation for the specified algorithm.KeyStoreException
- if no Provider supports a KeyStoreSpi implementation for the specified type.CertificateException
- if any of the certificates in the keystore could not be loaded.IOException
- if an I/O exception occurs.public SSLContextBuilder loadTrustMaterial(TrustStrategy trustStrategy) throws NoSuchAlgorithmException, KeyStoreException
public SSLContextBuilder loadTrustMaterial(File file, char[] storePassword, TrustStrategy trustStrategy) throws NoSuchAlgorithmException, KeyStoreException, CertificateException, IOException
public SSLContextBuilder loadTrustMaterial(File file, char[] storePassword) throws NoSuchAlgorithmException, KeyStoreException, CertificateException, IOException
public SSLContextBuilder loadTrustMaterial(File file) throws NoSuchAlgorithmException, KeyStoreException, CertificateException, IOException
public SSLContextBuilder loadTrustMaterial(URL url, char[] storePassword, TrustStrategy trustStrategy) throws NoSuchAlgorithmException, KeyStoreException, CertificateException, IOException
public SSLContextBuilder loadTrustMaterial(URL url, char[] storePassword) throws NoSuchAlgorithmException, KeyStoreException, CertificateException, IOException
public SSLContextBuilder loadKeyMaterial(KeyStore keyStore, char[] keyPassword, PrivateKeyStrategy aliasStrategy) throws NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException
public SSLContextBuilder loadKeyMaterial(Path file, char[] storePassword, char[] keyPassword, OpenOption... openOptions) throws NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException, CertificateException, IOException
NoSuchAlgorithmException
- if no Provider supports a KeyManagerFactorySpi implementation for the specified algorithm.KeyStoreException
- if no Provider supports a KeyStoreSpi implementation for the specified type.CertificateException
- if any of the certificates in the keystore could not be loaded.IOException
- if an I/O exception occurs.UnrecoverableKeyException
- if the key cannot be recovered (for example, the given password is wrong).public SSLContextBuilder loadKeyMaterial(Path file, char[] storePassword, char[] keyPassword, PrivateKeyStrategy aliasStrategy, OpenOption... openOptions) throws NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException, CertificateException, IOException
NoSuchAlgorithmException
- if no Provider supports a KeyManagerFactorySpi implementation for the specified algorithm.KeyStoreException
- if no Provider supports a KeyStoreSpi implementation for the specified type.CertificateException
- if any of the certificates in the keystore could not be loaded.IOException
- if an I/O exception occurs.UnrecoverableKeyException
- if the key cannot be recovered (for example, the given password is wrong).public SSLContextBuilder loadKeyMaterial(KeyStore keyStore, char[] keyPassword) throws NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException
public SSLContextBuilder loadKeyMaterial(File file, char[] storePassword, char[] keyPassword, PrivateKeyStrategy aliasStrategy) throws NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException, CertificateException, IOException
public SSLContextBuilder loadKeyMaterial(File file, char[] storePassword, char[] keyPassword) throws NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException, CertificateException, IOException
public SSLContextBuilder loadKeyMaterial(URL url, char[] storePassword, char[] keyPassword, PrivateKeyStrategy aliasStrategy) throws NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException, CertificateException, IOException
public SSLContextBuilder loadKeyMaterial(URL url, char[] storePassword, char[] keyPassword) throws NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException, CertificateException, IOException
protected void initSSLContext(SSLContext sslContext, Collection<KeyManager> keyManagers, Collection<TrustManager> trustManagers, SecureRandom secureRandom) throws KeyManagementException
KeyManagementException
- if this SSLContext operation fails.public SSLContext build() throws NoSuchAlgorithmException, KeyManagementException
NoSuchAlgorithmException
- if no Provider supports a KeyManagerFactorySpi implementation for the specified algorithm.KeyManagementException
- if this SSLContext operation fails.Copyright © 2005–2021 The Apache Software Foundation. All rights reserved.