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
-
-
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()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).
-
-
-
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
-
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
-
-