public class SslContextFactory extends Object
The following snippet shows how to create a SSL context for a client:
X509Certificate certificate = CertificatesHelper.getCertificate(CERTIFICATE_PATH); X509TrustManager trustManager = SslContextFactory.createTrustManager(certificate); SSLContext sslContext = SslContextFactory.createSslContext(SslProtocols.TLS, trustManager);
Modifier and Type | Method and Description |
---|---|
static X509KeyManager |
createKeyManager(byte[] key,
char[] keyPassword,
X509Certificate... certificateChain)
Creates a key manager that stores the given key and its associated certificate chain.
|
static SSLContext |
createSslContext(String protocol,
TrustManager trustManager,
KeyManager... keyManagers)
Creates a SSL context.
|
static X509TrustManager |
createTrustManager(X509Certificate... certificates)
Creates a trust manager that stores the given certificates.
|
public static X509KeyManager createKeyManager(byte[] key, char[] keyPassword, X509Certificate... certificateChain)
key
- the key.keyPassword
- the password to decrypt the key.certificateChain
- the certificate chain.public static SSLContext createSslContext(String protocol, TrustManager trustManager, KeyManager... keyManagers)
The createTrustManager(java.security.cert.X509Certificate...)
and createKeyManager(byte[], char[], java.security.cert.X509Certificate...)
methods can be used to create the trust manager and
the key managers easily.
protocol
- the protocol (see SslProtocols
).trustManager
- the trust manager.keyManagers
- the key managers.public static X509TrustManager createTrustManager(X509Certificate... certificates)
certificates
- the trusted certificates.