Package org.apache.http.ssl
Class SSLContextBuilder
- java.lang.Object
-
- org.apache.http.ssl.SSLContextBuilder
-
public class SSLContextBuilder extends java.lang.ObjectBuilder forSSLContextinstances.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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classSSLContextBuilder.KeyManagerDelegate(package private) static classSSLContextBuilder.TrustManagerDelegate
-
Field Summary
Fields Modifier and Type Field Description private java.lang.StringkeyManagerFactoryAlgorithmprivate java.util.Set<javax.net.ssl.KeyManager>keyManagersprivate java.lang.StringkeyStoreTypeprivate java.lang.Stringprotocolprivate java.security.Providerproviderprivate java.security.SecureRandomsecureRandom(package private) static java.lang.StringTLSprivate java.lang.StringtrustManagerFactoryAlgorithmprivate java.util.Set<javax.net.ssl.TrustManager>trustManagers
-
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.SSLContextbuild()static SSLContextBuildercreate()protected voidinitSSLContext(javax.net.ssl.SSLContext sslContext, java.util.Collection<javax.net.ssl.KeyManager> keyManagers, java.util.Collection<javax.net.ssl.TrustManager> trustManagers, java.security.SecureRandom secureRandom)SSLContextBuilderloadKeyMaterial(java.io.File file, char[] storePassword, char[] keyPassword)SSLContextBuilderloadKeyMaterial(java.io.File file, char[] storePassword, char[] keyPassword, PrivateKeyStrategy aliasStrategy)SSLContextBuilderloadKeyMaterial(java.net.URL url, char[] storePassword, char[] keyPassword)SSLContextBuilderloadKeyMaterial(java.net.URL url, char[] storePassword, char[] keyPassword, PrivateKeyStrategy aliasStrategy)SSLContextBuilderloadKeyMaterial(java.security.KeyStore keystore, char[] keyPassword)SSLContextBuilderloadKeyMaterial(java.security.KeyStore keystore, char[] keyPassword, PrivateKeyStrategy aliasStrategy)SSLContextBuilderloadTrustMaterial(java.io.File file)SSLContextBuilderloadTrustMaterial(java.io.File file, char[] storePassword)SSLContextBuilderloadTrustMaterial(java.io.File file, char[] storePassword, TrustStrategy trustStrategy)SSLContextBuilderloadTrustMaterial(java.net.URL url, char[] storePassword)SSLContextBuilderloadTrustMaterial(java.net.URL url, char[] storePassword, TrustStrategy trustStrategy)SSLContextBuilderloadTrustMaterial(java.security.KeyStore truststore, TrustStrategy trustStrategy)SSLContextBuilderloadTrustMaterial(TrustStrategy trustStrategy)SSLContextBuildersetKeyManagerFactoryAlgorithm(java.lang.String keyManagerFactoryAlgorithm)Sets the key manager factory algorithm name.SSLContextBuildersetKeyStoreType(java.lang.String keyStoreType)Sets the key store type.SSLContextBuildersetProtocol(java.lang.String protocol)Sets the SSLContext protocol algorithm name.SSLContextBuildersetProvider(java.lang.String name)SSLContextBuildersetProvider(java.security.Provider provider)SSLContextBuildersetSecureRandom(java.security.SecureRandom secureRandom)SSLContextBuildersetTrustManagerFactoryAlgorithm(java.lang.String trustManagerFactoryAlgorithm)Sets the trust manager factory algorithm name.java.lang.StringtoString()SSLContextBuilderuseProtocol(java.lang.String protocol)Deprecated.UsesetProtocol(String).
-
-
-
Field Detail
-
TLS
static final java.lang.String TLS
- See Also:
- Constant Field Values
-
protocol
private java.lang.String protocol
-
keyManagers
private final java.util.Set<javax.net.ssl.KeyManager> keyManagers
-
keyManagerFactoryAlgorithm
private java.lang.String keyManagerFactoryAlgorithm
-
keyStoreType
private java.lang.String keyStoreType
-
trustManagers
private final java.util.Set<javax.net.ssl.TrustManager> trustManagers
-
trustManagerFactoryAlgorithm
private java.lang.String trustManagerFactoryAlgorithm
-
secureRandom
private java.security.SecureRandom secureRandom
-
provider
private java.security.Provider provider
-
-
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.NoSuchAlgorithmExceptionjava.security.KeyStoreException
-
loadTrustMaterial
public SSLContextBuilder loadTrustMaterial(TrustStrategy trustStrategy) throws java.security.NoSuchAlgorithmException, java.security.KeyStoreException
- Throws:
java.security.NoSuchAlgorithmExceptionjava.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.NoSuchAlgorithmExceptionjava.security.KeyStoreExceptionjava.security.cert.CertificateExceptionjava.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.NoSuchAlgorithmExceptionjava.security.KeyStoreExceptionjava.security.cert.CertificateExceptionjava.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.NoSuchAlgorithmExceptionjava.security.KeyStoreExceptionjava.security.cert.CertificateExceptionjava.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.NoSuchAlgorithmExceptionjava.security.KeyStoreExceptionjava.security.cert.CertificateExceptionjava.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.NoSuchAlgorithmExceptionjava.security.KeyStoreExceptionjava.security.cert.CertificateExceptionjava.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.NoSuchAlgorithmExceptionjava.security.KeyStoreExceptionjava.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.NoSuchAlgorithmExceptionjava.security.KeyStoreExceptionjava.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.NoSuchAlgorithmExceptionjava.security.KeyStoreExceptionjava.security.UnrecoverableKeyExceptionjava.security.cert.CertificateExceptionjava.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.NoSuchAlgorithmExceptionjava.security.KeyStoreExceptionjava.security.UnrecoverableKeyExceptionjava.security.cert.CertificateExceptionjava.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.NoSuchAlgorithmExceptionjava.security.KeyStoreExceptionjava.security.UnrecoverableKeyExceptionjava.security.cert.CertificateExceptionjava.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.NoSuchAlgorithmExceptionjava.security.KeyStoreExceptionjava.security.UnrecoverableKeyExceptionjava.security.cert.CertificateExceptionjava.io.IOException
-
initSSLContext
protected void initSSLContext(javax.net.ssl.SSLContext sslContext, java.util.Collection<javax.net.ssl.KeyManager> keyManagers, java.util.Collection<javax.net.ssl.TrustManager> trustManagers, java.security.SecureRandom secureRandom) throws java.security.KeyManagementException- Throws:
java.security.KeyManagementException
-
build
public javax.net.ssl.SSLContext build() throws java.security.NoSuchAlgorithmException, java.security.KeyManagementException- Throws:
java.security.NoSuchAlgorithmExceptionjava.security.KeyManagementException
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-