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.-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final JdkApplicationProtocolNegotiatorprivate final java.lang.String[]private final ClientAuthprivate static final java.util.List<java.lang.String> private static final java.util.List<java.lang.String> private static final java.lang.String[]private static final java.security.Providerprivate final java.lang.Stringprivate final booleanprivate static final InternalLogger(package private) static final java.lang.Stringprivate final java.lang.String[]private final java.util.List<javax.net.ssl.SNIServerName> private final javax.net.ssl.SSLContextprivate static final java.util.Set<java.lang.String> private static final java.util.Set<java.lang.String> private final java.util.List<java.lang.String> Fields inherited from class SslContext
ALIAS, defaultEndpointVerificationAlgorithm, resumptionController, X509_CERT_FACTORY -
Constructor Summary
ConstructorsConstructorDescriptionJdkSslContext(javax.net.ssl.SSLContext sslContext, boolean isClient, ClientAuth clientAuth) Deprecated.JdkSslContext(javax.net.ssl.SSLContext sslContext, boolean isClient, java.lang.Iterable<java.lang.String> ciphers, CipherSuiteFilter cipherFilter, ApplicationProtocolConfig apn, ClientAuth clientAuth) JdkSslContext(javax.net.ssl.SSLContext sslContext, boolean isClient, java.lang.Iterable<java.lang.String> ciphers, CipherSuiteFilter cipherFilter, ApplicationProtocolConfig apn, ClientAuth clientAuth, java.lang.String[] protocols, boolean startTls) Creates a newJdkSslContextfrom a pre-configuredSSLContext.JdkSslContext(javax.net.ssl.SSLContext sslContext, boolean isClient, java.lang.Iterable<java.lang.String> ciphers, CipherSuiteFilter cipherFilter, JdkApplicationProtocolNegotiator apn, ClientAuth clientAuth, java.lang.String[] protocols, boolean startTls) JdkSslContext(javax.net.ssl.SSLContext sslContext, boolean isClient, java.lang.Iterable<java.lang.String> ciphers, CipherSuiteFilter cipherFilter, JdkApplicationProtocolNegotiator apn, ClientAuth clientAuth, java.lang.String[] protocols, boolean startTls, java.lang.String endpointIdentificationAlgorithm, java.util.List<javax.net.ssl.SNIServerName> serverNames, ResumptionController resumptionController) -
Method Summary
Modifier and TypeMethodDescriptionReturns the object responsible for negotiating application layer protocols for the TLS NPN/ALPN extensions.protected static javax.net.ssl.KeyManagerFactorybuildKeyManagerFactory(java.io.File certChainFile, java.io.File keyFile, java.lang.String keyPassword, javax.net.ssl.KeyManagerFactory kmf) Deprecated.will be removed.(package private) static javax.net.ssl.KeyManagerFactorybuildKeyManagerFactory(java.io.File certChainFile, java.io.File keyFile, java.lang.String keyPassword, javax.net.ssl.KeyManagerFactory kmf, java.lang.String keyStore) Build aKeyManagerFactorybased upon a key file, key file password, and a certificate chain.protected static javax.net.ssl.KeyManagerFactorybuildKeyManagerFactory(java.io.File certChainFile, java.lang.String keyAlgorithm, java.io.File keyFile, java.lang.String keyPassword, javax.net.ssl.KeyManagerFactory kmf) Deprecated.will be removed.(package private) static javax.net.ssl.KeyManagerFactorybuildKeyManagerFactory(java.io.File certChainFile, java.lang.String keyAlgorithm, java.io.File keyFile, java.lang.String keyPassword, javax.net.ssl.KeyManagerFactory kmf, java.lang.String keyStore) Build aKeyManagerFactorybased upon a key algorithm, key file, key file password, and a certificate chain.final java.util.List<java.lang.String> Returns the list of enabled cipher suites, in the order of preference.private javax.net.ssl.SSLEngineconfigureAndWrapEngine(javax.net.ssl.SSLEngine engine, ByteBufAllocator alloc) private voidconfigureSSLParameters(javax.net.ssl.SSLEngine engine) final javax.net.ssl.SSLContextcontext()Returns the JDKSSLContextobject held by this context.private static java.util.List<java.lang.String> defaultCiphers(javax.net.ssl.SSLEngine engine, java.util.Set<java.lang.String> supportedCiphers) private static java.lang.String[]defaultProtocols(javax.net.ssl.SSLContext context, javax.net.ssl.SSLEngine engine) final booleanisClient()Returns thetrueif and only if this context is for client-side.private static booleanisTlsV13Supported(java.lang.String[] protocols) final javax.net.ssl.SSLEnginenewEngine(ByteBufAllocator alloc) Creates a newSSLEngine.final javax.net.ssl.SSLEnginenewEngine(ByteBufAllocator alloc, java.lang.String peerHost, int peerPort) Creates a newSSLEngineusing advisory peer information.final javax.net.ssl.SSLSessionContextReturns the JDKSSLSessionContextobject held by this context.private static java.util.Set<java.lang.String> supportedCiphers(javax.net.ssl.SSLEngine engine) (package private) static JdkApplicationProtocolNegotiatortoNegotiator(ApplicationProtocolConfig config, boolean isServer) Translate aApplicationProtocolConfigobject to aJdkApplicationProtocolNegotiatorobject.Methods inherited from class SslContext
attributes, buildKeyManagerFactory, buildKeyManagerFactory, buildKeyStore, buildTrustManagerFactory, buildTrustManagerFactory, buildTrustManagerFactory, defaultClientProvider, defaultServerProvider, deriveSessionIdContext, generateKeySpec, isServer, keyStorePassword, newClientContext, newClientContext, newClientContext, newClientContext, newClientContext, newClientContext, newClientContext, newClientContext, newClientContext, newClientContext, newClientContext, newClientContext, newClientContext, newClientContextInternal, newClientContextInternal, newHandler, newHandler, newHandler, newHandler, newHandler, newHandler, newHandler, newHandler, newServerContext, newServerContext, newServerContext, newServerContext, newServerContext, newServerContext, newServerContext, newServerContext, newServerContext, newServerContext, newServerContext, newServerContextInternal, nextProtocols, sessionCacheSize, sessionTimeout, toApplicationProtocolConfig, toPrivateKey, toPrivateKey, toPrivateKey, toPrivateKeyInternal, toX509Certificates, toX509Certificates, toX509CertificatesInternalMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
logger
-
PROTOCOL
static final java.lang.String PROTOCOL- See Also:
-
DEFAULT_PROTOCOLS
private static final java.lang.String[] DEFAULT_PROTOCOLS -
DEFAULT_CIPHERS
private static final java.util.List<java.lang.String> DEFAULT_CIPHERS -
DEFAULT_CIPHERS_NON_TLSV13
private static final java.util.List<java.lang.String> DEFAULT_CIPHERS_NON_TLSV13 -
SUPPORTED_CIPHERS
private static final java.util.Set<java.lang.String> SUPPORTED_CIPHERS -
SUPPORTED_CIPHERS_NON_TLSV13
private static final java.util.Set<java.lang.String> SUPPORTED_CIPHERS_NON_TLSV13 -
DEFAULT_PROVIDER
private static final java.security.Provider DEFAULT_PROVIDER -
protocols
private final java.lang.String[] protocols -
cipherSuites
private final java.lang.String[] cipherSuites -
unmodifiableCipherSuites
private final java.util.List<java.lang.String> unmodifiableCipherSuites -
apn
-
clientAuth
-
sslContext
private final javax.net.ssl.SSLContext sslContext -
isClient
private final boolean isClient -
endpointIdentificationAlgorithm
private final java.lang.String endpointIdentificationAlgorithm -
serverNames
private final java.util.List<javax.net.ssl.SNIServerName> serverNames
-
-
Constructor Details
-
JdkSslContext
@Deprecated public JdkSslContext(javax.net.ssl.SSLContext sslContext, boolean isClient, ClientAuth clientAuth) 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(javax.net.ssl.SSLContext sslContext, boolean isClient, java.lang.Iterable<java.lang.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(javax.net.ssl.SSLContext sslContext, boolean isClient, java.lang.Iterable<java.lang.String> ciphers, CipherSuiteFilter cipherFilter, ApplicationProtocolConfig apn, ClientAuth clientAuth, java.lang.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
-
JdkSslContext
JdkSslContext(javax.net.ssl.SSLContext sslContext, boolean isClient, java.lang.Iterable<java.lang.String> ciphers, CipherSuiteFilter cipherFilter, JdkApplicationProtocolNegotiator apn, ClientAuth clientAuth, java.lang.String[] protocols, boolean startTls) -
JdkSslContext
JdkSslContext(javax.net.ssl.SSLContext sslContext, boolean isClient, java.lang.Iterable<java.lang.String> ciphers, CipherSuiteFilter cipherFilter, JdkApplicationProtocolNegotiator apn, ClientAuth clientAuth, java.lang.String[] protocols, boolean startTls, java.lang.String endpointIdentificationAlgorithm, java.util.List<javax.net.ssl.SNIServerName> serverNames, ResumptionController resumptionController)
-
-
Method Details
-
defaultProtocols
private static java.lang.String[] defaultProtocols(javax.net.ssl.SSLContext context, javax.net.ssl.SSLEngine engine) -
supportedCiphers
private static java.util.Set<java.lang.String> supportedCiphers(javax.net.ssl.SSLEngine engine) -
defaultCiphers
private static java.util.List<java.lang.String> defaultCiphers(javax.net.ssl.SSLEngine engine, java.util.Set<java.lang.String> supportedCiphers) -
isTlsV13Supported
private static boolean isTlsV13Supported(java.lang.String[] protocols) -
context
public final javax.net.ssl.SSLContext 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
public final javax.net.ssl.SSLSessionContext sessionContext()Returns the JDKSSLSessionContextobject held by this context.- Specified by:
sessionContextin classSslContext
-
cipherSuites
public final java.util.List<java.lang.String> 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
public final javax.net.ssl.SSLEngine newEngine(ByteBufAllocator alloc, java.lang.String peerHost, int peerPort) 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
-
configureAndWrapEngine
private javax.net.ssl.SSLEngine configureAndWrapEngine(javax.net.ssl.SSLEngine engine, ByteBufAllocator alloc) -
configureSSLParameters
private void configureSSLParameters(javax.net.ssl.SSLEngine engine) -
applicationProtocolNegotiator
Description copied from class:SslContextReturns the object responsible for negotiating application layer protocols for the TLS NPN/ALPN extensions.- Specified by:
applicationProtocolNegotiatorin classSslContext
-
toNegotiator
static JdkApplicationProtocolNegotiator toNegotiator(ApplicationProtocolConfig config, boolean isServer) Translate aApplicationProtocolConfigobject to aJdkApplicationProtocolNegotiatorobject.- Parameters:
config- The configuration which defines the translationisServer-trueif a serverfalseotherwise.- Returns:
- The results of the translation
-
buildKeyManagerFactory
static javax.net.ssl.KeyManagerFactory buildKeyManagerFactory(java.io.File certChainFile, java.io.File keyFile, java.lang.String keyPassword, javax.net.ssl.KeyManagerFactory kmf, java.lang.String keyStore) throws java.security.UnrecoverableKeyException, java.security.KeyStoreException, java.security.NoSuchAlgorithmException, javax.crypto.NoSuchPaddingException, java.security.spec.InvalidKeySpecException, java.security.InvalidAlgorithmParameterException, java.security.cert.CertificateException, java.security.KeyException, java.io.IOException 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 notnullkeyStore- theKeyStorethat should be used in theKeyManagerFactory- Returns:
- A
KeyManagerFactorybased upon a key file, key file password, and a certificate chain. - Throws:
java.security.UnrecoverableKeyExceptionjava.security.KeyStoreExceptionjava.security.NoSuchAlgorithmExceptionjavax.crypto.NoSuchPaddingExceptionjava.security.spec.InvalidKeySpecExceptionjava.security.InvalidAlgorithmParameterExceptionjava.security.cert.CertificateExceptionjava.security.KeyExceptionjava.io.IOException
-
buildKeyManagerFactory
@Deprecated protected static javax.net.ssl.KeyManagerFactory buildKeyManagerFactory(java.io.File certChainFile, java.io.File keyFile, java.lang.String keyPassword, javax.net.ssl.KeyManagerFactory kmf) throws java.security.UnrecoverableKeyException, java.security.KeyStoreException, java.security.NoSuchAlgorithmException, javax.crypto.NoSuchPaddingException, java.security.spec.InvalidKeySpecException, java.security.InvalidAlgorithmParameterException, java.security.cert.CertificateException, java.security.KeyException, java.io.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:
java.security.UnrecoverableKeyExceptionjava.security.KeyStoreExceptionjava.security.NoSuchAlgorithmExceptionjavax.crypto.NoSuchPaddingExceptionjava.security.spec.InvalidKeySpecExceptionjava.security.InvalidAlgorithmParameterExceptionjava.security.cert.CertificateExceptionjava.security.KeyExceptionjava.io.IOException
-
buildKeyManagerFactory
static javax.net.ssl.KeyManagerFactory buildKeyManagerFactory(java.io.File certChainFile, java.lang.String keyAlgorithm, java.io.File keyFile, java.lang.String keyPassword, javax.net.ssl.KeyManagerFactory kmf, java.lang.String keyStore) throws java.security.KeyStoreException, java.security.NoSuchAlgorithmException, javax.crypto.NoSuchPaddingException, java.security.spec.InvalidKeySpecException, java.security.InvalidAlgorithmParameterException, java.io.IOException, java.security.cert.CertificateException, java.security.KeyException, java.security.UnrecoverableKeyException Build aKeyManagerFactorybased upon a key algorithm, key file, key file password, and a certificate chain.- Parameters:
certChainFile- an 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 notnullkeyStore- theKeyStorethat should be used in theKeyManagerFactory- Returns:
- A
KeyManagerFactorybased upon a key algorithm, key file, key file password, and a certificate chain. - Throws:
java.security.KeyStoreExceptionjava.security.NoSuchAlgorithmExceptionjavax.crypto.NoSuchPaddingExceptionjava.security.spec.InvalidKeySpecExceptionjava.security.InvalidAlgorithmParameterExceptionjava.io.IOExceptionjava.security.cert.CertificateExceptionjava.security.KeyExceptionjava.security.UnrecoverableKeyException
-
buildKeyManagerFactory
@Deprecated protected static javax.net.ssl.KeyManagerFactory buildKeyManagerFactory(java.io.File certChainFile, java.lang.String keyAlgorithm, java.io.File keyFile, java.lang.String keyPassword, javax.net.ssl.KeyManagerFactory kmf) throws java.security.KeyStoreException, java.security.NoSuchAlgorithmException, javax.crypto.NoSuchPaddingException, java.security.spec.InvalidKeySpecException, java.security.InvalidAlgorithmParameterException, java.io.IOException, java.security.cert.CertificateException, java.security.KeyException, java.security.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:
java.security.KeyStoreExceptionjava.security.NoSuchAlgorithmExceptionjavax.crypto.NoSuchPaddingExceptionjava.security.spec.InvalidKeySpecExceptionjava.security.InvalidAlgorithmParameterExceptionjava.io.IOExceptionjava.security.cert.CertificateExceptionjava.security.KeyExceptionjava.security.UnrecoverableKeyException
-
JdkSslContext(SSLContext, boolean, Iterable, CipherSuiteFilter, ApplicationProtocolConfig, ClientAuth, String[], boolean)