Class ReferenceCountedOpenSslContext
java.lang.Object
io.netty.handler.ssl.SslContext
io.netty.handler.ssl.ReferenceCountedOpenSslContext
- All Implemented Interfaces:
ReferenceCounted
- Direct Known Subclasses:
OpenSslContext, ReferenceCountedOpenSslClientContext, ReferenceCountedOpenSslServerContext
An implementation of
SslContext which works with libraries that support the
OpenSsl C library API.
Instances of this class must be released or else native memory will leak!
Instances of this class must not be released before any ReferenceCountedOpenSslEngine
which depends upon the instance of this class is released. Otherwise if any method of
ReferenceCountedOpenSslEngine is called which uses this class's JNI resources the JVM may crash.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected longThe OpenSSL SSL_CTX object.protected static final int -
Method Summary
Modifier and TypeMethodDescriptionReturns 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) Deprecated.This method is kept for API backwards compatibility.protected static X509KeyManagerchooseX509KeyManager(KeyManager[] kms) Returns the list of enabled cipher suites, in the order of preference.final longcontext()Deprecated.this method is considered unsafe as the returned pointer may be released later.intReturns the size of the buffer used by the BIO for non-application based writesbooleanDeprecated.final booleanisClient()Returns thetrueif and only if this context is for client-side.final SSLEnginenewEngine(ByteBufAllocator alloc) Returns a new server-sideSSLEnginewith the current configuration.final SSLEnginenewEngine(ByteBufAllocator alloc, String peerHost, int peerPort) Creates a newSSLEngineusing advisory peer information.protected final SslHandlernewHandler(ByteBufAllocator alloc, boolean startTls) Create a new SslHandler.protected SslHandlernewHandler(ByteBufAllocator alloc, boolean startTls, Executor executor) Create a new SslHandler.protected final SslHandlernewHandler(ByteBufAllocator alloc, String peerHost, int peerPort, boolean startTls) Create a new SslHandler.protected SslHandlernewHandler(ByteBufAllocator alloc, String peerHost, int peerPort, boolean startTls, Executor executor) final intrefCnt()Returns the reference count of this object.final booleanrelease()Decreases the reference count by1and deallocates this object if the reference count reaches at0.final booleanrelease(int decrement) Decreases the reference count by the specifieddecrementand deallocates this object if the reference count reaches at0.final ReferenceCountedretain()Increases the reference count by1.final ReferenceCountedretain(int increment) Increases the reference count by the specifiedincrement.abstract OpenSslSessionContextReturns 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...).final voidDeprecated.voidsetRejectRemoteInitiatedRenegotiation(boolean rejectRemoteInitiatedRenegotiation) Deprecated.final voidsetTicketKeys(byte[] keys) Deprecated.final voidsetUseTasks(boolean useTasks) Deprecated.final longDeprecated.this method is considered unsafe as the returned pointer may be released later.final OpenSslSessionStatsstats()Deprecated.use}invalid @link
{@link #sessionContext#stats()final ReferenceCountedtouch()Records the current access location of this object for debugging purposes.final ReferenceCountedRecords the current access location of this object with an additional arbitrary information for debugging purposes.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, newServerContext, newServerContext, newServerContext, newServerContext, newServerContext, newServerContext, newServerContext, newServerContext, newServerContext, newServerContext, nextProtocols, sessionCacheSize, sessionTimeout, toPrivateKey, toPrivateKey, toX509Certificates, toX509Certificates
-
Field Details
-
VERIFY_DEPTH
protected static final int VERIFY_DEPTH- See Also:
-
ctx
protected long ctxThe OpenSSL SSL_CTX object.ctxLockmust be hold while using ctx!
-
-
Method Details
-
cipherSuites
Description copied from class:SslContextReturns the list of enabled cipher suites, in the order of preference.- Specified by:
cipherSuitesin classSslContext
-
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
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
-
newHandler
Description copied from class:SslContextCreate a new SslHandler.- Overrides:
newHandlerin classSslContext- See Also:
-
newHandler
protected final SslHandler newHandler(ByteBufAllocator alloc, String peerHost, int peerPort, boolean startTls) Description copied from class:SslContextCreate a new SslHandler.- Overrides:
newHandlerin classSslContext- See Also:
-
newHandler
Description copied from class:SslContextCreate a new SslHandler.- Overrides:
newHandlerin classSslContext- See Also:
-
newHandler
protected SslHandler newHandler(ByteBufAllocator alloc, String peerHost, int peerPort, boolean startTls, Executor executor) - Overrides:
newHandlerin classSslContext
-
newEngine
Returns a new server-sideSSLEnginewith the current configuration.- Specified by:
newEnginein classSslContext- Returns:
- a new
SSLEngine
-
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.use}invalid @link
{@link #sessionContext#stats()Returns the stats of this context. -
setRejectRemoteInitiatedRenegotiation
@Deprecated public void setRejectRemoteInitiatedRenegotiation(boolean rejectRemoteInitiatedRenegotiation) Deprecated.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.- 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.Sets the SSL session ticket keys of this context. -
sessionContext
Description copied from class:SslContextReturns theSSLSessionContextobject held by this context.- Specified by:
sessionContextin classSslContext
-
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.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. -
certificates
-
chooseTrustManager
Deprecated.This method is kept for API backwards compatibility. -
chooseX509KeyManager
-
refCnt
public final int refCnt()Description copied from interface:ReferenceCountedReturns the reference count of this object. If0, it means this object has been deallocated.- Specified by:
refCntin interfaceReferenceCounted
-
retain
Description copied from interface:ReferenceCountedIncreases the reference count by1.- Specified by:
retainin interfaceReferenceCounted
-
retain
Description copied from interface:ReferenceCountedIncreases the reference count by the specifiedincrement.- Specified by:
retainin interfaceReferenceCounted
-
touch
Description copied from interface:ReferenceCountedRecords the current access location of this object for debugging purposes. If this object is determined to be leaked, the information recorded by this operation will be provided to you viaResourceLeakDetector. This method is a shortcut totouch(null).- Specified by:
touchin interfaceReferenceCounted
-
touch
Description copied from interface:ReferenceCountedRecords the current access location of this object with an additional arbitrary information for debugging purposes. If this object is determined to be leaked, the information recorded by this operation will be provided to you viaResourceLeakDetector.- Specified by:
touchin interfaceReferenceCounted
-
release
public final boolean release()Description copied from interface:ReferenceCountedDecreases the reference count by1and deallocates this object if the reference count reaches at0.- Specified by:
releasein interfaceReferenceCounted- Returns:
trueif and only if the reference count became0and this object has been deallocated
-
release
public final boolean release(int decrement) Description copied from interface:ReferenceCountedDecreases the reference count by the specifieddecrementand deallocates this object if the reference count reaches at0.- Specified by:
releasein interfaceReferenceCounted- Returns:
trueif and only if the reference count became0and this object has been deallocated
-