Package org.apache.http.ssl
Class SSLContextBuilder
- java.lang.Object
-
- org.apache.http.ssl.SSLContextBuilder
-
public class SSLContextBuilder extends java.lang.Object
Builder forSSLContext
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#initTODO Specify which Oracle JSSE versions the above has been verified.
- Since:
- 4.4
-
-
Constructor Summary
Constructors Constructor Description SSLContextBuilder()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description javax.net.ssl.SSLContext
build()
static SSLContextBuilder
create()
SSLContextBuilder
loadKeyMaterial(java.io.File file, char[] storePassword, char[] keyPassword)
SSLContextBuilder
loadKeyMaterial(java.io.File file, char[] storePassword, char[] keyPassword, PrivateKeyStrategy aliasStrategy)
SSLContextBuilder
loadKeyMaterial(java.net.URL url, char[] storePassword, char[] keyPassword)
SSLContextBuilder
loadKeyMaterial(java.net.URL url, char[] storePassword, char[] keyPassword, PrivateKeyStrategy aliasStrategy)
SSLContextBuilder
loadKeyMaterial(java.security.KeyStore keystore, char[] keyPassword)
SSLContextBuilder
loadKeyMaterial(java.security.KeyStore keystore, char[] keyPassword, PrivateKeyStrategy aliasStrategy)
SSLContextBuilder
loadTrustMaterial(java.io.File file)
SSLContextBuilder
loadTrustMaterial(java.io.File file, char[] storePassword)
SSLContextBuilder
loadTrustMaterial(java.io.File file, char[] storePassword, TrustStrategy trustStrategy)
SSLContextBuilder
loadTrustMaterial(java.net.URL url, char[] storePassword)
SSLContextBuilder
loadTrustMaterial(java.net.URL url, char[] storePassword, TrustStrategy trustStrategy)
SSLContextBuilder
loadTrustMaterial(java.security.KeyStore truststore, TrustStrategy trustStrategy)
SSLContextBuilder
loadTrustMaterial(TrustStrategy trustStrategy)
SSLContextBuilder
setKeyManagerFactoryAlgorithm(java.lang.String keyManagerFactoryAlgorithm)
Sets the key manager factory algorithm name.SSLContextBuilder
setKeyStoreType(java.lang.String keyStoreType)
Sets the key store type.SSLContextBuilder
setProtocol(java.lang.String protocol)
Sets the SSLContext protocol algorithm name.SSLContextBuilder
setProvider(java.lang.String name)
SSLContextBuilder
setProvider(java.security.Provider provider)
SSLContextBuilder
setSecureRandom(java.security.SecureRandom secureRandom)
SSLContextBuilder
setTrustManagerFactoryAlgorithm(java.lang.String trustManagerFactoryAlgorithm)
Sets the trust manager factory algorithm name.java.lang.String
toString()
SSLContextBuilder
useProtocol(java.lang.String protocol)
Deprecated.UsesetProtocol(String)
.
-
-
-
Method Detail
-
create
public static SSLContextBuilder create()
-
useProtocol
@Deprecated public SSLContextBuilder useProtocol(java.lang.String protocol)
Deprecated.UsesetProtocol(String)
.Sets the SSLContext protocol algorithm name.- Parameters:
protocol
- the SSLContext protocol algorithm name of the requested protocol. See the SSLContext section in the Java Cryptography Architecture Standard Algorithm Name Documentation for more information.- Returns:
- this builder
- See Also:
- Java Cryptography Architecture Standard Algorithm Name Documentation
-
setProtocol
public SSLContextBuilder setProtocol(java.lang.String protocol)
Sets the SSLContext protocol algorithm name.- Parameters:
protocol
- the SSLContext protocol algorithm name of the requested protocol. See the SSLContext section in the Java Cryptography Architecture Standard Algorithm Name Documentation for more information.- Returns:
- this builder
- Since:
- 4.4.7
- See Also:
- Java Cryptography Architecture Standard Algorithm Name Documentation
-
setSecureRandom
public SSLContextBuilder setSecureRandom(java.security.SecureRandom secureRandom)
-
setProvider
public SSLContextBuilder setProvider(java.security.Provider provider)
-
setProvider
public SSLContextBuilder setProvider(java.lang.String name)
-
setKeyStoreType
public SSLContextBuilder setKeyStoreType(java.lang.String keyStoreType)
Sets the key store type.- Parameters:
keyStoreType
- the SSLkey store type. See the KeyStore section in the Java Cryptography Architecture Standard Algorithm Name Documentation for more information.- Returns:
- this builder
- Since:
- 4.4.7
- See Also:
- Java Cryptography Architecture Standard Algorithm Name Documentation
-
setKeyManagerFactoryAlgorithm
public SSLContextBuilder setKeyManagerFactoryAlgorithm(java.lang.String keyManagerFactoryAlgorithm)
Sets the key manager factory algorithm name.- Parameters:
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.- Returns:
- this builder
- Since:
- 4.4.7
- See Also:
- Java Cryptography Architecture Standard Algorithm Name Documentation
-
setTrustManagerFactoryAlgorithm
public SSLContextBuilder setTrustManagerFactoryAlgorithm(java.lang.String trustManagerFactoryAlgorithm)
Sets the trust manager factory algorithm name.- Parameters:
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.- Returns:
- this builder
- Since:
- 4.4.7
- See Also:
- Java Cryptography Architecture Standard Algorithm Name Documentation
-
loadTrustMaterial
public SSLContextBuilder loadTrustMaterial(java.security.KeyStore truststore, TrustStrategy trustStrategy) throws java.security.NoSuchAlgorithmException, java.security.KeyStoreException
- Throws:
java.security.NoSuchAlgorithmException
java.security.KeyStoreException
-
loadTrustMaterial
public SSLContextBuilder loadTrustMaterial(TrustStrategy trustStrategy) throws java.security.NoSuchAlgorithmException, java.security.KeyStoreException
- Throws:
java.security.NoSuchAlgorithmException
java.security.KeyStoreException
-
loadTrustMaterial
public SSLContextBuilder loadTrustMaterial(java.io.File file, char[] storePassword, TrustStrategy trustStrategy) throws java.security.NoSuchAlgorithmException, java.security.KeyStoreException, java.security.cert.CertificateException, java.io.IOException
- Throws:
java.security.NoSuchAlgorithmException
java.security.KeyStoreException
java.security.cert.CertificateException
java.io.IOException
-
loadTrustMaterial
public SSLContextBuilder loadTrustMaterial(java.io.File file, char[] storePassword) throws java.security.NoSuchAlgorithmException, java.security.KeyStoreException, java.security.cert.CertificateException, java.io.IOException
- Throws:
java.security.NoSuchAlgorithmException
java.security.KeyStoreException
java.security.cert.CertificateException
java.io.IOException
-
loadTrustMaterial
public SSLContextBuilder loadTrustMaterial(java.io.File file) throws java.security.NoSuchAlgorithmException, java.security.KeyStoreException, java.security.cert.CertificateException, java.io.IOException
- Throws:
java.security.NoSuchAlgorithmException
java.security.KeyStoreException
java.security.cert.CertificateException
java.io.IOException
-
loadTrustMaterial
public SSLContextBuilder loadTrustMaterial(java.net.URL url, char[] storePassword, TrustStrategy trustStrategy) throws java.security.NoSuchAlgorithmException, java.security.KeyStoreException, java.security.cert.CertificateException, java.io.IOException
- Throws:
java.security.NoSuchAlgorithmException
java.security.KeyStoreException
java.security.cert.CertificateException
java.io.IOException
-
loadTrustMaterial
public SSLContextBuilder loadTrustMaterial(java.net.URL url, char[] storePassword) throws java.security.NoSuchAlgorithmException, java.security.KeyStoreException, java.security.cert.CertificateException, java.io.IOException
- Throws:
java.security.NoSuchAlgorithmException
java.security.KeyStoreException
java.security.cert.CertificateException
java.io.IOException
-
loadKeyMaterial
public SSLContextBuilder loadKeyMaterial(java.security.KeyStore keystore, char[] keyPassword, PrivateKeyStrategy aliasStrategy) throws java.security.NoSuchAlgorithmException, java.security.KeyStoreException, java.security.UnrecoverableKeyException
- Throws:
java.security.NoSuchAlgorithmException
java.security.KeyStoreException
java.security.UnrecoverableKeyException
-
loadKeyMaterial
public SSLContextBuilder loadKeyMaterial(java.security.KeyStore keystore, char[] keyPassword) throws java.security.NoSuchAlgorithmException, java.security.KeyStoreException, java.security.UnrecoverableKeyException
- Throws:
java.security.NoSuchAlgorithmException
java.security.KeyStoreException
java.security.UnrecoverableKeyException
-
loadKeyMaterial
public SSLContextBuilder loadKeyMaterial(java.io.File file, char[] storePassword, char[] keyPassword, PrivateKeyStrategy aliasStrategy) throws java.security.NoSuchAlgorithmException, java.security.KeyStoreException, java.security.UnrecoverableKeyException, java.security.cert.CertificateException, java.io.IOException
- Throws:
java.security.NoSuchAlgorithmException
java.security.KeyStoreException
java.security.UnrecoverableKeyException
java.security.cert.CertificateException
java.io.IOException
-
loadKeyMaterial
public SSLContextBuilder loadKeyMaterial(java.io.File file, char[] storePassword, char[] keyPassword) throws java.security.NoSuchAlgorithmException, java.security.KeyStoreException, java.security.UnrecoverableKeyException, java.security.cert.CertificateException, java.io.IOException
- Throws:
java.security.NoSuchAlgorithmException
java.security.KeyStoreException
java.security.UnrecoverableKeyException
java.security.cert.CertificateException
java.io.IOException
-
loadKeyMaterial
public SSLContextBuilder loadKeyMaterial(java.net.URL url, char[] storePassword, char[] keyPassword, PrivateKeyStrategy aliasStrategy) throws java.security.NoSuchAlgorithmException, java.security.KeyStoreException, java.security.UnrecoverableKeyException, java.security.cert.CertificateException, java.io.IOException
- Throws:
java.security.NoSuchAlgorithmException
java.security.KeyStoreException
java.security.UnrecoverableKeyException
java.security.cert.CertificateException
java.io.IOException
-
loadKeyMaterial
public SSLContextBuilder loadKeyMaterial(java.net.URL url, char[] storePassword, char[] keyPassword) throws java.security.NoSuchAlgorithmException, java.security.KeyStoreException, java.security.UnrecoverableKeyException, java.security.cert.CertificateException, java.io.IOException
- Throws:
java.security.NoSuchAlgorithmException
java.security.KeyStoreException
java.security.UnrecoverableKeyException
java.security.cert.CertificateException
java.io.IOException
-
build
public javax.net.ssl.SSLContext build() throws java.security.NoSuchAlgorithmException, java.security.KeyManagementException
- Throws:
java.security.NoSuchAlgorithmException
java.security.KeyManagementException
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-