Class SslContext
- java.lang.Object
- 
- io.netty.handler.ssl.SslContext
 
- 
- Direct Known Subclasses:
- DelegatingSslContext,- JdkSslContext,- QuicSslContext,- ReferenceCountedOpenSslContext
 
 public abstract class SslContext extends java.lang.ObjectA 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 SummaryConstructors Modifier Constructor Description protectedSslContext()Creates a new instance (startTls set tofalse).protectedSslContext(boolean startTls)Creates a new instance.
 - 
Method SummaryAll 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 javax.net.ssl.KeyManagerFactorybuildKeyManagerFactory(java.security.cert.X509Certificate[] certChainFile, java.lang.String keyAlgorithm, java.security.PrivateKey key, java.lang.String keyPassword, javax.net.ssl.KeyManagerFactory kmf, java.lang.String keyStore)protected static java.security.KeyStorebuildKeyStore(java.security.cert.X509Certificate[] certChain, java.security.PrivateKey key, char[] keyPasswordChars, java.lang.String keyStoreType)Generates a newKeyStore.protected static javax.net.ssl.TrustManagerFactorybuildTrustManagerFactory(java.io.File certChainFile, javax.net.ssl.TrustManagerFactory trustManagerFactory)Deprecated.protected static javax.net.ssl.TrustManagerFactorybuildTrustManagerFactory(java.io.File certChainFile, javax.net.ssl.TrustManagerFactory trustManagerFactory, java.lang.String keyType)Build aTrustManagerFactoryfrom a certificate chain file.protected static javax.net.ssl.TrustManagerFactorybuildTrustManagerFactory(java.security.cert.X509Certificate[] certCollection, javax.net.ssl.TrustManagerFactory trustManagerFactory, java.lang.String keyStoreType)abstract java.util.List<java.lang.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 java.security.spec.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, java.io.File certChainFile)Deprecated.Replaced bySslContextBuilderstatic SslContextnewClientContext(SslProvider provider, java.io.File certChainFile, javax.net.ssl.TrustManagerFactory trustManagerFactory)Deprecated.Replaced bySslContextBuilderstatic SslContextnewClientContext(SslProvider provider, java.io.File trustCertCollectionFile, javax.net.ssl.TrustManagerFactory trustManagerFactory, java.io.File keyCertChainFile, java.io.File keyFile, java.lang.String keyPassword, javax.net.ssl.KeyManagerFactory keyManagerFactory, java.lang.Iterable<java.lang.String> ciphers, CipherSuiteFilter cipherFilter, ApplicationProtocolConfig apn, long sessionCacheSize, long sessionTimeout)Deprecated.Replaced bySslContextBuilderstatic SslContextnewClientContext(SslProvider provider, java.io.File certChainFile, javax.net.ssl.TrustManagerFactory trustManagerFactory, java.lang.Iterable<java.lang.String> ciphers, CipherSuiteFilter cipherFilter, ApplicationProtocolConfig apn, long sessionCacheSize, long sessionTimeout)Deprecated.Replaced bySslContextBuilderstatic SslContextnewClientContext(SslProvider provider, java.io.File certChainFile, javax.net.ssl.TrustManagerFactory trustManagerFactory, java.lang.Iterable<java.lang.String> ciphers, java.lang.Iterable<java.lang.String> nextProtocols, long sessionCacheSize, long sessionTimeout)Deprecated.Replaced bySslContextBuilderstatic SslContextnewClientContext(SslProvider provider, javax.net.ssl.TrustManagerFactory trustManagerFactory)Deprecated.Replaced bySslContextBuilderstatic SslContextnewClientContext(java.io.File certChainFile)Deprecated.Replaced bySslContextBuilderstatic SslContextnewClientContext(java.io.File certChainFile, javax.net.ssl.TrustManagerFactory trustManagerFactory)Deprecated.Replaced bySslContextBuilderstatic SslContextnewClientContext(java.io.File certChainFile, javax.net.ssl.TrustManagerFactory trustManagerFactory, java.lang.Iterable<java.lang.String> ciphers, CipherSuiteFilter cipherFilter, ApplicationProtocolConfig apn, long sessionCacheSize, long sessionTimeout)Deprecated.Replaced bySslContextBuilderstatic SslContextnewClientContext(java.io.File certChainFile, javax.net.ssl.TrustManagerFactory trustManagerFactory, java.lang.Iterable<java.lang.String> ciphers, java.lang.Iterable<java.lang.String> nextProtocols, long sessionCacheSize, long sessionTimeout)Deprecated.Replaced bySslContextBuilderstatic SslContextnewClientContext(javax.net.ssl.TrustManagerFactory trustManagerFactory)Deprecated.Replaced bySslContextBuilderabstract javax.net.ssl.SSLEnginenewEngine(ByteBufAllocator alloc)Creates a newSSLEngine.abstract javax.net.ssl.SSLEnginenewEngine(ByteBufAllocator alloc, java.lang.String peerHost, int peerPort)Creates a newSSLEngineusing advisory peer information.SslHandlernewHandler(ByteBufAllocator alloc)Create a new SslHandler.protected SslHandlernewHandler(ByteBufAllocator alloc, boolean startTls)Create a new SslHandler.protected SslHandlernewHandler(ByteBufAllocator alloc, boolean startTls, java.util.concurrent.Executor executor)Create a new SslHandler.SslHandlernewHandler(ByteBufAllocator alloc, java.lang.String peerHost, int peerPort)Creates a newSslHandlerprotected SslHandlernewHandler(ByteBufAllocator alloc, java.lang.String peerHost, int peerPort, boolean startTls)Create a new SslHandler.protected SslHandlernewHandler(ByteBufAllocator alloc, java.lang.String peerHost, int peerPort, boolean startTls, java.util.concurrent.Executor delegatedTaskExecutor)SslHandlernewHandler(ByteBufAllocator alloc, java.lang.String peerHost, int peerPort, java.util.concurrent.Executor delegatedTaskExecutor)Creates a newSslHandlerwith advisory peer information.SslHandlernewHandler(ByteBufAllocator alloc, java.util.concurrent.Executor delegatedTaskExecutor)Creates a newSslHandler.static SslContextnewServerContext(SslProvider provider, java.io.File certChainFile, java.io.File keyFile)Deprecated.Replaced bySslContextBuilderstatic SslContextnewServerContext(SslProvider provider, java.io.File certChainFile, java.io.File keyFile, java.lang.String keyPassword)Deprecated.Replaced bySslContextBuilderstatic SslContextnewServerContext(SslProvider provider, java.io.File certChainFile, java.io.File keyFile, java.lang.String keyPassword, java.lang.Iterable<java.lang.String> ciphers, CipherSuiteFilter cipherFilter, ApplicationProtocolConfig apn, long sessionCacheSize, long sessionTimeout)Deprecated.Replaced bySslContextBuilderstatic SslContextnewServerContext(SslProvider provider, java.io.File certChainFile, java.io.File keyFile, java.lang.String keyPassword, java.lang.Iterable<java.lang.String> ciphers, java.lang.Iterable<java.lang.String> nextProtocols, long sessionCacheSize, long sessionTimeout)Deprecated.Replaced bySslContextBuilderstatic SslContextnewServerContext(SslProvider provider, java.io.File certChainFile, java.io.File keyFile, java.lang.String keyPassword, javax.net.ssl.TrustManagerFactory trustManagerFactory, java.lang.Iterable<java.lang.String> ciphers, java.lang.Iterable<java.lang.String> nextProtocols, long sessionCacheSize, long sessionTimeout)Deprecated.Replaced bySslContextBuilderstatic SslContextnewServerContext(SslProvider provider, java.io.File trustCertCollectionFile, javax.net.ssl.TrustManagerFactory trustManagerFactory, java.io.File keyCertChainFile, java.io.File keyFile, java.lang.String keyPassword, javax.net.ssl.KeyManagerFactory keyManagerFactory, java.lang.Iterable<java.lang.String> ciphers, CipherSuiteFilter cipherFilter, ApplicationProtocolConfig apn, long sessionCacheSize, long sessionTimeout)Deprecated.Replaced bySslContextBuilderstatic SslContextnewServerContext(java.io.File certChainFile, java.io.File keyFile)Deprecated.Replaced bySslContextBuilderstatic SslContextnewServerContext(java.io.File certChainFile, java.io.File keyFile, java.lang.String keyPassword)Deprecated.Replaced bySslContextBuilderstatic SslContextnewServerContext(java.io.File certChainFile, java.io.File keyFile, java.lang.String keyPassword, java.lang.Iterable<java.lang.String> ciphers, CipherSuiteFilter cipherFilter, ApplicationProtocolConfig apn, long sessionCacheSize, long sessionTimeout)Deprecated.Replaced bySslContextBuilderstatic SslContextnewServerContext(java.io.File certChainFile, java.io.File keyFile, java.lang.String keyPassword, java.lang.Iterable<java.lang.String> ciphers, java.lang.Iterable<java.lang.String> nextProtocols, long sessionCacheSize, long sessionTimeout)Deprecated.Replaced bySslContextBuilderjava.util.List<java.lang.String>nextProtocols()Deprecated.UseapplicationProtocolNegotiator()instead.longsessionCacheSize()Returns the size of the cache used for storing SSL session objects.abstract javax.net.ssl.SSLSessionContextsessionContext()Returns theSSLSessionContextobject held by this context.longsessionTimeout()Returns the timeout for the cached SSL session objects, in seconds.protected static java.security.PrivateKeytoPrivateKey(java.io.File keyFile, java.lang.String keyPassword)protected static java.security.PrivateKeytoPrivateKey(java.io.InputStream keyInputStream, java.lang.String keyPassword)protected static java.security.cert.X509Certificate[]toX509Certificates(java.io.File file)protected static java.security.cert.X509Certificate[]toX509Certificates(java.io.InputStream in)
 
- 
- 
- 
Method Detail- 
defaultServerProviderpublic static SslProvider defaultServerProvider() Returns the default server-side implementation provider currently in use.- Returns:
- SslProvider.OPENSSLif OpenSSL is available.- SslProvider.JDKotherwise.
 
 - 
defaultClientProviderpublic 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(java.io.File certChainFile, java.io.File keyFile) throws javax.net.ssl.SSLException Deprecated.Replaced bySslContextBuilderCreates a new server-sideSslContext.- Parameters:
- certChainFile- an X.509 certificate chain file in PEM format
- keyFile- a PKCS#8 private key file in PEM format
- Returns:
- a new server-side SslContext
- Throws:
- javax.net.ssl.SSLException
 
 - 
newServerContext@Deprecated public static SslContext newServerContext(java.io.File certChainFile, java.io.File keyFile, java.lang.String keyPassword) throws javax.net.ssl.SSLException Deprecated.Replaced bySslContextBuilderCreates a new server-sideSslContext.- Parameters:
- certChainFile- an X.509 certificate chain file in PEM format
- keyFile- a PKCS#8 private key file in PEM format
- keyPassword- the password of the- keyFile.- nullif it's not password-protected.
- Returns:
- a new server-side SslContext
- Throws:
- javax.net.ssl.SSLException
 
 - 
newServerContext@Deprecated public static SslContext newServerContext(java.io.File certChainFile, java.io.File keyFile, java.lang.String keyPassword, java.lang.Iterable<java.lang.String> ciphers, java.lang.Iterable<java.lang.String> nextProtocols, long sessionCacheSize, long sessionTimeout) throws javax.net.ssl.SSLException Deprecated.Replaced bySslContextBuilderCreates a new server-sideSslContext.- Parameters:
- certChainFile- an X.509 certificate chain file in PEM format
- keyFile- a PKCS#8 private key file in PEM format
- keyPassword- the password of the- keyFile.- 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:
- javax.net.ssl.SSLException
 
 - 
newServerContext@Deprecated public static SslContext newServerContext(java.io.File certChainFile, java.io.File keyFile, java.lang.String keyPassword, java.lang.Iterable<java.lang.String> ciphers, CipherSuiteFilter cipherFilter, ApplicationProtocolConfig apn, long sessionCacheSize, long sessionTimeout) throws javax.net.ssl.SSLException Deprecated.Replaced bySslContextBuilderCreates a new server-sideSslContext.- Parameters:
- certChainFile- an X.509 certificate chain file in PEM format
- keyFile- a PKCS#8 private key file in PEM format
- keyPassword- the password of the- keyFile.- 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
- apn- 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:
- javax.net.ssl.SSLException
 
 - 
newServerContext@Deprecated public static SslContext newServerContext(SslProvider provider, java.io.File certChainFile, java.io.File keyFile) throws javax.net.ssl.SSLException Deprecated.Replaced bySslContextBuilderCreates a new server-sideSslContext.- Parameters:
- provider- the- SslContextimplementation to use.- nullto use the current default one.
- certChainFile- an X.509 certificate chain file in PEM format
- keyFile- a PKCS#8 private key file in PEM format
- Returns:
- a new server-side SslContext
- Throws:
- javax.net.ssl.SSLException
 
 - 
newServerContext@Deprecated public static SslContext newServerContext(SslProvider provider, java.io.File certChainFile, java.io.File keyFile, java.lang.String keyPassword) throws javax.net.ssl.SSLException Deprecated.Replaced bySslContextBuilderCreates a new server-sideSslContext.- Parameters:
- provider- the- SslContextimplementation to use.- nullto use the current default one.
- certChainFile- an X.509 certificate chain file in PEM format
- keyFile- a PKCS#8 private key file in PEM format
- keyPassword- the password of the- keyFile.- nullif it's not password-protected.
- Returns:
- a new server-side SslContext
- Throws:
- javax.net.ssl.SSLException
 
 - 
newServerContext@Deprecated public static SslContext newServerContext(SslProvider provider, java.io.File certChainFile, java.io.File keyFile, java.lang.String keyPassword, java.lang.Iterable<java.lang.String> ciphers, java.lang.Iterable<java.lang.String> nextProtocols, long sessionCacheSize, long sessionTimeout) throws javax.net.ssl.SSLException Deprecated.Replaced bySslContextBuilderCreates a new server-sideSslContext.- Parameters:
- provider- the- SslContextimplementation to use.- nullto use the current default one.
- certChainFile- an X.509 certificate chain file in PEM format
- keyFile- a PKCS#8 private key file in PEM format
- keyPassword- the password of the- keyFile.- 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:
- javax.net.ssl.SSLException
 
 - 
newServerContext@Deprecated public static SslContext newServerContext(SslProvider provider, java.io.File certChainFile, java.io.File keyFile, java.lang.String keyPassword, javax.net.ssl.TrustManagerFactory trustManagerFactory, java.lang.Iterable<java.lang.String> ciphers, java.lang.Iterable<java.lang.String> nextProtocols, long sessionCacheSize, long sessionTimeout) throws javax.net.ssl.SSLException Deprecated.Replaced bySslContextBuilderCreates a new server-sideSslContext.- Parameters:
- provider- the- SslContextimplementation to use.- nullto use the current default one.
- certChainFile- an X.509 certificate chain file in PEM format
- keyFile- a PKCS#8 private key file in PEM format
- keyPassword- the password of the- keyFile.- nullif it's not password-protected.
- trustManagerFactory- the- TrustManagerFactorythat provides the- TrustManagers 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:
- javax.net.ssl.SSLException
 
 - 
newServerContext@Deprecated public static SslContext newServerContext(SslProvider provider, java.io.File certChainFile, java.io.File keyFile, java.lang.String keyPassword, java.lang.Iterable<java.lang.String> ciphers, CipherSuiteFilter cipherFilter, ApplicationProtocolConfig apn, long sessionCacheSize, long sessionTimeout) throws javax.net.ssl.SSLException Deprecated.Replaced bySslContextBuilderCreates a new server-sideSslContext.- Parameters:
- provider- the- SslContextimplementation to use.- nullto use the current default one.
- certChainFile- an X.509 certificate chain file in PEM format
- keyFile- a PKCS#8 private key file in PEM format
- keyPassword- the password of the- keyFile.- 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 if- provideris- SslProvider.JDK
- apn- 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:
- javax.net.ssl.SSLException
 
 - 
newServerContext@Deprecated public static SslContext newServerContext(SslProvider provider, java.io.File trustCertCollectionFile, javax.net.ssl.TrustManagerFactory trustManagerFactory, java.io.File keyCertChainFile, java.io.File keyFile, java.lang.String keyPassword, javax.net.ssl.KeyManagerFactory keyManagerFactory, java.lang.Iterable<java.lang.String> ciphers, CipherSuiteFilter cipherFilter, ApplicationProtocolConfig apn, long sessionCacheSize, long sessionTimeout) throws javax.net.ssl.SSLException Deprecated.Replaced bySslContextBuilderCreates a new server-sideSslContext.- Parameters:
- provider- the- SslContextimplementation 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 default
- trustManagerFactory- the- TrustManagerFactorythat provides the- TrustManagers that verifies the certificates sent from clients.- nullto use the default or the results of parsing- trustCertCollectionFile. This parameter is ignored if- provideris not- SslProvider.JDK.
- keyCertChainFile- an X.509 certificate chain file in PEM format
- keyFile- a PKCS#8 private key file in PEM format
- keyPassword- the password of the- keyFile.- nullif it's not password-protected.
- keyManagerFactory- the- KeyManagerFactorythat provides the- KeyManagers that is used to encrypt data being sent to clients.- nullto use the default or the results of parsing- keyCertChainFileand- keyFile. This parameter is ignored if- provideris not- SslProvider.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 if- provideris- SslProvider.JDK
- apn- 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:
- javax.net.ssl.SSLException
 
 - 
newClientContext@Deprecated public static SslContext newClientContext() throws javax.net.ssl.SSLException Deprecated.Replaced bySslContextBuilderCreates a new client-sideSslContext.- Returns:
- a new client-side SslContext
- Throws:
- javax.net.ssl.SSLException
 
 - 
newClientContext@Deprecated public static SslContext newClientContext(java.io.File certChainFile) throws javax.net.ssl.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:
- javax.net.ssl.SSLException
 
 - 
newClientContext@Deprecated public static SslContext newClientContext(javax.net.ssl.TrustManagerFactory trustManagerFactory) throws javax.net.ssl.SSLException Deprecated.Replaced bySslContextBuilderCreates a new client-sideSslContext.- Parameters:
- trustManagerFactory- the- TrustManagerFactorythat provides the- TrustManagers that verifies the certificates sent from servers.- nullto use the default.
- Returns:
- a new client-side SslContext
- Throws:
- javax.net.ssl.SSLException
 
 - 
newClientContext@Deprecated public static SslContext newClientContext(java.io.File certChainFile, javax.net.ssl.TrustManagerFactory trustManagerFactory) throws javax.net.ssl.SSLException Deprecated.Replaced bySslContextBuilderCreates a new client-sideSslContext.- Parameters:
- certChainFile- an X.509 certificate chain file in PEM format.- nullto use the system default
- trustManagerFactory- the- TrustManagerFactorythat provides the- TrustManagers that verifies the certificates sent from servers.- nullto use the default.
- Returns:
- a new client-side SslContext
- Throws:
- javax.net.ssl.SSLException
 
 - 
newClientContext@Deprecated public static SslContext newClientContext(java.io.File certChainFile, javax.net.ssl.TrustManagerFactory trustManagerFactory, java.lang.Iterable<java.lang.String> ciphers, java.lang.Iterable<java.lang.String> nextProtocols, long sessionCacheSize, long sessionTimeout) throws javax.net.ssl.SSLException Deprecated.Replaced bySslContextBuilderCreates a new client-sideSslContext.- Parameters:
- certChainFile- an X.509 certificate chain file in PEM format.- nullto use the system default
- trustManagerFactory- the- TrustManagerFactorythat provides the- TrustManagers 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:
- javax.net.ssl.SSLException
 
 - 
newClientContext@Deprecated public static SslContext newClientContext(java.io.File certChainFile, javax.net.ssl.TrustManagerFactory trustManagerFactory, java.lang.Iterable<java.lang.String> ciphers, CipherSuiteFilter cipherFilter, ApplicationProtocolConfig apn, long sessionCacheSize, long sessionTimeout) throws javax.net.ssl.SSLException Deprecated.Replaced bySslContextBuilderCreates a new client-sideSslContext.- Parameters:
- certChainFile- an X.509 certificate chain file in PEM format.- nullto use the system default
- trustManagerFactory- the- TrustManagerFactorythat provides the- TrustManagers 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 ciphers
- apn- 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:
- javax.net.ssl.SSLException
 
 - 
newClientContext@Deprecated public static SslContext newClientContext(SslProvider provider) throws javax.net.ssl.SSLException Deprecated.Replaced bySslContextBuilderCreates a new client-sideSslContext.- Parameters:
- provider- the- SslContextimplementation to use.- nullto use the current default one.
- Returns:
- a new client-side SslContext
- Throws:
- javax.net.ssl.SSLException
 
 - 
newClientContext@Deprecated public static SslContext newClientContext(SslProvider provider, java.io.File certChainFile) throws javax.net.ssl.SSLException Deprecated.Replaced bySslContextBuilderCreates a new client-sideSslContext.- Parameters:
- provider- the- SslContextimplementation 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:
- javax.net.ssl.SSLException
 
 - 
newClientContext@Deprecated public static SslContext newClientContext(SslProvider provider, javax.net.ssl.TrustManagerFactory trustManagerFactory) throws javax.net.ssl.SSLException Deprecated.Replaced bySslContextBuilderCreates a new client-sideSslContext.- Parameters:
- provider- the- SslContextimplementation to use.- nullto use the current default one.
- trustManagerFactory- the- TrustManagerFactorythat provides the- TrustManagers that verifies the certificates sent from servers.- nullto use the default.
- Returns:
- a new client-side SslContext
- Throws:
- javax.net.ssl.SSLException
 
 - 
newClientContext@Deprecated public static SslContext newClientContext(SslProvider provider, java.io.File certChainFile, javax.net.ssl.TrustManagerFactory trustManagerFactory) throws javax.net.ssl.SSLException Deprecated.Replaced bySslContextBuilderCreates a new client-sideSslContext.- Parameters:
- provider- the- SslContextimplementation to use.- nullto use the current default one.
- certChainFile- an X.509 certificate chain file in PEM format.- nullto use the system default
- trustManagerFactory- the- TrustManagerFactorythat provides the- TrustManagers that verifies the certificates sent from servers.- nullto use the default.
- Returns:
- a new client-side SslContext
- Throws:
- javax.net.ssl.SSLException
 
 - 
newClientContext@Deprecated public static SslContext newClientContext(SslProvider provider, java.io.File certChainFile, javax.net.ssl.TrustManagerFactory trustManagerFactory, java.lang.Iterable<java.lang.String> ciphers, java.lang.Iterable<java.lang.String> nextProtocols, long sessionCacheSize, long sessionTimeout) throws javax.net.ssl.SSLException Deprecated.Replaced bySslContextBuilderCreates a new client-sideSslContext.- Parameters:
- provider- the- SslContextimplementation to use.- nullto use the current default one.
- certChainFile- an X.509 certificate chain file in PEM format.- nullto use the system default
- trustManagerFactory- the- TrustManagerFactorythat provides the- TrustManagers 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:
- javax.net.ssl.SSLException
 
 - 
newClientContext@Deprecated public static SslContext newClientContext(SslProvider provider, java.io.File certChainFile, javax.net.ssl.TrustManagerFactory trustManagerFactory, java.lang.Iterable<java.lang.String> ciphers, CipherSuiteFilter cipherFilter, ApplicationProtocolConfig apn, long sessionCacheSize, long sessionTimeout) throws javax.net.ssl.SSLException Deprecated.Replaced bySslContextBuilderCreates a new client-sideSslContext.- Parameters:
- provider- the- SslContextimplementation to use.- nullto use the current default one.
- certChainFile- an X.509 certificate chain file in PEM format.- nullto use the system default
- trustManagerFactory- the- TrustManagerFactorythat provides the- TrustManagers 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 ciphers
- apn- 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:
- javax.net.ssl.SSLException
 
 - 
newClientContext@Deprecated public static SslContext newClientContext(SslProvider provider, java.io.File trustCertCollectionFile, javax.net.ssl.TrustManagerFactory trustManagerFactory, java.io.File keyCertChainFile, java.io.File keyFile, java.lang.String keyPassword, javax.net.ssl.KeyManagerFactory keyManagerFactory, java.lang.Iterable<java.lang.String> ciphers, CipherSuiteFilter cipherFilter, ApplicationProtocolConfig apn, long sessionCacheSize, long sessionTimeout) throws javax.net.ssl.SSLException Deprecated.Replaced bySslContextBuilderCreates a new client-sideSslContext.- Parameters:
- provider- the- SslContextimplementation to use.- nullto use the current default one.
- trustCertCollectionFile- an X.509 certificate collection file in PEM format.- nullto use the system default
- trustManagerFactory- the- TrustManagerFactorythat provides the- TrustManagers that verifies the certificates sent from servers.- nullto use the default or the results of parsing- trustCertCollectionFile. This parameter is ignored if- provideris not- SslProvider.JDK.
- keyCertChainFile- an X.509 certificate chain file in PEM format. This provides the public key for mutual authentication.- nullto use the system default
- keyFile- 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 the- keyFile.- nullif it's not password-protected. Ignored if- keyFileis- null.
- keyManagerFactory- the- KeyManagerFactorythat provides the- KeyManagers that is used to encrypt data being sent to servers.- nullto use the default or the results of parsing- keyCertChainFileand- keyFile. This parameter is ignored if- provideris not- SslProvider.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
- apn- 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:
- javax.net.ssl.SSLException
 
 - 
attributespublic final AttributeMap attributes() Returns theAttributeMapthat belongs to thisSslContext.
 - 
isServerpublic final boolean isServer() Returnstrueif and only if this context is for server-side.
 - 
isClientpublic abstract boolean isClient() Returns thetrueif and only if this context is for client-side.
 - 
cipherSuitespublic abstract java.util.List<java.lang.String> cipherSuites() Returns the list of enabled cipher suites, in the order of preference.
 - 
sessionCacheSizepublic long sessionCacheSize() Returns the size of the cache used for storing SSL session objects.
 - 
sessionTimeoutpublic long sessionTimeout() Returns the timeout for the cached SSL session objects, in seconds.
 - 
nextProtocols@Deprecated public final java.util.List<java.lang.String> nextProtocols() Deprecated.UseapplicationProtocolNegotiator()instead.
 - 
applicationProtocolNegotiatorpublic abstract ApplicationProtocolNegotiator applicationProtocolNegotiator() Returns the object responsible for negotiating application layer protocols for the TLS NPN/ALPN extensions.
 - 
newEnginepublic abstract javax.net.ssl.SSLEngine newEngine(ByteBufAllocator 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(ByteBufAllocator).- Returns:
- a new SSLEngine
 
 - 
newEnginepublic abstract javax.net.ssl.SSLEngine newEngine(ByteBufAllocator alloc, java.lang.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(ByteBufAllocator, String, int).- Parameters:
- peerHost- the non-authoritative name of the host
- peerPort- the non-authoritative port
- Returns:
- a new SSLEngine
 
 - 
sessionContextpublic abstract javax.net.ssl.SSLSessionContext sessionContext() Returns theSSLSessionContextobject held by this context.
 - 
newHandlerpublic final SslHandler newHandler(ByteBufAllocator alloc) Create a new SslHandler.- See Also:
- newHandler(ByteBufAllocator, Executor)
 
 - 
newHandlerprotected SslHandler newHandler(ByteBufAllocator alloc, boolean startTls) Create a new SslHandler.- See Also:
- newHandler(ByteBufAllocator)
 
 - 
newHandlerpublic SslHandler newHandler(ByteBufAllocator alloc, java.util.concurrent.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 ByteBuf objects.
- delegatedTaskExecutor- the- Executorthat will be used to execute tasks that are returned by- SSLEngine.getDelegatedTask().
- Returns:
- a new SslHandler
 
 - 
newHandlerprotected SslHandler newHandler(ByteBufAllocator alloc, boolean startTls, java.util.concurrent.Executor executor) Create a new SslHandler.
 - 
newHandlerpublic final SslHandler newHandler(ByteBufAllocator alloc, java.lang.String peerHost, int peerPort) Creates a newSslHandler
 - 
newHandlerprotected SslHandler newHandler(ByteBufAllocator alloc, java.lang.String peerHost, int peerPort, boolean startTls) Create a new SslHandler.
 - 
newHandlerpublic SslHandler newHandler(ByteBufAllocator alloc, java.lang.String peerHost, int peerPort, java.util.concurrent.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 ByteBuf objects.
- peerHost- the non-authoritative name of the host
- peerPort- the non-authoritative port
- delegatedTaskExecutor- the- Executorthat will be used to execute tasks that are returned by- SSLEngine.getDelegatedTask().
- Returns:
- a new SslHandler
 
 - 
newHandlerprotected SslHandler newHandler(ByteBufAllocator alloc, java.lang.String peerHost, int peerPort, boolean startTls, java.util.concurrent.Executor delegatedTaskExecutor) 
 - 
generateKeySpec@Deprecated protected static java.security.spec.PKCS8EncodedKeySpec generateKeySpec(char[] password, byte[] key) throws java.io.IOException, java.security.NoSuchAlgorithmException, javax.crypto.NoSuchPaddingException, java.security.spec.InvalidKeySpecException, java.security.InvalidKeyException, java.security.InvalidAlgorithmParameterExceptionDeprecated.Generates a key specification for an (encrypted) private key.- Parameters:
- password- characters, if- nullan unencrypted key is assumed
- key- bytes of the DER encoded private key
- Returns:
- a key specification
- Throws:
- java.io.IOException- if parsing- keyfails
- java.security.NoSuchAlgorithmException- if the algorithm used to encrypt- keyis unknown
- javax.crypto.NoSuchPaddingException- if the padding scheme specified in the decryption algorithm is unknown
- java.security.spec.InvalidKeySpecException- if the decryption key based on- passwordcannot be generated
- java.security.InvalidKeyException- if the decryption key based on- passwordcannot be used to decrypt- key
- java.security.InvalidAlgorithmParameterException- if decryption algorithm parameters are somehow faulty
 
 - 
buildKeyStoreprotected static java.security.KeyStore buildKeyStore(java.security.cert.X509Certificate[] certChain, java.security.PrivateKey key, char[] keyPasswordChars, java.lang.String keyStoreType) throws java.security.KeyStoreException, java.security.NoSuchAlgorithmException, java.security.cert.CertificateException, java.io.IOExceptionGenerates a newKeyStore.- Parameters:
- certChain- an X.509 certificate chain
- key- a PKCS#8 private key
- keyPasswordChars- the password of the- keyFile.- nullif it's not password-protected.
- keyStoreType- The KeyStore Type you want to use
- Returns:
- generated KeyStore.
- Throws:
- java.security.KeyStoreException
- java.security.NoSuchAlgorithmException
- java.security.cert.CertificateException
- java.io.IOException
 
 - 
toPrivateKeyprotected static java.security.PrivateKey toPrivateKey(java.io.File keyFile, java.lang.String keyPassword) throws java.security.NoSuchAlgorithmException, javax.crypto.NoSuchPaddingException, java.security.spec.InvalidKeySpecException, java.security.InvalidAlgorithmParameterException, java.security.KeyException, java.io.IOException- Throws:
- java.security.NoSuchAlgorithmException
- javax.crypto.NoSuchPaddingException
- java.security.spec.InvalidKeySpecException
- java.security.InvalidAlgorithmParameterException
- java.security.KeyException
- java.io.IOException
 
 - 
toPrivateKeyprotected static java.security.PrivateKey toPrivateKey(java.io.InputStream keyInputStream, java.lang.String keyPassword) throws java.security.NoSuchAlgorithmException, javax.crypto.NoSuchPaddingException, java.security.spec.InvalidKeySpecException, java.security.InvalidAlgorithmParameterException, java.security.KeyException, java.io.IOException- Throws:
- java.security.NoSuchAlgorithmException
- javax.crypto.NoSuchPaddingException
- java.security.spec.InvalidKeySpecException
- java.security.InvalidAlgorithmParameterException
- java.security.KeyException
- java.io.IOException
 
 - 
buildTrustManagerFactory@Deprecated protected static javax.net.ssl.TrustManagerFactory buildTrustManagerFactory(java.io.File certChainFile, javax.net.ssl.TrustManagerFactory trustManagerFactory) throws java.security.NoSuchAlgorithmException, java.security.cert.CertificateException, java.security.KeyStoreException, java.io.IOExceptionDeprecated.Build aTrustManagerFactoryfrom a certificate chain file.- Parameters:
- certChainFile- The certificate file to build from.
- trustManagerFactory- The existing- TrustManagerFactorythat will be used if not- null.
- Returns:
- A TrustManagerFactorywhich contains the certificates incertChainFile
- Throws:
- java.security.NoSuchAlgorithmException
- java.security.cert.CertificateException
- java.security.KeyStoreException
- java.io.IOException
 
 - 
buildTrustManagerFactoryprotected static javax.net.ssl.TrustManagerFactory buildTrustManagerFactory(java.io.File certChainFile, javax.net.ssl.TrustManagerFactory trustManagerFactory, java.lang.String keyType) throws java.security.NoSuchAlgorithmException, java.security.cert.CertificateException, java.security.KeyStoreException, java.io.IOExceptionBuild aTrustManagerFactoryfrom a certificate chain file.- Parameters:
- certChainFile- The certificate file to build from.
- trustManagerFactory- The existing- TrustManagerFactorythat will be used if not- null.
- keyType- The KeyStore Type you want to use
- Returns:
- A TrustManagerFactorywhich contains the certificates incertChainFile
- Throws:
- java.security.NoSuchAlgorithmException
- java.security.cert.CertificateException
- java.security.KeyStoreException
- java.io.IOException
 
 - 
toX509Certificatesprotected static java.security.cert.X509Certificate[] toX509Certificates(java.io.File file) throws java.security.cert.CertificateException- Throws:
- java.security.cert.CertificateException
 
 - 
toX509Certificatesprotected static java.security.cert.X509Certificate[] toX509Certificates(java.io.InputStream in) throws java.security.cert.CertificateException- Throws:
- java.security.cert.CertificateException
 
 - 
buildTrustManagerFactoryprotected static javax.net.ssl.TrustManagerFactory buildTrustManagerFactory(java.security.cert.X509Certificate[] certCollection, javax.net.ssl.TrustManagerFactory trustManagerFactory, java.lang.String keyStoreType) throws java.security.NoSuchAlgorithmException, java.security.cert.CertificateException, java.security.KeyStoreException, java.io.IOException- Throws:
- java.security.NoSuchAlgorithmException
- java.security.cert.CertificateException
- java.security.KeyStoreException
- java.io.IOException
 
 - 
buildKeyManagerFactoryprotected static javax.net.ssl.KeyManagerFactory buildKeyManagerFactory(java.security.cert.X509Certificate[] certChainFile, java.lang.String keyAlgorithm, java.security.PrivateKey key, java.lang.String keyPassword, javax.net.ssl.KeyManagerFactory kmf, java.lang.String keyStore) throws java.security.KeyStoreException, java.security.NoSuchAlgorithmException, java.io.IOException, java.security.cert.CertificateException, java.security.UnrecoverableKeyException- Throws:
- java.security.KeyStoreException
- java.security.NoSuchAlgorithmException
- java.io.IOException
- java.security.cert.CertificateException
- java.security.UnrecoverableKeyException
 
 
- 
 
-