Package org.jboss.netty.handler.ssl
Class SslContext
- java.lang.Object
-
- org.jboss.netty.handler.ssl.SslContext
-
- Direct Known Subclasses:
JdkSslContext,OpenSslServerContext
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
ChannelPipelineFactory:ChannelPipelinep =Channels.pipeline();SslContextsslCtx =SslContext.newServerContext(...); p.addLast("ssl",sslCtx.newEngine()); ...Making your client support SSL/TLS
// In your
ChannelPipelineFactory:ChannelPipelinep =Channels.pipeline();SslContextsslCtx =SslContext.newClientContext(...); p.addLast("ssl",sslCtx.newEngine(host, port)); ...
-
-
Field Summary
Fields Modifier and Type Field Description private SslBufferPoolbufferPool
-
Constructor Summary
Constructors Constructor Description SslContext(SslBufferPool bufferPool)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description SslBufferPoolbufferPool()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.abstract booleanisClient()Returns thetrueif and only if this context is for client-side.booleanisServer()Returnstrueif and only if this context is for server-side.(package private) SslBufferPoolnewBufferPool()static SslContextnewClientContext()Creates a new client-sideSslContext.static SslContextnewClientContext(java.io.File certChainFile)Creates a new client-sideSslContext.static SslContextnewClientContext(java.io.File certChainFile, javax.net.ssl.TrustManagerFactory trustManagerFactory)Creates a new client-sideSslContext.static SslContextnewClientContext(javax.net.ssl.TrustManagerFactory trustManagerFactory)Creates a new client-sideSslContext.static SslContextnewClientContext(SslBufferPool bufPool, 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)Creates a new client-sideSslContext.static SslContextnewClientContext(SslProvider provider)Creates a new client-sideSslContext.static SslContextnewClientContext(SslProvider provider, java.io.File certChainFile)Creates a new client-sideSslContext.static SslContextnewClientContext(SslProvider provider, java.io.File certChainFile, javax.net.ssl.TrustManagerFactory trustManagerFactory)Creates a new client-sideSslContext.static SslContextnewClientContext(SslProvider provider, javax.net.ssl.TrustManagerFactory trustManagerFactory)Creates a new client-sideSslContext.static SslContextnewClientContext(SslProvider provider, SslBufferPool bufPool, 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)Creates a new client-sideSslContext.abstract javax.net.ssl.SSLEnginenewEngine()Creates a newSSLEngine.abstract javax.net.ssl.SSLEnginenewEngine(java.lang.String peerHost, int peerPort)Creates a newSSLEngineusing advisory peer information.SslHandlernewHandler()Creates a newSslHandler.SslHandlernewHandler(java.lang.String peerHost, int peerPort)Creates a newSslHandlerwith advisory peer information.private SslHandlernewHandler(javax.net.ssl.SSLEngine engine)static SslContextnewServerContext(java.io.File certChainFile, java.io.File keyFile)Creates a new server-sideSslContext.static SslContextnewServerContext(java.io.File certChainFile, java.io.File keyFile, java.lang.String keyPassword)Creates a new server-sideSslContext.static SslContextnewServerContext(SslBufferPool bufPool, 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)Creates a new server-sideSslContext.static SslContextnewServerContext(SslProvider provider, java.io.File certChainFile, java.io.File keyFile)Creates a new server-sideSslContext.static SslContextnewServerContext(SslProvider provider, java.io.File certChainFile, java.io.File keyFile, java.lang.String keyPassword)Creates a new server-sideSslContext.static SslContextnewServerContext(SslProvider provider, SslBufferPool bufPool, 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)Creates a new server-sideSslContext.abstract java.util.List<java.lang.String>nextProtocols()Returns the list of application layer protocols for the TLS NPN/ALPN extension, in the order of preference.abstract longsessionCacheSize()Returns the size of the cache used for storing SSL session objects.abstract longsessionTimeout()Returns the timeout for the cached SSL session objects, in seconds.
-
-
-
Field Detail
-
bufferPool
private final SslBufferPool bufferPool
-
-
Constructor Detail
-
SslContext
SslContext(SslBufferPool bufferPool)
-
-
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.JDK, because it is the only implementation at the moment
-
newServerContext
public static SslContext newServerContext(java.io.File certChainFile, java.io.File keyFile) throws javax.net.ssl.SSLException
Creates 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:
javax.net.ssl.SSLException
-
newServerContext
public static SslContext newServerContext(java.io.File certChainFile, java.io.File keyFile, java.lang.String keyPassword) throws javax.net.ssl.SSLException
Creates 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:
javax.net.ssl.SSLException
-
newServerContext
public static SslContext newServerContext(SslBufferPool bufPool, 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
Creates a new server-sideSslContext.- Parameters:
bufPool- the buffer pool which will be used by the returnedSslContext.nullto use the default buffer pool.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:
javax.net.ssl.SSLException
-
newServerContext
public static SslContext newServerContext(SslProvider provider, java.io.File certChainFile, java.io.File keyFile) throws javax.net.ssl.SSLException
Creates 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:
javax.net.ssl.SSLException
-
newServerContext
public static SslContext newServerContext(SslProvider provider, java.io.File certChainFile, java.io.File keyFile, java.lang.String keyPassword) throws javax.net.ssl.SSLException
Creates 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:
javax.net.ssl.SSLException
-
newServerContext
public static SslContext newServerContext(SslProvider provider, SslBufferPool bufPool, 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
Creates a new server-sideSslContext.- Parameters:
provider- theSslContextimplementation to use.nullto use the current default one.bufPool- the buffer pool which will be used by the returnedSslContext.nullto use the default buffer pool.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:
javax.net.ssl.SSLException
-
newClientContext
public static SslContext newClientContext() throws javax.net.ssl.SSLException
Creates a new client-sideSslContext.- Returns:
- a new client-side
SslContext - Throws:
javax.net.ssl.SSLException
-
newClientContext
public static SslContext newClientContext(java.io.File certChainFile) throws javax.net.ssl.SSLException
Creates 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
public static SslContext newClientContext(javax.net.ssl.TrustManagerFactory trustManagerFactory) throws javax.net.ssl.SSLException
Creates 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:
javax.net.ssl.SSLException
-
newClientContext
public static SslContext newClientContext(java.io.File certChainFile, javax.net.ssl.TrustManagerFactory trustManagerFactory) throws javax.net.ssl.SSLException
Creates 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:
javax.net.ssl.SSLException
-
newClientContext
public static SslContext newClientContext(SslBufferPool bufPool, 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
Creates a new client-sideSslContext.- Parameters:
bufPool- the buffer pool which will be used by the returnedSslContext.nullto use the default buffer pool.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:
javax.net.ssl.SSLException
-
newClientContext
public static SslContext newClientContext(SslProvider provider) throws javax.net.ssl.SSLException
Creates a new client-sideSslContext.- Parameters:
provider- theSslContextimplementation to use.nullto use the current default one.- Returns:
- a new client-side
SslContext - Throws:
javax.net.ssl.SSLException
-
newClientContext
public static SslContext newClientContext(SslProvider provider, java.io.File certChainFile) throws javax.net.ssl.SSLException
Creates 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:
javax.net.ssl.SSLException
-
newClientContext
public static SslContext newClientContext(SslProvider provider, javax.net.ssl.TrustManagerFactory trustManagerFactory) throws javax.net.ssl.SSLException
Creates 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:
javax.net.ssl.SSLException
-
newClientContext
public static SslContext newClientContext(SslProvider provider, java.io.File certChainFile, javax.net.ssl.TrustManagerFactory trustManagerFactory) throws javax.net.ssl.SSLException
Creates 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:
javax.net.ssl.SSLException
-
newClientContext
public static SslContext newClientContext(SslProvider provider, SslBufferPool bufPool, 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
Creates a new client-sideSslContext.- Parameters:
provider- theSslContextimplementation to use.nullto use the current default one.bufPool- the buffer pool which will be used by the returnedSslContext.nullto use the default buffer pool.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:
javax.net.ssl.SSLException
-
newBufferPool
SslBufferPool newBufferPool()
-
isServer
public final boolean isServer()
Returnstrueif and only if this context is for server-side.
-
bufferPool
public final SslBufferPool bufferPool()
-
isClient
public abstract boolean isClient()
Returns thetrueif and only if this context is for client-side.
-
cipherSuites
public abstract java.util.List<java.lang.String> cipherSuites()
Returns the list of enabled cipher suites, in the order of preference.
-
sessionCacheSize
public abstract long sessionCacheSize()
Returns the size of the cache used for storing SSL session objects.
-
sessionTimeout
public abstract long sessionTimeout()
Returns the timeout for the cached SSL session objects, in seconds.
-
nextProtocols
public abstract java.util.List<java.lang.String> nextProtocols()
Returns the list of application layer protocols for the TLS NPN/ALPN extension, in the order of preference.- Returns:
- the list of application layer protocols.
nullif NPN/ALPN extension has been disabled.
-
newEngine
public abstract javax.net.ssl.SSLEngine newEngine()
Creates a newSSLEngine.- Returns:
- a new
SSLEngine
-
newEngine
public abstract javax.net.ssl.SSLEngine newEngine(java.lang.String peerHost, int peerPort)Creates a newSSLEngineusing advisory peer information.- Parameters:
peerHost- the non-authoritative name of the hostpeerPort- the non-authoritative port- Returns:
- a new
SSLEngine
-
newHandler
public final SslHandler newHandler()
Creates a newSslHandler.- Returns:
- a new
SslHandler
-
newHandler
public final SslHandler newHandler(java.lang.String peerHost, int peerPort)
Creates a newSslHandlerwith advisory peer information.- Parameters:
peerHost- the non-authoritative name of the hostpeerPort- the non-authoritative port- Returns:
- a new
SslHandler
-
newHandler
private SslHandler newHandler(javax.net.ssl.SSLEngine engine)
-
-