- java.lang.Object
-
- javax.net.ssl.SSLEngine
-
- io.netty5.handler.ssl.ReferenceCountedOpenSslEngine
-
- All Implemented Interfaces:
io.netty.util.ReferenceCounted
,io.netty5.util.ReferenceCounted
- Direct Known Subclasses:
OpenSslEngine
public class ReferenceCountedOpenSslEngine extends SSLEngine implements io.netty5.util.ReferenceCounted
Implements aSSLEngine
using OpenSSL BIO abstractions.Instances of this class must be
released
or else native memory will leak!Instances of this class must be released before the
ReferenceCountedOpenSslContext
the instance depends upon are released. Otherwise if any method of this class is called which uses the theReferenceCountedOpenSslContext
JNI resources the JVM may crash.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
beginHandshake()
void
closeInbound()
void
closeOutbound()
String
getApplicationProtocol()
Runnable
getDelegatedTask()
String[]
getEnabledCipherSuites()
String[]
getEnabledProtocols()
boolean
getEnableSessionCreation()
String
getHandshakeApplicationProtocol()
SSLSession
getHandshakeSession()
SSLEngineResult.HandshakeStatus
getHandshakeStatus()
boolean
getNeedClientAuth()
String
getNegotiatedApplicationProtocol()
byte[]
getOcspResponse()
Returns the OCSP response ornull
if the server didn't provide a stapled OCSP response.SSLSession
getSession()
SSLParameters
getSSLParameters()
String[]
getSupportedCipherSuites()
String[]
getSupportedProtocols()
boolean
getUseClientMode()
boolean
getWantClientAuth()
boolean
isInboundDone()
boolean
isOutboundDone()
int
refCnt()
boolean
release()
boolean
release(int decrement)
io.netty5.util.ReferenceCounted
retain()
io.netty5.util.ReferenceCounted
retain(int increment)
void
setEnabledCipherSuites(String[] cipherSuites)
void
setEnabledProtocols(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.void
setEnableSessionCreation(boolean b)
void
setNeedClientAuth(boolean b)
void
setOcspResponse(byte[] response)
Sets the OCSP response.void
setSSLParameters(SSLParameters sslParameters)
void
setUseClientMode(boolean clientMode)
void
setVerify(int verifyMode, int depth)
See SSL_set_verify andSSL.setVerify(long, int, int)
.void
setWantClientAuth(boolean b)
void
shutdown()
Destroys this engine.long
sslPointer()
Returns the pointer to theSSL
object for thisReferenceCountedOpenSslEngine
.io.netty5.util.ReferenceCounted
touch()
io.netty5.util.ReferenceCounted
touch(Object hint)
SSLEngineResult
unwrap(ByteBuffer[] srcs, int srcsOffset, int srcsLength, ByteBuffer[] dsts, int dstsOffset, int dstsLength)
SSLEngineResult
unwrap(ByteBuffer[] srcs, ByteBuffer[] dsts)
SSLEngineResult
unwrap(ByteBuffer src, ByteBuffer dst)
SSLEngineResult
unwrap(ByteBuffer src, ByteBuffer[] dsts)
SSLEngineResult
unwrap(ByteBuffer src, ByteBuffer[] dsts, int offset, int length)
SSLEngineResult
wrap(ByteBuffer[] srcs, int offset, int length, ByteBuffer dst)
SSLEngineResult
wrap(ByteBuffer src, ByteBuffer dst)
-
Methods inherited from class javax.net.ssl.SSLEngine
getHandshakeApplicationProtocolSelector, getPeerHost, getPeerPort, setHandshakeApplicationProtocolSelector, wrap
-
-
-
-
Method Detail
-
setOcspResponse
@UnstableApi public void setOcspResponse(byte[] response)
Sets the OCSP response.
-
getOcspResponse
@UnstableApi public byte[] getOcspResponse()
Returns the OCSP response ornull
if the server didn't provide a stapled OCSP response.
-
refCnt
public final int refCnt()
- Specified by:
refCnt
in interfaceio.netty.util.ReferenceCounted
- Specified by:
refCnt
in interfaceio.netty5.util.ReferenceCounted
-
retain
public final io.netty5.util.ReferenceCounted retain()
- Specified by:
retain
in interfaceio.netty.util.ReferenceCounted
- Specified by:
retain
in interfaceio.netty5.util.ReferenceCounted
-
retain
public final io.netty5.util.ReferenceCounted retain(int increment)
- Specified by:
retain
in interfaceio.netty.util.ReferenceCounted
- Specified by:
retain
in interfaceio.netty5.util.ReferenceCounted
-
touch
public final io.netty5.util.ReferenceCounted touch()
- Specified by:
touch
in interfaceio.netty.util.ReferenceCounted
- Specified by:
touch
in interfaceio.netty5.util.ReferenceCounted
-
touch
public final io.netty5.util.ReferenceCounted touch(Object hint)
- Specified by:
touch
in interfaceio.netty.util.ReferenceCounted
- Specified by:
touch
in interfaceio.netty5.util.ReferenceCounted
-
release
public final boolean release()
- Specified by:
release
in interfaceio.netty.util.ReferenceCounted
- Specified by:
release
in interfaceio.netty5.util.ReferenceCounted
-
release
public final boolean release(int decrement)
- Specified by:
release
in interfaceio.netty.util.ReferenceCounted
- Specified by:
release
in interfaceio.netty5.util.ReferenceCounted
-
getApplicationProtocol
public String getApplicationProtocol()
- Overrides:
getApplicationProtocol
in classSSLEngine
-
getHandshakeApplicationProtocol
public String getHandshakeApplicationProtocol()
- Overrides:
getHandshakeApplicationProtocol
in classSSLEngine
-
getHandshakeSession
public final SSLSession getHandshakeSession()
- Overrides:
getHandshakeSession
in classSSLEngine
-
sslPointer
public final long sslPointer()
Returns the pointer to theSSL
object for thisReferenceCountedOpenSslEngine
. Be aware that it is freed as soon as therelease()
orshutdown()
methods are called. At this point0
will be returned.
-
shutdown
public final void shutdown()
Destroys this engine.
-
wrap
public final SSLEngineResult wrap(ByteBuffer[] srcs, int offset, int length, ByteBuffer dst) throws SSLException
- Specified by:
wrap
in classSSLEngine
- Throws:
SSLException
-
unwrap
public final SSLEngineResult unwrap(ByteBuffer[] srcs, int srcsOffset, int srcsLength, ByteBuffer[] dsts, int dstsOffset, int dstsLength) throws SSLException
- Throws:
SSLException
-
unwrap
public final SSLEngineResult unwrap(ByteBuffer[] srcs, ByteBuffer[] dsts) throws SSLException
- Throws:
SSLException
-
unwrap
public final SSLEngineResult unwrap(ByteBuffer src, ByteBuffer[] dsts, int offset, int length) throws SSLException
- Specified by:
unwrap
in classSSLEngine
- Throws:
SSLException
-
wrap
public final SSLEngineResult wrap(ByteBuffer src, ByteBuffer dst) throws SSLException
- Overrides:
wrap
in classSSLEngine
- Throws:
SSLException
-
unwrap
public final SSLEngineResult unwrap(ByteBuffer src, ByteBuffer dst) throws SSLException
- Overrides:
unwrap
in classSSLEngine
- Throws:
SSLException
-
unwrap
public final SSLEngineResult unwrap(ByteBuffer src, ByteBuffer[] dsts) throws SSLException
- Overrides:
unwrap
in classSSLEngine
- Throws:
SSLException
-
getDelegatedTask
public final Runnable getDelegatedTask()
- Specified by:
getDelegatedTask
in classSSLEngine
-
closeInbound
public final void closeInbound() throws SSLException
- Specified by:
closeInbound
in classSSLEngine
- Throws:
SSLException
-
isInboundDone
public final boolean isInboundDone()
- Specified by:
isInboundDone
in classSSLEngine
-
closeOutbound
public final void closeOutbound()
- Specified by:
closeOutbound
in classSSLEngine
-
isOutboundDone
public final boolean isOutboundDone()
- Specified by:
isOutboundDone
in classSSLEngine
-
getSupportedCipherSuites
public final String[] getSupportedCipherSuites()
- Specified by:
getSupportedCipherSuites
in classSSLEngine
-
getEnabledCipherSuites
public final String[] getEnabledCipherSuites()
- Specified by:
getEnabledCipherSuites
in classSSLEngine
-
setEnabledCipherSuites
public final void setEnabledCipherSuites(String[] cipherSuites)
- Specified by:
setEnabledCipherSuites
in classSSLEngine
-
getSupportedProtocols
public final String[] getSupportedProtocols()
- Specified by:
getSupportedProtocols
in classSSLEngine
-
getEnabledProtocols
public final String[] getEnabledProtocols()
- Specified by:
getEnabledProtocols
in classSSLEngine
-
setEnabledProtocols
public final void setEnabledProtocols(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:
setEnabledProtocols
in classSSLEngine
-
getSession
public final SSLSession getSession()
- Specified by:
getSession
in classSSLEngine
-
beginHandshake
public final void beginHandshake() throws SSLException
- Specified by:
beginHandshake
in classSSLEngine
- Throws:
SSLException
-
getHandshakeStatus
public final SSLEngineResult.HandshakeStatus getHandshakeStatus()
- Specified by:
getHandshakeStatus
in classSSLEngine
-
setUseClientMode
public final void setUseClientMode(boolean clientMode)
- Specified by:
setUseClientMode
in classSSLEngine
-
getUseClientMode
public final boolean getUseClientMode()
- Specified by:
getUseClientMode
in classSSLEngine
-
setNeedClientAuth
public final void setNeedClientAuth(boolean b)
- Specified by:
setNeedClientAuth
in classSSLEngine
-
getNeedClientAuth
public final boolean getNeedClientAuth()
- Specified by:
getNeedClientAuth
in classSSLEngine
-
setWantClientAuth
public final void setWantClientAuth(boolean b)
- Specified by:
setWantClientAuth
in classSSLEngine
-
getWantClientAuth
public final boolean getWantClientAuth()
- Specified by:
getWantClientAuth
in classSSLEngine
-
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:
setEnableSessionCreation
in classSSLEngine
-
getEnableSessionCreation
public final boolean getEnableSessionCreation()
- Specified by:
getEnableSessionCreation
in classSSLEngine
-
getSSLParameters
public final SSLParameters getSSLParameters()
- Overrides:
getSSLParameters
in classSSLEngine
-
setSSLParameters
public final void setSSLParameters(SSLParameters sslParameters)
- Overrides:
setSSLParameters
in classSSLEngine
-
getNegotiatedApplicationProtocol
public String getNegotiatedApplicationProtocol()
-
-