Class JdkSslContext
java.lang.Object
io.netty.handler.ssl.SslContext
io.netty.handler.ssl.JdkSslContext
- Direct Known Subclasses:
JdkSslClientContext, JdkSslServerContext
An
SslContext which uses JDK's SSL/TLS implementation.-
Constructor Summary
ConstructorsConstructorDescriptionJdkSslContext(SSLContext sslContext, boolean isClient, ClientAuth clientAuth) Deprecated.JdkSslContext(SSLContext sslContext, boolean isClient, Iterable<String> ciphers, CipherSuiteFilter cipherFilter, ApplicationProtocolConfig apn, ClientAuth clientAuth) JdkSslContext(SSLContext sslContext, boolean isClient, Iterable<String> ciphers, CipherSuiteFilter cipherFilter, ApplicationProtocolConfig apn, ClientAuth clientAuth, String[] protocols, boolean startTls) Creates a newJdkSslContextfrom a pre-configuredSSLContext. -
Method Summary
Modifier and TypeMethodDescriptionReturns the object responsible for negotiating application layer protocols for the TLS NPN/ALPN extensions.protected static KeyManagerFactorybuildKeyManagerFactory(File certChainFile, File keyFile, String keyPassword, KeyManagerFactory kmf) Deprecated.will be removed.protected static KeyManagerFactorybuildKeyManagerFactory(File certChainFile, String keyAlgorithm, File keyFile, String keyPassword, KeyManagerFactory kmf) Deprecated.will be removed.Returns the list of enabled cipher suites, in the order of preference.final SSLContextcontext()Returns the JDKSSLContextobject held by this context.final booleanisClient()Returns thetrueif and only if this context is for client-side.final SSLEnginenewEngine(ByteBufAllocator alloc) Creates a newSSLEngine.final SSLEnginenewEngine(ByteBufAllocator alloc, String peerHost, int peerPort) Creates a newSSLEngineusing advisory peer information.final SSLSessionContextReturns the JDKSSLSessionContextobject held by this context.Methods inherited from class SslContext
attributes, buildKeyManagerFactory, buildKeyStore, buildTrustManagerFactory, buildTrustManagerFactory, buildTrustManagerFactory, defaultClientProvider, defaultServerProvider, generateKeySpec, isServer, newClientContext, newClientContext, newClientContext, newClientContext, newClientContext, newClientContext, newClientContext, newClientContext, newClientContext, newClientContext, newClientContext, newClientContext, newClientContext, newHandler, newHandler, newHandler, newHandler, newHandler, newHandler, newHandler, newHandler, newServerContext, newServerContext, newServerContext, newServerContext, newServerContext, newServerContext, newServerContext, newServerContext, newServerContext, newServerContext, nextProtocols, sessionCacheSize, sessionTimeout, toPrivateKey, toPrivateKey, toX509Certificates, toX509CertificatesModifier and TypeMethodDescriptionfinal AttributeMapReturns 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) static SslProviderReturns the default client-side implementation provider currently in use.static SslProviderReturns the default server-side implementation provider currently in use.protected static PKCS8EncodedKeySpecgenerateKeySpec(char[] password, byte[] key) Deprecated.final booleanisServer()Returnstrueif and only if this context is for server-side.static SslContextDeprecated.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 bySslContextBuilderfinal SslHandlernewHandler(ByteBufAllocator alloc) Create a new SslHandler.protected SslHandlernewHandler(ByteBufAllocator alloc, boolean startTls) Create a new SslHandler.protected SslHandlernewHandler(ByteBufAllocator alloc, boolean startTls, Executor executor) Create a new SslHandler.final SslHandlernewHandler(ByteBufAllocator alloc, String peerHost, int peerPort) Creates a newSslHandlerprotected SslHandlernewHandler(ByteBufAllocator alloc, String peerHost, int peerPort, boolean startTls) Create a new SslHandler.protected SslHandlernewHandler(ByteBufAllocator alloc, String peerHost, int peerPort, boolean startTls, Executor delegatedTaskExecutor) newHandler(ByteBufAllocator alloc, String peerHost, int peerPort, Executor delegatedTaskExecutor) Creates a newSslHandlerwith advisory peer information.newHandler(ByteBufAllocator 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 bySslContextBuilderDeprecated.UseSslContext.applicationProtocolNegotiator()instead.longReturns the size of the cache used for storing SSL session objects.longReturns 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[]
-
Constructor Details
-
JdkSslContext
Deprecated.Creates a newJdkSslContextfrom a pre-configuredSSLContext.- Parameters:
sslContext- theSSLContextto use.isClient-trueif this context should createSSLEngines for client-side usage.clientAuth- theClientAuthto use. This will only be used when isfalse.
-
JdkSslContext
@Deprecated public JdkSslContext(SSLContext sslContext, boolean isClient, Iterable<String> ciphers, CipherSuiteFilter cipherFilter, ApplicationProtocolConfig apn, ClientAuth clientAuth) Deprecated.Creates a newJdkSslContextfrom a pre-configuredSSLContext.- Parameters:
sslContext- theSSLContextto use.isClient-trueif this context should createSSLEngines for client-side usage.ciphers- the ciphers to use ornullif the standard should be used.cipherFilter- the filter to use.apn- theApplicationProtocolConfigto use.clientAuth- theClientAuthto use. This will only be used when isfalse.
-
JdkSslContext
public JdkSslContext(SSLContext sslContext, boolean isClient, Iterable<String> ciphers, CipherSuiteFilter cipherFilter, ApplicationProtocolConfig apn, ClientAuth clientAuth, String[] protocols, boolean startTls) Creates a newJdkSslContextfrom a pre-configuredSSLContext.- Parameters:
sslContext- theSSLContextto use.isClient-trueif this context should createSSLEngines for client-side usage.ciphers- the ciphers to use ornullif the standard should be used.cipherFilter- the filter to use.apn- theApplicationProtocolConfigto use.clientAuth- theClientAuthto use. This will only be used when isfalse.protocols- the protocols to enable, ornullto enable the default protocols.startTls-trueif the first write request shouldn't be encrypted
-
-
Method Details
-
context
Returns the JDKSSLContextobject held by this context. -
isClient
public final boolean isClient()Description copied from class:SslContextReturns thetrueif and only if this context is for client-side.- Specified by:
isClientin classSslContext
-
sessionContext
Returns the JDKSSLSessionContextobject held by this context.- Specified by:
sessionContextin classSslContext
-
cipherSuites
Description copied from class:SslContextReturns the list of enabled cipher suites, in the order of preference.- Specified by:
cipherSuitesin classSslContext
-
newEngine
Description copied from class:SslContextCreates 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. SeeSslContext.newHandler(ByteBufAllocator).- Specified by:
newEnginein classSslContext- Returns:
- a new
SSLEngine
-
newEngine
Description copied from class:SslContextCreates 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. SeeSslContext.newHandler(ByteBufAllocator, String, int).- Specified by:
newEnginein classSslContext- Parameters:
peerHost- the non-authoritative name of the hostpeerPort- the non-authoritative port- Returns:
- a new
SSLEngine
-
applicationProtocolNegotiator
Description copied from class:SslContextReturns the object responsible for negotiating application layer protocols for the TLS NPN/ALPN extensions.- Specified by:
applicationProtocolNegotiatorin classSslContext
-
buildKeyManagerFactory
@Deprecated protected static KeyManagerFactory buildKeyManagerFactory(File certChainFile, File keyFile, String keyPassword, KeyManagerFactory kmf) throws UnrecoverableKeyException, KeyStoreException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeySpecException, InvalidAlgorithmParameterException, CertificateException, KeyException, IOException Deprecated.will be removed.Build aKeyManagerFactorybased upon a key file, key file password, and a certificate chain.- 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.kmf- The existingKeyManagerFactorythat will be used if notnull- Returns:
- A
KeyManagerFactorybased upon a key file, key file password, and a certificate chain. - Throws:
UnrecoverableKeyExceptionKeyStoreExceptionNoSuchAlgorithmExceptionNoSuchPaddingExceptionInvalidKeySpecExceptionInvalidAlgorithmParameterExceptionCertificateExceptionKeyExceptionIOException
-
buildKeyManagerFactory
@Deprecated protected static KeyManagerFactory buildKeyManagerFactory(File certChainFile, String keyAlgorithm, File keyFile, String keyPassword, KeyManagerFactory kmf) throws KeyStoreException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeySpecException, InvalidAlgorithmParameterException, IOException, CertificateException, KeyException, UnrecoverableKeyException Deprecated.will be removed.Build aKeyManagerFactorybased upon a key algorithm, key file, key file password, and a certificate chain.- Parameters:
certChainFile- an buildKeyManagerFactory X.509 certificate chain file in PEM formatkeyAlgorithm- the standard name of the requested algorithm. See the Java Secure Socket Extension Reference Guide for information about standard algorithm names.keyFile- a PKCS#8 private key file in PEM formatkeyPassword- the password of thekeyFile.nullif it's not password-protected.kmf- The existingKeyManagerFactorythat will be used if notnull- Returns:
- A
KeyManagerFactorybased upon a key algorithm, key file, key file password, and a certificate chain. - Throws:
KeyStoreExceptionNoSuchAlgorithmExceptionNoSuchPaddingExceptionInvalidKeySpecExceptionInvalidAlgorithmParameterExceptionIOExceptionCertificateExceptionKeyExceptionUnrecoverableKeyException
-
JdkSslContext(SSLContext, boolean, Iterable, CipherSuiteFilter, ApplicationProtocolConfig, ClientAuth, String[], boolean)