Package io.netty5.handler.ssl
Class ReferenceCountedOpenSslContext
- java.lang.Object
-
- io.netty5.handler.ssl.SslContext
-
- io.netty5.handler.ssl.ReferenceCountedOpenSslContext
-
- All Implemented Interfaces:
io.netty5.util.ReferenceCounted
- Direct Known Subclasses:
OpenSslContext,ReferenceCountedOpenSslClientContext,ReferenceCountedOpenSslServerContext
public abstract class ReferenceCountedOpenSslContext extends SslContext implements io.netty5.util.ReferenceCounted
An implementation ofSslContextwhich works with libraries that support the OpenSsl C library API.Instances of this class must be
releasedor else native memory will leak!Instances of this class must not be released before any
ReferenceCountedOpenSslEnginewhich depends upon the instance of this class is released. Otherwise if any method ofReferenceCountedOpenSslEngineis called which uses this class's JNI resources the JVM may crash.
-
-
Field Summary
Fields Modifier and Type Field Description protected longctxThe OpenSSL SSL_CTX object.protected static intVERIFY_DEPTH
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description ApplicationProtocolNegotiatorapplicationProtocolNegotiator()Returns the object responsible for negotiating application layer protocols for the TLS NPN/ALPN extensions.protected static X509Certificate[]certificates(byte[][] chain)protected static X509TrustManagerchooseTrustManager(TrustManager[] managers)protected static X509KeyManagerchooseX509KeyManager(KeyManager[] kms)List<String>cipherSuites()Returns the list of enabled cipher suites, in the order of preference.longcontext()Deprecated.this method is considered unsafe as the returned pointer may be released later.intgetBioNonApplicationBufferSize()Returns the size of the buffer used by the BIO for non-application based writesbooleangetRejectRemoteInitiatedRenegotiation()Deprecated.booleanisClient()Returns thetrueif and only if this context is for client-side.SSLEnginenewEngine(io.netty5.buffer.ByteBufAllocator alloc)Returns a new server-sideSSLEnginewith the current configuration.SSLEnginenewEngine(io.netty5.buffer.ByteBufAllocator alloc, String peerHost, int peerPort)Creates a newSSLEngineusing advisory peer information.protected SslHandlernewHandler(io.netty5.buffer.ByteBufAllocator alloc, boolean startTls)Create a new SslHandler.protected SslHandlernewHandler(io.netty5.buffer.ByteBufAllocator alloc, boolean startTls, Executor executor)Create a new SslHandler.protected SslHandlernewHandler(io.netty5.buffer.ByteBufAllocator alloc, String peerHost, int peerPort, boolean startTls)Create a new SslHandler.protected SslHandlernewHandler(io.netty5.buffer.ByteBufAllocator alloc, String peerHost, int peerPort, boolean startTls, Executor executor)intrefCnt()booleanrelease()booleanrelease(int decrement)io.netty5.util.ReferenceCountedretain()io.netty5.util.ReferenceCountedretain(int increment)abstract OpenSslSessionContextsessionContext()Returns theSSLSessionContextobject held by this context.voidsetBioNonApplicationBufferSize(int bioNonApplicationBufferSize)Set the size of the buffer used by the BIO for non-application based writes (e.g. handshake, renegotiation, etc...).voidsetPrivateKeyMethod(OpenSslPrivateKeyMethod method)Deprecated.voidsetRejectRemoteInitiatedRenegotiation(boolean rejectRemoteInitiatedRenegotiation)Deprecated.voidsetTicketKeys(byte[] keys)Deprecated.voidsetUseTasks(boolean useTasks)Deprecated.longsslCtxPointer()Deprecated.this method is considered unsafe as the returned pointer may be released later.OpenSslSessionStatsstats()Deprecated.use {@link #sessionContext#stats()}io.netty5.util.ReferenceCountedtouch()io.netty5.util.ReferenceCountedtouch(Object hint)-
Methods inherited from class io.netty5.handler.ssl.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, newServerContext, newServerContext, newServerContext, newServerContext, newServerContext, newServerContext, newServerContext, newServerContext, newServerContext, newServerContext, nextProtocols, sessionCacheSize, sessionTimeout, toPrivateKey, toPrivateKey, toX509Certificates, toX509Certificates
-
-
-
-
Field Detail
-
VERIFY_DEPTH
protected static final int VERIFY_DEPTH
- See Also:
- Constant Field Values
-
ctx
protected long ctx
The OpenSSL SSL_CTX object.ctxLockmust be hold while using ctx!
-
-
Method Detail
-
cipherSuites
public final List<String> cipherSuites()
Description copied from class:SslContextReturns the list of enabled cipher suites, in the order of preference.- Specified by:
cipherSuitesin classSslContext
-
applicationProtocolNegotiator
public ApplicationProtocolNegotiator applicationProtocolNegotiator()
Description copied from class:SslContextReturns the object responsible for negotiating application layer protocols for the TLS NPN/ALPN extensions.- Specified by:
applicationProtocolNegotiatorin classSslContext
-
isClient
public final boolean isClient()
Description copied from class:SslContextReturns thetrueif and only if this context is for client-side.- Specified by:
isClientin classSslContext
-
newEngine
public final SSLEngine newEngine(io.netty5.buffer.ByteBufAllocator alloc, 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 classSslContextpeerHost- the non-authoritative name of the hostpeerPort- the non-authoritative port- Returns:
- a new
SSLEngine
-
newHandler
protected final SslHandler newHandler(io.netty5.buffer.ByteBufAllocator alloc, boolean startTls)
Description copied from class:SslContextCreate a new SslHandler.- Overrides:
newHandlerin classSslContext- See Also:
SslContext.newHandler(ByteBufAllocator)
-
newHandler
protected final SslHandler newHandler(io.netty5.buffer.ByteBufAllocator alloc, String peerHost, int peerPort, boolean startTls)
Description copied from class:SslContextCreate a new SslHandler.- Overrides:
newHandlerin classSslContext- See Also:
SslContext.newHandler(ByteBufAllocator, String, int, boolean, Executor)
-
newHandler
protected SslHandler newHandler(io.netty5.buffer.ByteBufAllocator alloc, boolean startTls, Executor executor)
Description copied from class:SslContextCreate a new SslHandler.- Overrides:
newHandlerin classSslContext- See Also:
SslContext.newHandler(ByteBufAllocator, String, int, boolean, Executor)
-
newHandler
protected SslHandler newHandler(io.netty5.buffer.ByteBufAllocator alloc, String peerHost, int peerPort, boolean startTls, Executor executor)
- Overrides:
newHandlerin classSslContext
-
newEngine
public final SSLEngine newEngine(io.netty5.buffer.ByteBufAllocator alloc)
Returns a new server-sideSSLEnginewith the current configuration.- Specified by:
newEnginein classSslContext- Returns:
- a new
SSLEngine
-
context
@Deprecated public final long context()
Deprecated.this method is considered unsafe as the returned pointer may be released later. Dont use it!Returns the pointer to theSSL_CTXobject for thisReferenceCountedOpenSslContext. Be aware that it is freed as soon as theObject.finalize()method is called. At this point0will be returned.
-
stats
@Deprecated public final OpenSslSessionStats stats()
Deprecated.use {@link #sessionContext#stats()}Returns the stats of this context.
-
setRejectRemoteInitiatedRenegotiation
@Deprecated public void setRejectRemoteInitiatedRenegotiation(boolean rejectRemoteInitiatedRenegotiation)
Deprecated.{@deprecated Renegotiation is not supported} Specify if remote initiated renegotiation is supported or not. If not supported and the remote side tries to initiate a renegotiation aSSLHandshakeExceptionwill be thrown during decoding.
-
getRejectRemoteInitiatedRenegotiation
@Deprecated public boolean getRejectRemoteInitiatedRenegotiation()
Deprecated.{@deprecated Renegotiation is not supported}- Returns:
truebecause renegotiation is not supported.
-
setBioNonApplicationBufferSize
public void setBioNonApplicationBufferSize(int bioNonApplicationBufferSize)
Set the size of the buffer used by the BIO for non-application based writes (e.g. handshake, renegotiation, etc...).
-
getBioNonApplicationBufferSize
public int getBioNonApplicationBufferSize()
Returns the size of the buffer used by the BIO for non-application based writes
-
setTicketKeys
@Deprecated public final void setTicketKeys(byte[] keys)
Deprecated.Sets the SSL session ticket keys of this context.
-
sessionContext
public abstract OpenSslSessionContext sessionContext()
Description copied from class:SslContextReturns theSSLSessionContextobject held by this context.- Specified by:
sessionContextin classSslContext
-
sslCtxPointer
@Deprecated public final long sslCtxPointer()
Deprecated.this method is considered unsafe as the returned pointer may be released later. Dont use it!Returns the pointer to theSSL_CTXobject for thisReferenceCountedOpenSslContext. Be aware that it is freed as soon as therelease()method is called. At this point0will be returned.
-
setPrivateKeyMethod
@Deprecated @UnstableApi public final void setPrivateKeyMethod(OpenSslPrivateKeyMethod method)
Deprecated.Set theOpenSslPrivateKeyMethodto use. This allows to offload private-key operations if needed. This method is currently only supported whenBoringSSLis used.- Parameters:
method- method to use.
-
setUseTasks
@Deprecated public final void setUseTasks(boolean useTasks)
Deprecated.
-
certificates
protected static X509Certificate[] certificates(byte[][] chain)
-
chooseTrustManager
protected static X509TrustManager chooseTrustManager(TrustManager[] managers)
-
chooseX509KeyManager
protected static X509KeyManager chooseX509KeyManager(KeyManager[] kms)
-
refCnt
public final int refCnt()
- Specified by:
refCntin interfaceio.netty5.util.ReferenceCounted
-
retain
public final io.netty5.util.ReferenceCounted retain()
- Specified by:
retainin interfaceio.netty5.util.ReferenceCounted
-
retain
public final io.netty5.util.ReferenceCounted retain(int increment)
- Specified by:
retainin interfaceio.netty5.util.ReferenceCounted
-
touch
public final io.netty5.util.ReferenceCounted touch()
- Specified by:
touchin interfaceio.netty5.util.ReferenceCounted
-
touch
public final io.netty5.util.ReferenceCounted touch(Object hint)
- Specified by:
touchin interfaceio.netty5.util.ReferenceCounted
-
release
public final boolean release()
- Specified by:
releasein interfaceio.netty5.util.ReferenceCounted
-
release
public final boolean release(int decrement)
- Specified by:
releasein interfaceio.netty5.util.ReferenceCounted
-
-