Package io.netty.handler.ssl
Class ReferenceCountedOpenSslEngine
- java.lang.Object
-
- javax.net.ssl.SSLEngine
-
- io.netty.handler.ssl.ReferenceCountedOpenSslEngine
-
- All Implemented Interfaces:
ReferenceCounted
- Direct Known Subclasses:
OpenSslEngine
public class ReferenceCountedOpenSslEngine extends javax.net.ssl.SSLEngine implements ReferenceCounted
Implements aSSLEngineusing OpenSSL BIO abstractions.Instances of this class must be
releasedor else native memory will leak!Instances of this class must be released before the
ReferenceCountedOpenSslContextthe instance depends upon are released. Otherwise if any method of this class is called which uses the theReferenceCountedOpenSslContextJNI resources the JVM may crash.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbeginHandshake()voidcloseInbound()voidcloseOutbound()java.lang.StringgetApplicationProtocol()java.lang.RunnablegetDelegatedTask()java.lang.String[]getEnabledCipherSuites()java.lang.String[]getEnabledProtocols()booleangetEnableSessionCreation()java.lang.StringgetHandshakeApplicationProtocol()javax.net.ssl.SSLSessiongetHandshakeSession()javax.net.ssl.SSLEngineResult.HandshakeStatusgetHandshakeStatus()booleangetNeedClientAuth()java.lang.StringgetNegotiatedApplicationProtocol()byte[]getOcspResponse()Returns the OCSP response ornullif the server didn't provide a stapled OCSP response.javax.net.ssl.SSLSessiongetSession()javax.net.ssl.SSLParametersgetSSLParameters()java.lang.String[]getSupportedCipherSuites()java.lang.String[]getSupportedProtocols()booleangetUseClientMode()booleangetWantClientAuth()booleanisInboundDone()booleanisOutboundDone()intrefCnt()Returns the reference count of this object.booleanrelease()Decreases the reference count by1and deallocates this object if the reference count reaches at0.booleanrelease(int decrement)Decreases the reference count by the specifieddecrementand deallocates this object if the reference count reaches at0.ReferenceCountedretain()Increases the reference count by1.ReferenceCountedretain(int increment)Increases the reference count by the specifiedincrement.voidsetEnabledCipherSuites(java.lang.String[] cipherSuites)voidsetEnabledProtocols(java.lang.String[] protocols)TLS doesn't support a way to advertise non-contiguous versions from the client's perspective, and the client just advertises the max supported version.voidsetEnableSessionCreation(boolean b)voidsetNeedClientAuth(boolean b)voidsetOcspResponse(byte[] response)Sets the OCSP response.voidsetSSLParameters(javax.net.ssl.SSLParameters sslParameters)voidsetUseClientMode(boolean clientMode)voidsetVerify(int verifyMode, int depth)See SSL_set_verify andSSL.setVerify(long, int, int).voidsetWantClientAuth(boolean b)voidshutdown()Destroys this engine.longsslPointer()Returns the pointer to theSSLobject for thisReferenceCountedOpenSslEngine.ReferenceCountedtouch()Records the current access location of this object for debugging purposes.ReferenceCountedtouch(java.lang.Object hint)Records the current access location of this object with an additional arbitrary information for debugging purposes.javax.net.ssl.SSLEngineResultunwrap(java.nio.ByteBuffer[] srcs, int srcsOffset, int srcsLength, java.nio.ByteBuffer[] dsts, int dstsOffset, int dstsLength)javax.net.ssl.SSLEngineResultunwrap(java.nio.ByteBuffer[] srcs, java.nio.ByteBuffer[] dsts)javax.net.ssl.SSLEngineResultunwrap(java.nio.ByteBuffer src, java.nio.ByteBuffer dst)javax.net.ssl.SSLEngineResultunwrap(java.nio.ByteBuffer src, java.nio.ByteBuffer[] dsts)javax.net.ssl.SSLEngineResultunwrap(java.nio.ByteBuffer src, java.nio.ByteBuffer[] dsts, int offset, int length)javax.net.ssl.SSLEngineResultwrap(java.nio.ByteBuffer[] srcs, int offset, int length, java.nio.ByteBuffer dst)javax.net.ssl.SSLEngineResultwrap(java.nio.ByteBuffer src, java.nio.ByteBuffer dst)
-
-
-
Method Detail
-
setOcspResponse
@UnstableApi public void setOcspResponse(byte[] response)
Sets the OCSP response.
-
getOcspResponse
@UnstableApi public byte[] getOcspResponse()
Returns the OCSP response ornullif the server didn't provide a stapled OCSP response.
-
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
public final ReferenceCounted retain()
Description copied from interface:ReferenceCountedIncreases the reference count by1.- Specified by:
retainin interfaceReferenceCounted
-
retain
public final ReferenceCounted retain(int increment)
Description copied from interface:ReferenceCountedIncreases the reference count by the specifiedincrement.- Specified by:
retainin interfaceReferenceCounted
-
touch
public final ReferenceCounted 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
public final ReferenceCounted touch(java.lang.Object hint)
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
-
getApplicationProtocol
public java.lang.String getApplicationProtocol()
- Overrides:
getApplicationProtocolin classjavax.net.ssl.SSLEngine
-
getHandshakeApplicationProtocol
public java.lang.String getHandshakeApplicationProtocol()
- Overrides:
getHandshakeApplicationProtocolin classjavax.net.ssl.SSLEngine
-
getHandshakeSession
public final javax.net.ssl.SSLSession getHandshakeSession()
- Overrides:
getHandshakeSessionin classjavax.net.ssl.SSLEngine
-
sslPointer
public final long sslPointer()
Returns the pointer to theSSLobject for thisReferenceCountedOpenSslEngine. Be aware that it is freed as soon as therelease()orshutdown()methods are called. At this point0will be returned.
-
shutdown
public final void shutdown()
Destroys this engine.
-
wrap
public final javax.net.ssl.SSLEngineResult wrap(java.nio.ByteBuffer[] srcs, int offset, int length, java.nio.ByteBuffer dst) throws javax.net.ssl.SSLException- Specified by:
wrapin classjavax.net.ssl.SSLEngine- Throws:
javax.net.ssl.SSLException
-
unwrap
public final javax.net.ssl.SSLEngineResult unwrap(java.nio.ByteBuffer[] srcs, int srcsOffset, int srcsLength, java.nio.ByteBuffer[] dsts, int dstsOffset, int dstsLength) throws javax.net.ssl.SSLException- Throws:
javax.net.ssl.SSLException
-
unwrap
public final javax.net.ssl.SSLEngineResult unwrap(java.nio.ByteBuffer[] srcs, java.nio.ByteBuffer[] dsts) throws javax.net.ssl.SSLException- Throws:
javax.net.ssl.SSLException
-
unwrap
public final javax.net.ssl.SSLEngineResult unwrap(java.nio.ByteBuffer src, java.nio.ByteBuffer[] dsts, int offset, int length) throws javax.net.ssl.SSLException- Specified by:
unwrapin classjavax.net.ssl.SSLEngine- Throws:
javax.net.ssl.SSLException
-
wrap
public final javax.net.ssl.SSLEngineResult wrap(java.nio.ByteBuffer src, java.nio.ByteBuffer dst) throws javax.net.ssl.SSLException- Overrides:
wrapin classjavax.net.ssl.SSLEngine- Throws:
javax.net.ssl.SSLException
-
unwrap
public final javax.net.ssl.SSLEngineResult unwrap(java.nio.ByteBuffer src, java.nio.ByteBuffer dst) throws javax.net.ssl.SSLException- Overrides:
unwrapin classjavax.net.ssl.SSLEngine- Throws:
javax.net.ssl.SSLException
-
unwrap
public final javax.net.ssl.SSLEngineResult unwrap(java.nio.ByteBuffer src, java.nio.ByteBuffer[] dsts) throws javax.net.ssl.SSLException- Overrides:
unwrapin classjavax.net.ssl.SSLEngine- Throws:
javax.net.ssl.SSLException
-
getDelegatedTask
public final java.lang.Runnable getDelegatedTask()
- Specified by:
getDelegatedTaskin classjavax.net.ssl.SSLEngine
-
closeInbound
public final void closeInbound() throws javax.net.ssl.SSLException- Specified by:
closeInboundin classjavax.net.ssl.SSLEngine- Throws:
javax.net.ssl.SSLException
-
isInboundDone
public final boolean isInboundDone()
- Specified by:
isInboundDonein classjavax.net.ssl.SSLEngine
-
closeOutbound
public final void closeOutbound()
- Specified by:
closeOutboundin classjavax.net.ssl.SSLEngine
-
isOutboundDone
public final boolean isOutboundDone()
- Specified by:
isOutboundDonein classjavax.net.ssl.SSLEngine
-
getSupportedCipherSuites
public final java.lang.String[] getSupportedCipherSuites()
- Specified by:
getSupportedCipherSuitesin classjavax.net.ssl.SSLEngine
-
getEnabledCipherSuites
public final java.lang.String[] getEnabledCipherSuites()
- Specified by:
getEnabledCipherSuitesin classjavax.net.ssl.SSLEngine
-
setEnabledCipherSuites
public final void setEnabledCipherSuites(java.lang.String[] cipherSuites)
- Specified by:
setEnabledCipherSuitesin classjavax.net.ssl.SSLEngine
-
getSupportedProtocols
public final java.lang.String[] getSupportedProtocols()
- Specified by:
getSupportedProtocolsin classjavax.net.ssl.SSLEngine
-
getEnabledProtocols
public final java.lang.String[] getEnabledProtocols()
- Specified by:
getEnabledProtocolsin classjavax.net.ssl.SSLEngine
-
setEnabledProtocols
public final void setEnabledProtocols(java.lang.String[] protocols)
TLS doesn't support a way to advertise non-contiguous versions from the client's perspective, and the client just advertises the max supported version. The TLS protocol also doesn't support all different combinations of discrete protocols, and instead assumes contiguous ranges. OpenSSL has some unexpected behavior (e.g. handshake failures) if non-contiguous protocols are used even where there is a compatible set of protocols and ciphers. For these reasons this method will determine the minimum protocol and the maximum protocol and enabled a contiguous range from [min protocol, max protocol] in OpenSSL.- Specified by:
setEnabledProtocolsin classjavax.net.ssl.SSLEngine
-
getSession
public final javax.net.ssl.SSLSession getSession()
- Specified by:
getSessionin classjavax.net.ssl.SSLEngine
-
beginHandshake
public final void beginHandshake() throws javax.net.ssl.SSLException- Specified by:
beginHandshakein classjavax.net.ssl.SSLEngine- Throws:
javax.net.ssl.SSLException
-
getHandshakeStatus
public final javax.net.ssl.SSLEngineResult.HandshakeStatus getHandshakeStatus()
- Specified by:
getHandshakeStatusin classjavax.net.ssl.SSLEngine
-
setUseClientMode
public final void setUseClientMode(boolean clientMode)
- Specified by:
setUseClientModein classjavax.net.ssl.SSLEngine
-
getUseClientMode
public final boolean getUseClientMode()
- Specified by:
getUseClientModein classjavax.net.ssl.SSLEngine
-
setNeedClientAuth
public final void setNeedClientAuth(boolean b)
- Specified by:
setNeedClientAuthin classjavax.net.ssl.SSLEngine
-
getNeedClientAuth
public final boolean getNeedClientAuth()
- Specified by:
getNeedClientAuthin classjavax.net.ssl.SSLEngine
-
setWantClientAuth
public final void setWantClientAuth(boolean b)
- Specified by:
setWantClientAuthin classjavax.net.ssl.SSLEngine
-
getWantClientAuth
public final boolean getWantClientAuth()
- Specified by:
getWantClientAuthin classjavax.net.ssl.SSLEngine
-
setVerify
@UnstableApi public final void setVerify(int verifyMode, int depth)
See SSL_set_verify andSSL.setVerify(long, int, int).
-
setEnableSessionCreation
public final void setEnableSessionCreation(boolean b)
- Specified by:
setEnableSessionCreationin classjavax.net.ssl.SSLEngine
-
getEnableSessionCreation
public final boolean getEnableSessionCreation()
- Specified by:
getEnableSessionCreationin classjavax.net.ssl.SSLEngine
-
getSSLParameters
public final javax.net.ssl.SSLParameters getSSLParameters()
- Overrides:
getSSLParametersin classjavax.net.ssl.SSLEngine
-
setSSLParameters
public final void setSSLParameters(javax.net.ssl.SSLParameters sslParameters)
- Overrides:
setSSLParametersin classjavax.net.ssl.SSLEngine
-
getNegotiatedApplicationProtocol
public java.lang.String getNegotiatedApplicationProtocol()
-
-