public abstract class SslContext extends Object
SSLEngine and SslHandler.
Internally, it is implemented via JDK's SSLContext or OpenSSL's SSL_CTX.
// In yourChannelInitializer:ChannelPipelinep = channel.pipeline();SslContextsslCtx =SslContext.newServerContext(...); p.addLast("ssl",sslCtx.newEngine(channel.alloc())); ...
// In yourChannelInitializer:ChannelPipelinep = channel.pipeline();SslContextsslCtx =SslContext.newClientContext(...); p.addLast("ssl",sslCtx.newEngine(channel.alloc(), host, port)); ...
| Modifier and Type | Method and Description |
|---|---|
abstract ApplicationProtocolNegotiator |
applicationProtocolNegotiator()
Returns the object responsible for negotiating application layer protocols for the TLS NPN/ALPN extensions.
|
abstract List<String> |
cipherSuites()
Returns the list of enabled cipher suites, in the order of preference.
|
static SslProvider |
defaultClientProvider()
Returns the default client-side implementation provider currently in use.
|
static SslProvider |
defaultServerProvider()
Returns the default server-side implementation provider currently in use.
|
protected static PKCS8EncodedKeySpec |
generateKeySpec(char[] password,
byte[] key)
Generates a key specification for an (encrypted) private key.
|
abstract boolean |
isClient()
Returns the
true if and only if this context is for client-side. |
boolean |
isServer()
Returns
true if and only if this context is for server-side. |
static SslContext |
newClientContext()
Creates a new client-side
SslContext. |
static SslContext |
newClientContext(File certChainFile)
Creates a new client-side
SslContext. |
static SslContext |
newClientContext(File certChainFile,
TrustManagerFactory trustManagerFactory)
Creates a new client-side
SslContext. |
static SslContext |
newClientContext(File certChainFile,
TrustManagerFactory trustManagerFactory,
Iterable<String> ciphers,
CipherSuiteFilter cipherFilter,
ApplicationProtocolConfig apn,
long sessionCacheSize,
long sessionTimeout)
Creates a new client-side
SslContext. |
static SslContext |
newClientContext(SslProvider provider)
Creates a new client-side
SslContext. |
static SslContext |
newClientContext(SslProvider provider,
File certChainFile)
Creates a new client-side
SslContext. |
static SslContext |
newClientContext(SslProvider provider,
File certChainFile,
TrustManagerFactory trustManagerFactory)
Creates a new client-side
SslContext. |
static SslContext |
newClientContext(SslProvider provider,
File trustCertChainFile,
TrustManagerFactory trustManagerFactory,
File keyCertChainFile,
File keyFile,
String keyPassword,
KeyManagerFactory keyManagerFactory,
Iterable<String> ciphers,
CipherSuiteFilter cipherFilter,
ApplicationProtocolConfig apn,
long sessionCacheSize,
long sessionTimeout)
Creates a new client-side
SslContext. |
static SslContext |
newClientContext(SslProvider provider,
File certChainFile,
TrustManagerFactory trustManagerFactory,
Iterable<String> ciphers,
CipherSuiteFilter cipherFilter,
ApplicationProtocolConfig apn,
long sessionCacheSize,
long sessionTimeout)
Creates a new client-side
SslContext. |
static SslContext |
newClientContext(SslProvider provider,
TrustManagerFactory trustManagerFactory)
Creates a new client-side
SslContext. |
static SslContext |
newClientContext(TrustManagerFactory trustManagerFactory)
Creates a new client-side
SslContext. |
abstract SSLEngine |
newEngine(ByteBufAllocator alloc)
Creates a new
SSLEngine. |
abstract SSLEngine |
newEngine(ByteBufAllocator alloc,
String peerHost,
int peerPort)
Creates a new
SSLEngine using advisory peer information. |
SslHandler |
newHandler(ByteBufAllocator alloc)
Creates a new
SslHandler. |
SslHandler |
newHandler(ByteBufAllocator alloc,
String peerHost,
int peerPort)
Creates a new
SslHandler with advisory peer information. |
static SslContext |
newServerContext(File certChainFile,
File keyFile)
Creates a new server-side
SslContext. |
static SslContext |
newServerContext(File certChainFile,
File keyFile,
String keyPassword)
Creates a new server-side
SslContext. |
static SslContext |
newServerContext(File certChainFile,
File keyFile,
String keyPassword,
Iterable<String> ciphers,
CipherSuiteFilter cipherFilter,
ApplicationProtocolConfig apn,
long sessionCacheSize,
long sessionTimeout)
Creates a new server-side
SslContext. |
static SslContext |
newServerContext(SslProvider provider,
File certChainFile,
File keyFile)
Creates a new server-side
SslContext. |
static SslContext |
newServerContext(SslProvider provider,
File certChainFile,
File keyFile,
String keyPassword)
Creates a new server-side
SslContext. |
static SslContext |
newServerContext(SslProvider provider,
File certChainFile,
File keyFile,
String keyPassword,
Iterable<String> ciphers,
CipherSuiteFilter cipherFilter,
ApplicationProtocolConfig apn,
long sessionCacheSize,
long sessionTimeout)
Creates a new server-side
SslContext. |
static SslContext |
newServerContext(SslProvider provider,
File trustCertChainFile,
TrustManagerFactory trustManagerFactory,
File keyCertChainFile,
File keyFile,
String keyPassword,
KeyManagerFactory keyManagerFactory,
Iterable<String> ciphers,
CipherSuiteFilter cipherFilter,
ApplicationProtocolConfig apn,
long sessionCacheSize,
long sessionTimeout)
Creates a new server-side
SslContext. |
abstract long |
sessionCacheSize()
Returns the size of the cache used for storing SSL session objects.
|
abstract SSLSessionContext |
sessionContext()
Returns the
SSLSessionContext object held by this context. |
abstract long |
sessionTimeout()
Returns the timeout for the cached SSL session objects, in seconds.
|
public static SslProvider defaultServerProvider()
SslProvider.OPENSSL if OpenSSL is available. SslProvider.JDK otherwise.public static SslProvider defaultClientProvider()
SslProvider.OPENSSL if OpenSSL is available. SslProvider.JDK otherwise.public static SslContext newServerContext(File certChainFile, File keyFile) throws SSLException
SslContext.certChainFile - an X.509 certificate chain file in PEM formatkeyFile - a PKCS#8 private key file in PEM formatSslContextSSLExceptionpublic static SslContext newServerContext(File certChainFile, File keyFile, String keyPassword) throws SSLException
SslContext.certChainFile - an X.509 certificate chain file in PEM formatkeyFile - a PKCS#8 private key file in PEM formatkeyPassword - the password of the keyFile.
null if it's not password-protected.SslContextSSLExceptionpublic static SslContext newServerContext(File certChainFile, File keyFile, String keyPassword, Iterable<String> ciphers, CipherSuiteFilter cipherFilter, ApplicationProtocolConfig apn, long sessionCacheSize, long sessionTimeout) throws SSLException
SslContext.certChainFile - an X.509 certificate chain file in PEM formatkeyFile - a PKCS#8 private key file in PEM formatkeyPassword - the password of the keyFile.
null if it's not password-protected.ciphers - the cipher suites to enable, in the order of preference.
null to use the default cipher suites.cipherFilter - a filter to apply over the supplied list of ciphersapn - Provides a means to configure parameters related to application protocol negotiation.sessionCacheSize - the size of the cache used for storing SSL session objects.
0 to use the default value.sessionTimeout - the timeout for the cached SSL session objects, in seconds.
0 to use the default value.SslContextSSLExceptionpublic static SslContext newServerContext(SslProvider provider, File certChainFile, File keyFile) throws SSLException
SslContext.provider - the SslContext implementation to use.
null to use the current default one.certChainFile - an X.509 certificate chain file in PEM formatkeyFile - a PKCS#8 private key file in PEM formatSslContextSSLExceptionpublic static SslContext newServerContext(SslProvider provider, File certChainFile, File keyFile, String keyPassword) throws SSLException
SslContext.provider - the SslContext implementation to use.
null to use the current default one.certChainFile - an X.509 certificate chain file in PEM formatkeyFile - a PKCS#8 private key file in PEM formatkeyPassword - the password of the keyFile.
null if it's not password-protected.SslContextSSLExceptionpublic static SslContext newServerContext(SslProvider provider, File certChainFile, File keyFile, String keyPassword, Iterable<String> ciphers, CipherSuiteFilter cipherFilter, ApplicationProtocolConfig apn, long sessionCacheSize, long sessionTimeout) throws SSLException
SslContext.provider - the SslContext implementation to use.
null to use the current default one.certChainFile - an X.509 certificate chain file in PEM formatkeyFile - a PKCS#8 private key file in PEM formatkeyPassword - the password of the keyFile.
null if it's not password-protected.ciphers - the cipher suites to enable, in the order of preference.
null to use the default cipher suites.cipherFilter - a filter to apply over the supplied list of ciphers
Only required if provider is SslProvider.JDKapn - Provides a means to configure parameters related to application protocol negotiation.sessionCacheSize - the size of the cache used for storing SSL session objects.
0 to use the default value.sessionTimeout - the timeout for the cached SSL session objects, in seconds.
0 to use the default value.SslContextSSLExceptionpublic static SslContext newServerContext(SslProvider provider, File trustCertChainFile, TrustManagerFactory trustManagerFactory, File keyCertChainFile, File keyFile, String keyPassword, KeyManagerFactory keyManagerFactory, Iterable<String> ciphers, CipherSuiteFilter cipherFilter, ApplicationProtocolConfig apn, long sessionCacheSize, long sessionTimeout) throws SSLException
SslContext.provider - the SslContext implementation to use.
null to use the current default one.trustCertChainFile - an X.509 certificate chain file in PEM format.
This provides the certificate chains used for mutual authentication.
null to use the system defaulttrustManagerFactory - the TrustManagerFactory that provides the TrustManagers
that verifies the certificates sent from clients.
null to use the default or the results of parsing trustCertChainFile.
This parameter is ignored if provider is not SslProvider.JDK.keyCertChainFile - an X.509 certificate chain file in PEM formatkeyFile - a PKCS#8 private key file in PEM formatkeyPassword - the password of the keyFile.
null if it's not password-protected.keyManagerFactory - the KeyManagerFactory that provides the KeyManagers
that is used to encrypt data being sent to clients.
null to use the default or the results of parsing
keyCertChainFile and keyFile.
This parameter is ignored if provider is not SslProvider.JDK.ciphers - the cipher suites to enable, in the order of preference.
null to use the default cipher suites.cipherFilter - a filter to apply over the supplied list of ciphers
Only required if provider is SslProvider.JDKapn - Provides a means to configure parameters related to application protocol negotiation.sessionCacheSize - the size of the cache used for storing SSL session objects.
0 to use the default value.sessionTimeout - the timeout for the cached SSL session objects, in seconds.
0 to use the default value.SslContextSSLExceptionpublic static SslContext newClientContext() throws SSLException
SslContext.SslContextSSLExceptionpublic static SslContext newClientContext(File certChainFile) throws SSLException
SslContext.certChainFile - an X.509 certificate chain file in PEM formatSslContextSSLExceptionpublic static SslContext newClientContext(TrustManagerFactory trustManagerFactory) throws SSLException
SslContext.trustManagerFactory - the TrustManagerFactory that provides the TrustManagers
that verifies the certificates sent from servers.
null to use the default.SslContextSSLExceptionpublic static SslContext newClientContext(File certChainFile, TrustManagerFactory trustManagerFactory) throws SSLException
SslContext.certChainFile - an X.509 certificate chain file in PEM format.
null to use the system defaulttrustManagerFactory - the TrustManagerFactory that provides the TrustManagers
that verifies the certificates sent from servers.
null to use the default.SslContextSSLExceptionpublic static SslContext newClientContext(File certChainFile, TrustManagerFactory trustManagerFactory, Iterable<String> ciphers, CipherSuiteFilter cipherFilter, ApplicationProtocolConfig apn, long sessionCacheSize, long sessionTimeout) throws SSLException
SslContext.certChainFile - an X.509 certificate chain file in PEM format.
null to use the system defaulttrustManagerFactory - the TrustManagerFactory that provides the TrustManagers
that verifies the certificates sent from servers.
null to use the default.ciphers - the cipher suites to enable, in the order of preference.
null to use the default cipher suites.cipherFilter - a filter to apply over the supplied list of ciphersapn - Provides a means to configure parameters related to application protocol negotiation.sessionCacheSize - the size of the cache used for storing SSL session objects.
0 to use the default value.sessionTimeout - the timeout for the cached SSL session objects, in seconds.
0 to use the default value.SslContextSSLExceptionpublic static SslContext newClientContext(SslProvider provider) throws SSLException
SslContext.provider - the SslContext implementation to use.
null to use the current default one.SslContextSSLExceptionpublic static SslContext newClientContext(SslProvider provider, File certChainFile) throws SSLException
SslContext.provider - the SslContext implementation to use.
null to use the current default one.certChainFile - an X.509 certificate chain file in PEM format.
null to use the system defaultSslContextSSLExceptionpublic static SslContext newClientContext(SslProvider provider, TrustManagerFactory trustManagerFactory) throws SSLException
SslContext.provider - the SslContext implementation to use.
null to use the current default one.trustManagerFactory - the TrustManagerFactory that provides the TrustManagers
that verifies the certificates sent from servers.
null to use the default.SslContextSSLExceptionpublic static SslContext newClientContext(SslProvider provider, File certChainFile, TrustManagerFactory trustManagerFactory) throws SSLException
SslContext.provider - the SslContext implementation to use.
null to use the current default one.certChainFile - an X.509 certificate chain file in PEM format.
null to use the system defaulttrustManagerFactory - the TrustManagerFactory that provides the TrustManagers
that verifies the certificates sent from servers.
null to use the default.SslContextSSLExceptionpublic static SslContext newClientContext(SslProvider provider, File certChainFile, TrustManagerFactory trustManagerFactory, Iterable<String> ciphers, CipherSuiteFilter cipherFilter, ApplicationProtocolConfig apn, long sessionCacheSize, long sessionTimeout) throws SSLException
SslContext.provider - the SslContext implementation to use.
null to use the current default one.certChainFile - an X.509 certificate chain file in PEM format.
null to use the system defaulttrustManagerFactory - the TrustManagerFactory that provides the TrustManagers
that verifies the certificates sent from servers.
null to use the default.ciphers - the cipher suites to enable, in the order of preference.
null to use the default cipher suites.cipherFilter - a filter to apply over the supplied list of ciphersapn - Provides a means to configure parameters related to application protocol negotiation.sessionCacheSize - the size of the cache used for storing SSL session objects.
0 to use the default value.sessionTimeout - the timeout for the cached SSL session objects, in seconds.
0 to use the default value.SslContextSSLExceptionpublic static SslContext newClientContext(SslProvider provider, File trustCertChainFile, TrustManagerFactory trustManagerFactory, File keyCertChainFile, File keyFile, String keyPassword, KeyManagerFactory keyManagerFactory, Iterable<String> ciphers, CipherSuiteFilter cipherFilter, ApplicationProtocolConfig apn, long sessionCacheSize, long sessionTimeout) throws SSLException
SslContext.provider - the SslContext implementation to use.
null to use the current default one.trustCertChainFile - an X.509 certificate chain file in PEM format.
null to use the system defaulttrustManagerFactory - the TrustManagerFactory that provides the TrustManagers
that verifies the certificates sent from servers.
null to use the default or the results of parsing trustCertChainFile.
This parameter is ignored if provider is not SslProvider.JDK.keyCertChainFile - an X.509 certificate chain file in PEM format.
This provides the public key for mutual authentication.
null to use the system defaultkeyFile - a PKCS#8 private key file in PEM format.
This provides the private key for mutual authentication.
null for no mutual authentication.keyPassword - the password of the keyFile.
null if it's not password-protected.
Ignored if keyFile is null.keyManagerFactory - the KeyManagerFactory that provides the KeyManagers
that is used to encrypt data being sent to servers.
null to use the default or the results of parsing
keyCertChainFile and keyFile.
This parameter is ignored if provider is not SslProvider.JDK.ciphers - the cipher suites to enable, in the order of preference.
null to use the default cipher suites.cipherFilter - a filter to apply over the supplied list of ciphersapn - Provides a means to configure parameters related to application protocol negotiation.sessionCacheSize - the size of the cache used for storing SSL session objects.
0 to use the default value.sessionTimeout - the timeout for the cached SSL session objects, in seconds.
0 to use the default value.SslContextSSLExceptionpublic final boolean isServer()
true if and only if this context is for server-side.public abstract boolean isClient()
true if and only if this context is for client-side.public abstract List<String> cipherSuites()
public abstract long sessionCacheSize()
public abstract long sessionTimeout()
public abstract ApplicationProtocolNegotiator applicationProtocolNegotiator()
public abstract SSLEngine newEngine(ByteBufAllocator alloc)
SSLEngine.SSLEnginepublic abstract SSLEngine newEngine(ByteBufAllocator alloc, String peerHost, int peerPort)
SSLEngine using advisory peer information.peerHost - the non-authoritative name of the hostpeerPort - the non-authoritative portSSLEnginepublic abstract SSLSessionContext sessionContext()
SSLSessionContext object held by this context.public final SslHandler newHandler(ByteBufAllocator alloc)
SslHandler.SslHandlerpublic final SslHandler newHandler(ByteBufAllocator alloc, String peerHost, int peerPort)
SslHandler with advisory peer information.peerHost - the non-authoritative name of the hostpeerPort - the non-authoritative portSslHandlerprotected static PKCS8EncodedKeySpec generateKeySpec(char[] password, byte[] key) throws IOException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeySpecException, InvalidKeyException, InvalidAlgorithmParameterException
password - characters, if null or empty an unencrypted key is assumedkey - bytes of the DER encoded private keyIOException - if parsing key failsNoSuchAlgorithmException - if the algorithm used to encrypt key is unkownNoSuchPaddingException - if the padding scheme specified in the decryption algorithm is unkownInvalidKeySpecException - if the decryption key based on password cannot be generatedInvalidKeyException - if the decryption key based on password cannot be used to decrypt
keyInvalidAlgorithmParameterException - if decryption algorithm parameters are somehow faultyCopyright © 2008–2015 The Netty Project. All rights reserved.