- java.lang.Object
-
- io.netty5.handler.ssl.SslContext
-
- Direct Known Subclasses:
DelegatingSslContext,JdkSslContext,ReferenceCountedOpenSslContext
public abstract class SslContext extends Object
A secure socket protocol implementation which acts as a factory forSSLEngineandSslHandler. Internally, it is implemented via JDK'sSSLContextor OpenSSL'sSSL_CTX.Making your server support SSL/TLS
// In your
ChannelInitializer:ChannelPipelinep = channel.pipeline();SslContextsslCtx =SslContextBuilder.forServer(...).build(); p.addLast("ssl",sslCtx.newHandler(channel.alloc())); ...Making your client support SSL/TLS
// In your
ChannelInitializer:ChannelPipelinep = channel.pipeline();SslContextsslCtx =SslContextBuilder.forClient().build(); p.addLast("ssl",sslCtx.newHandler(channel.alloc(), host, port)); ...
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedSslContext()Creates a new instance (startTls set tofalse).protectedSslContext(boolean startTls)Creates a new instance.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description abstract ApplicationProtocolNegotiatorapplicationProtocolNegotiator()Returns the object responsible for negotiating application layer protocols for the TLS NPN/ALPN extensions.AttributeMapattributes()Returns theAttributeMapthat belongs to thisSslContext.protected static KeyManagerFactorybuildKeyManagerFactory(X509Certificate[] certChainFile, String keyAlgorithm, PrivateKey key, String keyPassword, KeyManagerFactory kmf, String keyStore)protected static KeyStorebuildKeyStore(X509Certificate[] certChain, PrivateKey key, char[] keyPasswordChars, String keyStoreType)Generates a newKeyStore.protected static TrustManagerFactorybuildTrustManagerFactory(File certChainFile, TrustManagerFactory trustManagerFactory)Deprecated.protected static TrustManagerFactorybuildTrustManagerFactory(File certChainFile, TrustManagerFactory trustManagerFactory, String keyType)Build aTrustManagerFactoryfrom a certificate chain file.protected static TrustManagerFactorybuildTrustManagerFactory(X509Certificate[] certCollection, TrustManagerFactory trustManagerFactory, String keyStoreType)abstract List<String>cipherSuites()Returns the list of enabled cipher suites, in the order of preference.static SslProviderdefaultClientProvider()Returns the default client-side implementation provider currently in use.static SslProviderdefaultServerProvider()Returns the default server-side implementation provider currently in use.protected static PKCS8EncodedKeySpecgenerateKeySpec(char[] password, byte[] key)Deprecated.abstract booleanisClient()Returns thetrueif and only if this context is for client-side.booleanisServer()Returnstrueif and only if this context is for server-side.static SslContextnewClientContext()Deprecated.Replaced bySslContextBuilderstatic SslContextnewClientContext(SslProvider provider)Deprecated.Replaced bySslContextBuilderstatic SslContextnewClientContext(SslProvider provider, File certChainFile)Deprecated.Replaced bySslContextBuilderstatic SslContextnewClientContext(SslProvider provider, File certChainFile, TrustManagerFactory trustManagerFactory)Deprecated.Replaced bySslContextBuilderstatic SslContextnewClientContext(SslProvider provider, File trustCertCollectionFile, TrustManagerFactory trustManagerFactory, File keyCertChainFile, File keyFile, String keyPassword, KeyManagerFactory keyManagerFactory, Iterable<String> ciphers, CipherSuiteFilter cipherFilter, ApplicationProtocolConfig apn, long sessionCacheSize, long sessionTimeout)Deprecated.Replaced bySslContextBuilderstatic SslContextnewClientContext(SslProvider provider, File certChainFile, TrustManagerFactory trustManagerFactory, Iterable<String> ciphers, CipherSuiteFilter cipherFilter, ApplicationProtocolConfig apn, long sessionCacheSize, long sessionTimeout)Deprecated.Replaced bySslContextBuilderstatic SslContextnewClientContext(SslProvider provider, File certChainFile, TrustManagerFactory trustManagerFactory, Iterable<String> ciphers, Iterable<String> nextProtocols, long sessionCacheSize, long sessionTimeout)Deprecated.Replaced bySslContextBuilderstatic SslContextnewClientContext(SslProvider provider, TrustManagerFactory trustManagerFactory)Deprecated.Replaced bySslContextBuilderstatic SslContextnewClientContext(File certChainFile)Deprecated.Replaced bySslContextBuilderstatic SslContextnewClientContext(File certChainFile, TrustManagerFactory trustManagerFactory)Deprecated.Replaced bySslContextBuilderstatic SslContextnewClientContext(File certChainFile, TrustManagerFactory trustManagerFactory, Iterable<String> ciphers, CipherSuiteFilter cipherFilter, ApplicationProtocolConfig apn, long sessionCacheSize, long sessionTimeout)Deprecated.Replaced bySslContextBuilderstatic SslContextnewClientContext(File certChainFile, TrustManagerFactory trustManagerFactory, Iterable<String> ciphers, Iterable<String> nextProtocols, long sessionCacheSize, long sessionTimeout)Deprecated.Replaced bySslContextBuilderstatic SslContextnewClientContext(TrustManagerFactory trustManagerFactory)Deprecated.Replaced bySslContextBuilderabstract SSLEnginenewEngine(BufferAllocator alloc)Creates a newSSLEngine.abstract SSLEnginenewEngine(BufferAllocator alloc, String peerHost, int peerPort)Creates a newSSLEngineusing advisory peer information.SslHandlernewHandler(BufferAllocator alloc)Create a new SslHandler.protected SslHandlernewHandler(BufferAllocator alloc, boolean startTls)Create a new SslHandler.protected SslHandlernewHandler(BufferAllocator alloc, boolean startTls, Executor executor)Create a new SslHandler.SslHandlernewHandler(BufferAllocator alloc, String peerHost, int peerPort)Creates a newSslHandlerprotected SslHandlernewHandler(BufferAllocator alloc, String peerHost, int peerPort, boolean startTls)Create a new SslHandler.protected SslHandlernewHandler(BufferAllocator alloc, String peerHost, int peerPort, boolean startTls, Executor delegatedTaskExecutor)SslHandlernewHandler(BufferAllocator alloc, String peerHost, int peerPort, Executor delegatedTaskExecutor)Creates a newSslHandlerwith advisory peer information.SslHandlernewHandler(BufferAllocator alloc, Executor delegatedTaskExecutor)Creates a newSslHandler.static SslContextnewServerContext(SslProvider provider, File certChainFile, File keyFile)Deprecated.Replaced bySslContextBuilderstatic SslContextnewServerContext(SslProvider provider, File certChainFile, File keyFile, String keyPassword)Deprecated.Replaced bySslContextBuilderstatic SslContextnewServerContext(SslProvider provider, File certChainFile, File keyFile, String keyPassword, Iterable<String> ciphers, CipherSuiteFilter cipherFilter, ApplicationProtocolConfig apn, long sessionCacheSize, long sessionTimeout)Deprecated.Replaced bySslContextBuilderstatic SslContextnewServerContext(SslProvider provider, File certChainFile, File keyFile, String keyPassword, Iterable<String> ciphers, Iterable<String> nextProtocols, long sessionCacheSize, long sessionTimeout)Deprecated.Replaced bySslContextBuilderstatic SslContextnewServerContext(SslProvider provider, File certChainFile, File keyFile, String keyPassword, TrustManagerFactory trustManagerFactory, Iterable<String> ciphers, Iterable<String> nextProtocols, long sessionCacheSize, long sessionTimeout)Deprecated.Replaced bySslContextBuilderstatic SslContextnewServerContext(SslProvider provider, File trustCertCollectionFile, TrustManagerFactory trustManagerFactory, File keyCertChainFile, File keyFile, String keyPassword, KeyManagerFactory keyManagerFactory, Iterable<String> ciphers, CipherSuiteFilter cipherFilter, ApplicationProtocolConfig apn, long sessionCacheSize, long sessionTimeout)Deprecated.Replaced bySslContextBuilderstatic SslContextnewServerContext(File certChainFile, File keyFile)Deprecated.Replaced bySslContextBuilderstatic SslContextnewServerContext(File certChainFile, File keyFile, String keyPassword)Deprecated.Replaced bySslContextBuilderstatic SslContextnewServerContext(File certChainFile, File keyFile, String keyPassword, Iterable<String> ciphers, CipherSuiteFilter cipherFilter, ApplicationProtocolConfig apn, long sessionCacheSize, long sessionTimeout)Deprecated.Replaced bySslContextBuilderstatic SslContextnewServerContext(File certChainFile, File keyFile, String keyPassword, Iterable<String> ciphers, Iterable<String> nextProtocols, long sessionCacheSize, long sessionTimeout)Deprecated.Replaced bySslContextBuilderList<String>nextProtocols()Deprecated.UseapplicationProtocolNegotiator()instead.longsessionCacheSize()Returns the size of the cache used for storing SSL session objects.abstract SSLSessionContextsessionContext()Returns theSSLSessionContextobject held by this context.longsessionTimeout()Returns the timeout for the cached SSL session objects, in seconds.protected static PrivateKeytoPrivateKey(File keyFile, String keyPassword)protected static PrivateKeytoPrivateKey(InputStream keyInputStream, String keyPassword)protected static X509Certificate[]toX509Certificates(File file)protected static X509Certificate[]toX509Certificates(InputStream in)
-
-
-
Method Detail
-
defaultServerProvider
public static SslProvider defaultServerProvider()
Returns the default server-side implementation provider currently in use.- Returns:
SslProvider.OPENSSLif OpenSSL is available.SslProvider.JDKotherwise.
-
defaultClientProvider
public static SslProvider defaultClientProvider()
Returns the default client-side implementation provider currently in use.- Returns:
SslProvider.OPENSSLif OpenSSL is available.SslProvider.JDKotherwise.
-
newServerContext
@Deprecated public static SslContext newServerContext(File certChainFile, File keyFile) throws SSLException
Deprecated.Replaced bySslContextBuilderCreates a new server-sideSslContext.- Parameters:
certChainFile- an X.509 certificate chain file in PEM formatkeyFile- a PKCS#8 private key file in PEM format- Returns:
- a new server-side
SslContext - Throws:
SSLException
-
newServerContext
@Deprecated public static SslContext newServerContext(File certChainFile, File keyFile, String keyPassword) throws SSLException
Deprecated.Replaced bySslContextBuilderCreates a new server-sideSslContext.- Parameters:
certChainFile- an X.509 certificate chain file in PEM formatkeyFile- a PKCS#8 private key file in PEM formatkeyPassword- the password of thekeyFile.nullif it's not password-protected.- Returns:
- a new server-side
SslContext - Throws:
SSLException
-
newServerContext
@Deprecated public static SslContext newServerContext(File certChainFile, File keyFile, String keyPassword, Iterable<String> ciphers, Iterable<String> nextProtocols, long sessionCacheSize, long sessionTimeout) throws SSLException
Deprecated.Replaced bySslContextBuilderCreates a new server-sideSslContext.- Parameters:
certChainFile- an X.509 certificate chain file in PEM formatkeyFile- a PKCS#8 private key file in PEM formatkeyPassword- the password of thekeyFile.nullif it's not password-protected.ciphers- the cipher suites to enable, in the order of preference.nullto use the default cipher suites.nextProtocols- the application layer protocols to accept, in the order of preference.nullto disable TLS NPN/ALPN extension.sessionCacheSize- the size of the cache used for storing SSL session objects.0to use the default value.sessionTimeout- the timeout for the cached SSL session objects, in seconds.0to use the default value.- Returns:
- a new server-side
SslContext - Throws:
SSLException
-
newServerContext
@Deprecated public static SslContext newServerContext(File certChainFile, File keyFile, String keyPassword, Iterable<String> ciphers, CipherSuiteFilter cipherFilter, ApplicationProtocolConfig apn, long sessionCacheSize, long sessionTimeout) throws SSLException
Deprecated.Replaced bySslContextBuilderCreates a new server-sideSslContext.- Parameters:
certChainFile- an X.509 certificate chain file in PEM formatkeyFile- a PKCS#8 private key file in PEM formatkeyPassword- the password of thekeyFile.nullif it's not password-protected.ciphers- the cipher suites to enable, in the order of preference.nullto 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.0to use the default value.sessionTimeout- the timeout for the cached SSL session objects, in seconds.0to use the default value.- Returns:
- a new server-side
SslContext - Throws:
SSLException
-
newServerContext
@Deprecated public static SslContext newServerContext(SslProvider provider, File certChainFile, File keyFile) throws SSLException
Deprecated.Replaced bySslContextBuilderCreates a new server-sideSslContext.- Parameters:
provider- theSslContextimplementation to use.nullto use the current default one.certChainFile- an X.509 certificate chain file in PEM formatkeyFile- a PKCS#8 private key file in PEM format- Returns:
- a new server-side
SslContext - Throws:
SSLException
-
newServerContext
@Deprecated public static SslContext newServerContext(SslProvider provider, File certChainFile, File keyFile, String keyPassword) throws SSLException
Deprecated.Replaced bySslContextBuilderCreates a new server-sideSslContext.- Parameters:
provider- theSslContextimplementation to use.nullto 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 thekeyFile.nullif it's not password-protected.- Returns:
- a new server-side
SslContext - Throws:
SSLException
-
newServerContext
@Deprecated public static SslContext newServerContext(SslProvider provider, File certChainFile, File keyFile, String keyPassword, Iterable<String> ciphers, Iterable<String> nextProtocols, long sessionCacheSize, long sessionTimeout) throws SSLException
Deprecated.Replaced bySslContextBuilderCreates a new server-sideSslContext.- Parameters:
provider- theSslContextimplementation to use.nullto 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 thekeyFile.nullif it's not password-protected.ciphers- the cipher suites to enable, in the order of preference.nullto use the default cipher suites.nextProtocols- the application layer protocols to accept, in the order of preference.nullto disable TLS NPN/ALPN extension.sessionCacheSize- the size of the cache used for storing SSL session objects.0to use the default value.sessionTimeout- the timeout for the cached SSL session objects, in seconds.0to use the default value.- Returns:
- a new server-side
SslContext - Throws:
SSLException
-
newServerContext
@Deprecated public static SslContext newServerContext(SslProvider provider, File certChainFile, File keyFile, String keyPassword, TrustManagerFactory trustManagerFactory, Iterable<String> ciphers, Iterable<String> nextProtocols, long sessionCacheSize, long sessionTimeout) throws SSLException
Deprecated.Replaced bySslContextBuilderCreates a new server-sideSslContext.- Parameters:
provider- theSslContextimplementation to use.nullto 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 thekeyFile.nullif it's not password-protected.trustManagerFactory- theTrustManagerFactorythat provides theTrustManagers that verifies the certificates sent from servers.nullto use the default.ciphers- the cipher suites to enable, in the order of preference.nullto use the default cipher suites.nextProtocols- the application layer protocols to accept, in the order of preference.nullto disable TLS NPN/ALPN extension.sessionCacheSize- the size of the cache used for storing SSL session objects.0to use the default value.sessionTimeout- the timeout for the cached SSL session objects, in seconds.0to use the default value.- Returns:
- a new server-side
SslContext - Throws:
SSLException
-
newServerContext
@Deprecated public static SslContext newServerContext(SslProvider provider, File certChainFile, File keyFile, String keyPassword, Iterable<String> ciphers, CipherSuiteFilter cipherFilter, ApplicationProtocolConfig apn, long sessionCacheSize, long sessionTimeout) throws SSLException
Deprecated.Replaced bySslContextBuilderCreates a new server-sideSslContext.- Parameters:
provider- theSslContextimplementation to use.nullto 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 thekeyFile.nullif it's not password-protected.ciphers- the cipher suites to enable, in the order of preference.nullto use the default cipher suites.cipherFilter- a filter to apply over the supplied list of ciphers Only required ifproviderisSslProvider.JDKapn- Provides a means to configure parameters related to application protocol negotiation.sessionCacheSize- the size of the cache used for storing SSL session objects.0to use the default value.sessionTimeout- the timeout for the cached SSL session objects, in seconds.0to use the default value.- Returns:
- a new server-side
SslContext - Throws:
SSLException
-
newServerContext
@Deprecated public static SslContext newServerContext(SslProvider provider, File trustCertCollectionFile, TrustManagerFactory trustManagerFactory, File keyCertChainFile, File keyFile, String keyPassword, KeyManagerFactory keyManagerFactory, Iterable<String> ciphers, CipherSuiteFilter cipherFilter, ApplicationProtocolConfig apn, long sessionCacheSize, long sessionTimeout) throws SSLException
Deprecated.Replaced bySslContextBuilderCreates a new server-sideSslContext.- Parameters:
provider- theSslContextimplementation to use.nullto use the current default one.trustCertCollectionFile- an X.509 certificate collection file in PEM format. This provides the certificate collection used for mutual authentication.nullto use the system defaulttrustManagerFactory- theTrustManagerFactorythat provides theTrustManagers that verifies the certificates sent from clients.nullto use the default or the results of parsingtrustCertCollectionFile. This parameter is ignored ifprovideris notSslProvider.JDK.keyCertChainFile- an X.509 certificate chain file in PEM formatkeyFile- a PKCS#8 private key file in PEM formatkeyPassword- the password of thekeyFile.nullif it's not password-protected.keyManagerFactory- theKeyManagerFactorythat provides theKeyManagers that is used to encrypt data being sent to clients.nullto use the default or the results of parsingkeyCertChainFileandkeyFile. This parameter is ignored ifprovideris notSslProvider.JDK.ciphers- the cipher suites to enable, in the order of preference.nullto use the default cipher suites.cipherFilter- a filter to apply over the supplied list of ciphers Only required ifproviderisSslProvider.JDKapn- Provides a means to configure parameters related to application protocol negotiation.sessionCacheSize- the size of the cache used for storing SSL session objects.0to use the default value.sessionTimeout- the timeout for the cached SSL session objects, in seconds.0to use the default value.- Returns:
- a new server-side
SslContext - Throws:
SSLException
-
newClientContext
@Deprecated public static SslContext newClientContext() throws SSLException
Deprecated.Replaced bySslContextBuilderCreates a new client-sideSslContext.- Returns:
- a new client-side
SslContext - Throws:
SSLException
-
newClientContext
@Deprecated public static SslContext newClientContext(File certChainFile) throws SSLException
Deprecated.Replaced bySslContextBuilderCreates a new client-sideSslContext.- Parameters:
certChainFile- an X.509 certificate chain file in PEM format- Returns:
- a new client-side
SslContext - Throws:
SSLException
-
newClientContext
@Deprecated public static SslContext newClientContext(TrustManagerFactory trustManagerFactory) throws SSLException
Deprecated.Replaced bySslContextBuilderCreates a new client-sideSslContext.- Parameters:
trustManagerFactory- theTrustManagerFactorythat provides theTrustManagers that verifies the certificates sent from servers.nullto use the default.- Returns:
- a new client-side
SslContext - Throws:
SSLException
-
newClientContext
@Deprecated public static SslContext newClientContext(File certChainFile, TrustManagerFactory trustManagerFactory) throws SSLException
Deprecated.Replaced bySslContextBuilderCreates a new client-sideSslContext.- Parameters:
certChainFile- an X.509 certificate chain file in PEM format.nullto use the system defaulttrustManagerFactory- theTrustManagerFactorythat provides theTrustManagers that verifies the certificates sent from servers.nullto use the default.- Returns:
- a new client-side
SslContext - Throws:
SSLException
-
newClientContext
@Deprecated public static SslContext newClientContext(File certChainFile, TrustManagerFactory trustManagerFactory, Iterable<String> ciphers, Iterable<String> nextProtocols, long sessionCacheSize, long sessionTimeout) throws SSLException
Deprecated.Replaced bySslContextBuilderCreates a new client-sideSslContext.- Parameters:
certChainFile- an X.509 certificate chain file in PEM format.nullto use the system defaulttrustManagerFactory- theTrustManagerFactorythat provides theTrustManagers that verifies the certificates sent from servers.nullto use the default.ciphers- the cipher suites to enable, in the order of preference.nullto use the default cipher suites.nextProtocols- the application layer protocols to accept, in the order of preference.nullto disable TLS NPN/ALPN extension.sessionCacheSize- the size of the cache used for storing SSL session objects.0to use the default value.sessionTimeout- the timeout for the cached SSL session objects, in seconds.0to use the default value.- Returns:
- a new client-side
SslContext - Throws:
SSLException
-
newClientContext
@Deprecated public static SslContext newClientContext(File certChainFile, TrustManagerFactory trustManagerFactory, Iterable<String> ciphers, CipherSuiteFilter cipherFilter, ApplicationProtocolConfig apn, long sessionCacheSize, long sessionTimeout) throws SSLException
Deprecated.Replaced bySslContextBuilderCreates a new client-sideSslContext.- Parameters:
certChainFile- an X.509 certificate chain file in PEM format.nullto use the system defaulttrustManagerFactory- theTrustManagerFactorythat provides theTrustManagers that verifies the certificates sent from servers.nullto use the default.ciphers- the cipher suites to enable, in the order of preference.nullto 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.0to use the default value.sessionTimeout- the timeout for the cached SSL session objects, in seconds.0to use the default value.- Returns:
- a new client-side
SslContext - Throws:
SSLException
-
newClientContext
@Deprecated public static SslContext newClientContext(SslProvider provider) throws SSLException
Deprecated.Replaced bySslContextBuilderCreates a new client-sideSslContext.- Parameters:
provider- theSslContextimplementation to use.nullto use the current default one.- Returns:
- a new client-side
SslContext - Throws:
SSLException
-
newClientContext
@Deprecated public static SslContext newClientContext(SslProvider provider, File certChainFile) throws SSLException
Deprecated.Replaced bySslContextBuilderCreates a new client-sideSslContext.- Parameters:
provider- theSslContextimplementation to use.nullto use the current default one.certChainFile- an X.509 certificate chain file in PEM format.nullto use the system default- Returns:
- a new client-side
SslContext - Throws:
SSLException
-
newClientContext
@Deprecated public static SslContext newClientContext(SslProvider provider, TrustManagerFactory trustManagerFactory) throws SSLException
Deprecated.Replaced bySslContextBuilderCreates a new client-sideSslContext.- Parameters:
provider- theSslContextimplementation to use.nullto use the current default one.trustManagerFactory- theTrustManagerFactorythat provides theTrustManagers that verifies the certificates sent from servers.nullto use the default.- Returns:
- a new client-side
SslContext - Throws:
SSLException
-
newClientContext
@Deprecated public static SslContext newClientContext(SslProvider provider, File certChainFile, TrustManagerFactory trustManagerFactory) throws SSLException
Deprecated.Replaced bySslContextBuilderCreates a new client-sideSslContext.- Parameters:
provider- theSslContextimplementation to use.nullto use the current default one.certChainFile- an X.509 certificate chain file in PEM format.nullto use the system defaulttrustManagerFactory- theTrustManagerFactorythat provides theTrustManagers that verifies the certificates sent from servers.nullto use the default.- Returns:
- a new client-side
SslContext - Throws:
SSLException
-
newClientContext
@Deprecated public static SslContext newClientContext(SslProvider provider, File certChainFile, TrustManagerFactory trustManagerFactory, Iterable<String> ciphers, Iterable<String> nextProtocols, long sessionCacheSize, long sessionTimeout) throws SSLException
Deprecated.Replaced bySslContextBuilderCreates a new client-sideSslContext.- Parameters:
provider- theSslContextimplementation to use.nullto use the current default one.certChainFile- an X.509 certificate chain file in PEM format.nullto use the system defaulttrustManagerFactory- theTrustManagerFactorythat provides theTrustManagers that verifies the certificates sent from servers.nullto use the default.ciphers- the cipher suites to enable, in the order of preference.nullto use the default cipher suites.nextProtocols- the application layer protocols to accept, in the order of preference.nullto disable TLS NPN/ALPN extension.sessionCacheSize- the size of the cache used for storing SSL session objects.0to use the default value.sessionTimeout- the timeout for the cached SSL session objects, in seconds.0to use the default value.- Returns:
- a new client-side
SslContext - Throws:
SSLException
-
newClientContext
@Deprecated public static SslContext newClientContext(SslProvider provider, File certChainFile, TrustManagerFactory trustManagerFactory, Iterable<String> ciphers, CipherSuiteFilter cipherFilter, ApplicationProtocolConfig apn, long sessionCacheSize, long sessionTimeout) throws SSLException
Deprecated.Replaced bySslContextBuilderCreates a new client-sideSslContext.- Parameters:
provider- theSslContextimplementation to use.nullto use the current default one.certChainFile- an X.509 certificate chain file in PEM format.nullto use the system defaulttrustManagerFactory- theTrustManagerFactorythat provides theTrustManagers that verifies the certificates sent from servers.nullto use the default.ciphers- the cipher suites to enable, in the order of preference.nullto 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.0to use the default value.sessionTimeout- the timeout for the cached SSL session objects, in seconds.0to use the default value.- Returns:
- a new client-side
SslContext - Throws:
SSLException
-
newClientContext
@Deprecated public static SslContext newClientContext(SslProvider provider, File trustCertCollectionFile, TrustManagerFactory trustManagerFactory, File keyCertChainFile, File keyFile, String keyPassword, KeyManagerFactory keyManagerFactory, Iterable<String> ciphers, CipherSuiteFilter cipherFilter, ApplicationProtocolConfig apn, long sessionCacheSize, long sessionTimeout) throws SSLException
Deprecated.Replaced bySslContextBuilderCreates a new client-sideSslContext.- Parameters:
provider- theSslContextimplementation to use.nullto use the current default one.trustCertCollectionFile- an X.509 certificate collection file in PEM format.nullto use the system defaulttrustManagerFactory- theTrustManagerFactorythat provides theTrustManagers that verifies the certificates sent from servers.nullto use the default or the results of parsingtrustCertCollectionFile. This parameter is ignored ifprovideris notSslProvider.JDK.keyCertChainFile- an X.509 certificate chain file in PEM format. This provides the public key for mutual authentication.nullto use the system defaultkeyFile- a PKCS#8 private key file in PEM format. This provides the private key for mutual authentication.nullfor no mutual authentication.keyPassword- the password of thekeyFile.nullif it's not password-protected. Ignored ifkeyFileisnull.keyManagerFactory- theKeyManagerFactorythat provides theKeyManagers that is used to encrypt data being sent to servers.nullto use the default or the results of parsingkeyCertChainFileandkeyFile. This parameter is ignored ifprovideris notSslProvider.JDK.ciphers- the cipher suites to enable, in the order of preference.nullto 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.0to use the default value.sessionTimeout- the timeout for the cached SSL session objects, in seconds.0to use the default value.- Returns:
- a new client-side
SslContext - Throws:
SSLException
-
attributes
public final AttributeMap attributes()
Returns theAttributeMapthat belongs to thisSslContext.
-
isServer
public final boolean isServer()
Returnstrueif and only if this context is for server-side.
-
isClient
public abstract boolean isClient()
Returns thetrueif and only if this context is for client-side.
-
cipherSuites
public abstract List<String> cipherSuites()
Returns the list of enabled cipher suites, in the order of preference.
-
sessionCacheSize
public long sessionCacheSize()
Returns the size of the cache used for storing SSL session objects.
-
sessionTimeout
public long sessionTimeout()
Returns the timeout for the cached SSL session objects, in seconds.
-
nextProtocols
@Deprecated public final List<String> nextProtocols()
Deprecated.UseapplicationProtocolNegotiator()instead.
-
applicationProtocolNegotiator
public abstract ApplicationProtocolNegotiator applicationProtocolNegotiator()
Returns the object responsible for negotiating application layer protocols for the TLS NPN/ALPN extensions.
-
newEngine
public abstract SSLEngine newEngine(BufferAllocator alloc)
Creates a newSSLEngine.If
SslProvider.OPENSSL_REFCNTis used then the object must be released. One way to do this is to wrap in aSslHandlerand insert it into a pipeline. SeenewHandler(BufferAllocator).- Returns:
- a new
SSLEngine
-
newEngine
public abstract SSLEngine newEngine(BufferAllocator alloc, String peerHost, int peerPort)
Creates a newSSLEngineusing advisory peer information.If
SslProvider.OPENSSL_REFCNTis used then the object must be released. One way to do this is to wrap in aSslHandlerand insert it into a pipeline. SeenewHandler(BufferAllocator, String, int).- Parameters:
peerHost- the non-authoritative name of the hostpeerPort- the non-authoritative port- Returns:
- a new
SSLEngine
-
sessionContext
public abstract SSLSessionContext sessionContext()
Returns theSSLSessionContextobject held by this context.
-
newHandler
public final SslHandler newHandler(BufferAllocator alloc)
Create a new SslHandler.- See Also:
newHandler(BufferAllocator, Executor)
-
newHandler
protected SslHandler newHandler(BufferAllocator alloc, boolean startTls)
Create a new SslHandler.- See Also:
newHandler(BufferAllocator)
-
newHandler
public SslHandler newHandler(BufferAllocator alloc, Executor delegatedTaskExecutor)
Creates a newSslHandler.If
SslProvider.OPENSSL_REFCNTis used then the returnedSslHandlerwill release the engine that is wrapped. If the returnedSslHandleris not inserted into a pipeline then you may leak native memory!Beware: the underlying generated
SSLEnginewon't have hostname verification enabled by default. If you createSslHandlerfor the client side and want proper security, we advice that you configure theSSLEngine(seeSSLParameters.setEndpointIdentificationAlgorithm(String)):SSLEngine sslEngine = sslHandler.engine(); SSLParameters sslParameters = sslEngine.getSSLParameters(); // only available since Java 7 sslParameters.setEndpointIdentificationAlgorithm("HTTPS"); sslEngine.setSSLParameters(sslParameters);The underlying
SSLEnginemay not follow the restrictions imposed by the SSLEngine javadocs which limits wrap/unwrap to operate on a single SSL/TLS packet.- Parameters:
alloc- If supported by the SSLEngine then the SSLEngine will use this to allocate Buffer objects.delegatedTaskExecutor- theExecutorthat will be used to execute tasks that are returned bySSLEngine.getDelegatedTask().- Returns:
- a new
SslHandler
-
newHandler
protected SslHandler newHandler(BufferAllocator alloc, boolean startTls, Executor executor)
Create a new SslHandler.
-
newHandler
public final SslHandler newHandler(BufferAllocator alloc, String peerHost, int peerPort)
Creates a newSslHandler
-
newHandler
protected SslHandler newHandler(BufferAllocator alloc, String peerHost, int peerPort, boolean startTls)
Create a new SslHandler.
-
newHandler
public SslHandler newHandler(BufferAllocator alloc, String peerHost, int peerPort, Executor delegatedTaskExecutor)
Creates a newSslHandlerwith advisory peer information.If
SslProvider.OPENSSL_REFCNTis used then the returnedSslHandlerwill release the engine that is wrapped. If the returnedSslHandleris not inserted into a pipeline then you may leak native memory!Beware: the underlying generated
SSLEnginewon't have hostname verification enabled by default. If you createSslHandlerfor the client side and want proper security, we advice that you configure theSSLEngine(seeSSLParameters.setEndpointIdentificationAlgorithm(String)):SSLEngine sslEngine = sslHandler.engine(); SSLParameters sslParameters = sslEngine.getSSLParameters(); // only available since Java 7 sslParameters.setEndpointIdentificationAlgorithm("HTTPS"); sslEngine.setSSLParameters(sslParameters);The underlying
SSLEnginemay not follow the restrictions imposed by the SSLEngine javadocs which limits wrap/unwrap to operate on a single SSL/TLS packet.- Parameters:
alloc- If supported by the SSLEngine then the SSLEngine will use this to allocate Buffer objects.peerHost- the non-authoritative name of the hostpeerPort- the non-authoritative portdelegatedTaskExecutor- theExecutorthat will be used to execute tasks that are returned bySSLEngine.getDelegatedTask().- Returns:
- a new
SslHandler
-
newHandler
protected SslHandler newHandler(BufferAllocator alloc, String peerHost, int peerPort, boolean startTls, Executor delegatedTaskExecutor)
-
generateKeySpec
@Deprecated protected static PKCS8EncodedKeySpec generateKeySpec(char[] password, byte[] key) throws IOException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeySpecException, InvalidKeyException, InvalidAlgorithmParameterException
Deprecated.Generates a key specification for an (encrypted) private key.- Parameters:
password- characters, ifnullan unencrypted key is assumedkey- bytes of the DER encoded private key- Returns:
- a key specification
- Throws:
IOException- if parsingkeyfailsNoSuchAlgorithmException- if the algorithm used to encryptkeyis unknownNoSuchPaddingException- if the padding scheme specified in the decryption algorithm is unknownInvalidKeySpecException- if the decryption key based onpasswordcannot be generatedInvalidKeyException- if the decryption key based onpasswordcannot be used to decryptkeyInvalidAlgorithmParameterException- if decryption algorithm parameters are somehow faulty
-
buildKeyStore
protected static KeyStore buildKeyStore(X509Certificate[] certChain, PrivateKey key, char[] keyPasswordChars, String keyStoreType) throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException
Generates a newKeyStore.- Parameters:
certChain- an X.509 certificate chainkey- a PKCS#8 private keykeyPasswordChars- the password of thekeyFile.nullif it's not password-protected.keyStoreType- The KeyStore Type you want to use- Returns:
- generated
KeyStore. - Throws:
KeyStoreExceptionNoSuchAlgorithmExceptionCertificateExceptionIOException
-
toPrivateKey
protected static PrivateKey toPrivateKey(File keyFile, String keyPassword) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeySpecException, InvalidAlgorithmParameterException, KeyException, IOException
-
toPrivateKey
protected static PrivateKey toPrivateKey(InputStream keyInputStream, String keyPassword) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeySpecException, InvalidAlgorithmParameterException, KeyException, IOException
-
buildTrustManagerFactory
@Deprecated protected static TrustManagerFactory buildTrustManagerFactory(File certChainFile, TrustManagerFactory trustManagerFactory) throws NoSuchAlgorithmException, CertificateException, KeyStoreException, IOException
Deprecated.Build aTrustManagerFactoryfrom a certificate chain file.- Parameters:
certChainFile- The certificate file to build from.trustManagerFactory- The existingTrustManagerFactorythat will be used if notnull.- Returns:
- A
TrustManagerFactorywhich contains the certificates incertChainFile - Throws:
NoSuchAlgorithmExceptionCertificateExceptionKeyStoreExceptionIOException
-
buildTrustManagerFactory
protected static TrustManagerFactory buildTrustManagerFactory(File certChainFile, TrustManagerFactory trustManagerFactory, String keyType) throws NoSuchAlgorithmException, CertificateException, KeyStoreException, IOException
Build aTrustManagerFactoryfrom a certificate chain file.- Parameters:
certChainFile- The certificate file to build from.trustManagerFactory- The existingTrustManagerFactorythat will be used if notnull.keyType- The KeyStore Type you want to use- Returns:
- A
TrustManagerFactorywhich contains the certificates incertChainFile - Throws:
NoSuchAlgorithmExceptionCertificateExceptionKeyStoreExceptionIOException
-
toX509Certificates
protected static X509Certificate[] toX509Certificates(File file) throws CertificateException
- Throws:
CertificateException
-
toX509Certificates
protected static X509Certificate[] toX509Certificates(InputStream in) throws CertificateException
- Throws:
CertificateException
-
buildTrustManagerFactory
protected static TrustManagerFactory buildTrustManagerFactory(X509Certificate[] certCollection, TrustManagerFactory trustManagerFactory, String keyStoreType) throws NoSuchAlgorithmException, CertificateException, KeyStoreException, IOException
-
buildKeyManagerFactory
protected static KeyManagerFactory buildKeyManagerFactory(X509Certificate[] certChainFile, String keyAlgorithm, PrivateKey key, String keyPassword, KeyManagerFactory kmf, String keyStore) throws KeyStoreException, NoSuchAlgorithmException, IOException, CertificateException, UnrecoverableKeyException
-
-