SSLEngineResult() — netty Function Reference
Architecture documentation for the SSLEngineResult() function in ReferenceCountedOpenSslEngine.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 9f77679b_188a_ea47_0bb0_025af752e7f4["SSLEngineResult()"] df1ad81e_e5bf_85e6_4418_db301b4c3e66["ReferenceCountedOpenSslEngine"] 9f77679b_188a_ea47_0bb0_025af752e7f4 -->|defined in| df1ad81e_e5bf_85e6_4418_db301b4c3e66 9bd72a0f_68ed_cd2d_f4ac_b0657258724c["isOutboundDone()"] 9f77679b_188a_ea47_0bb0_025af752e7f4 -->|calls| 9bd72a0f_68ed_cd2d_f4ac_b0657258724c b0196480_3542_7d56_b3fe_e50250950844["isInboundDone()"] 9f77679b_188a_ea47_0bb0_025af752e7f4 -->|calls| b0196480_3542_7d56_b3fe_e50250950844 5a654cb5_a186_f8ae_d05b_d708ac558525["bufferAddress()"] 9f77679b_188a_ea47_0bb0_025af752e7f4 -->|calls| 5a654cb5_a186_f8ae_d05b_d708ac558525 17f0d230_c2de_4728_edc7_3aa68e520dbb["isBytesAvailableEnoughForWrap()"] 9f77679b_188a_ea47_0bb0_025af752e7f4 -->|calls| 17f0d230_c2de_4728_edc7_3aa68e520dbb 3ddadf00_257d_ea94_ec2c_9afd83ac4524["getHandshakeStatus()"] 9f77679b_188a_ea47_0bb0_025af752e7f4 -->|calls| 3ddadf00_257d_ea94_ec2c_9afd83ac4524 1597114c_667e_f9e1_e97d_756c7ad01661["doSSLShutdown()"] 9f77679b_188a_ea47_0bb0_025af752e7f4 -->|calls| 1597114c_667e_f9e1_e97d_756c7ad01661 70ac8c99_3ca9_c202_a13f_16dda4571164["handshake()"] 9f77679b_188a_ea47_0bb0_025af752e7f4 -->|calls| 70ac8c99_3ca9_c202_a13f_16dda4571164 bd3db87e_15bb_10ab_35c4_8c54c4a424e8["handshakeException()"] 9f77679b_188a_ea47_0bb0_025af752e7f4 -->|calls| bd3db87e_15bb_10ab_35c4_8c54c4a424e8 8f4bc60d_a2f3_a1d5_59ca_53b86ada8b7f["mayFinishHandshake()"] 9f77679b_188a_ea47_0bb0_025af752e7f4 -->|calls| 8f4bc60d_a2f3_a1d5_59ca_53b86ada8b7f c4b3e9d1_8ba5_707f_4649_4d5a628a2433["shutdown()"] 9f77679b_188a_ea47_0bb0_025af752e7f4 -->|calls| c4b3e9d1_8ba5_707f_4649_4d5a628a2433 91fc1e9f_da8a_5369_c205_f01b69e8bd01["SSLException()"] 9f77679b_188a_ea47_0bb0_025af752e7f4 -->|calls| 91fc1e9f_da8a_5369_c205_f01b69e8bd01 fe023d64_85b8_5dd0_6b19_7572a209de43["writePlaintextData()"] 9f77679b_188a_ea47_0bb0_025af752e7f4 -->|calls| fe023d64_85b8_5dd0_6b19_7572a209de43 a8911f03_7846_4c48_375e_75acd519b8f2["closeAll()"] 9f77679b_188a_ea47_0bb0_025af752e7f4 -->|calls| a8911f03_7846_4c48_375e_75acd519b8f2 style 9f77679b_188a_ea47_0bb0_025af752e7f4 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
handler/src/main/java/io/netty/handler/ssl/ReferenceCountedOpenSslEngine.java lines 777–1071
@Override
public final SSLEngineResult wrap(
final ByteBuffer[] srcs, int offset, final int length, final ByteBuffer dst) throws SSLException {
// Throw required runtime exceptions
checkNotNullWithIAE(srcs, "srcs");
checkNotNullWithIAE(dst, "dst");
if (offset >= srcs.length || offset + length > srcs.length) {
throw new IndexOutOfBoundsException(
"offset: " + offset + ", length: " + length +
" (expected: offset <= offset + length <= srcs.length (" + srcs.length + "))");
}
if (dst.isReadOnly()) {
throw new ReadOnlyBufferException();
}
synchronized (this) {
if (isOutboundDone()) {
// All drained in the outbound buffer
return isInboundDone() || destroyed ? CLOSED_NOT_HANDSHAKING : NEED_UNWRAP_CLOSED;
}
int bytesProduced = 0;
ByteBuf bioReadCopyBuf = null;
try {
// Setup the BIO buffer so that we directly write the encryption results into dst.
if (dst.isDirect()) {
SSL.bioSetByteBuffer(networkBIO, bufferAddress(dst) + dst.position(), dst.remaining(),
true);
} else {
bioReadCopyBuf = alloc.directBuffer(dst.remaining());
SSL.bioSetByteBuffer(networkBIO, memoryAddress(bioReadCopyBuf), bioReadCopyBuf.writableBytes(),
true);
}
int bioLengthBefore = SSL.bioLengthByteBuffer(networkBIO);
// Explicitly use outboundClosed as we want to drain any bytes that are still present.
if (outboundClosed) {
// If the outbound was closed we want to ensure we can produce the alert to the destination buffer.
// This is true even if we not using jdkCompatibilityMode.
//
// We use a plaintextLength of 2 as we at least want to have an alert fit into it.
// https://tools.ietf.org/html/rfc5246#section-7.2
if (!isBytesAvailableEnoughForWrap(dst.remaining(), 2, 1)) {
return new SSLEngineResult(BUFFER_OVERFLOW, getHandshakeStatus(), 0, 0);
}
// There is something left to drain.
// See https://github.com/netty/netty/issues/6260
bytesProduced = SSL.bioFlushByteBuffer(networkBIO);
if (bytesProduced <= 0) {
return newResultMayFinishHandshake(NOT_HANDSHAKING, 0, 0);
}
// It is possible when the outbound was closed there was not enough room in the non-application
// buffers to hold the close_notify. We should keep trying to close until we consume all the data
// OpenSSL can give us.
if (!doSSLShutdown()) {
return newResultMayFinishHandshake(NOT_HANDSHAKING, 0, bytesProduced);
}
bytesProduced = bioLengthBefore - SSL.bioLengthByteBuffer(networkBIO);
return newResultMayFinishHandshake(NEED_WRAP, 0, bytesProduced);
}
// Flush any data that may be implicitly generated by OpenSSL (handshake, close, etc..).
SSLEngineResult.HandshakeStatus status = NOT_HANDSHAKING;
HandshakeState oldHandshakeState = handshakeState;
// Prepare OpenSSL to work in server mode and receive handshake
if (handshakeState != HandshakeState.FINISHED) {
if (handshakeState != HandshakeState.STARTED_EXPLICITLY) {
// Update accepted so we know we triggered the handshake via wrap
handshakeState = HandshakeState.STARTED_IMPLICITLY;
}
// Flush any data that may have been written implicitly during the handshake by OpenSSL.
bytesProduced = SSL.bioFlushByteBuffer(networkBIO);
if (pendingException != null) {
// TODO(scott): It is possible that when the handshake failed there was not enough room in the
Domain
Subdomains
Calls
- SSLException()
- bufferAddress()
- closeAll()
- doSSLShutdown()
- getApplicationBufferSize()
- getHandshakeStatus()
- handshake()
- handshakeException()
- isBytesAvailableEnoughForWrap()
- isInboundDone()
- isOutboundDone()
- mayFinishHandshake()
- needWrapAgain()
- readPlaintextData()
- rejectRemoteInitiatedRenegotiation()
- release()
- resetSingleDstBuffer()
- resetSingleSrcBuffer()
- shutdown()
- singleDstBuffer()
- singleSrcBuffer()
- sslPending0()
- tryExpandApplicationBufferSize()
- writePlaintextData()
Source
Frequently Asked Questions
What does SSLEngineResult() do?
SSLEngineResult() is a function in the netty codebase, defined in handler/src/main/java/io/netty/handler/ssl/ReferenceCountedOpenSslEngine.java.
Where is SSLEngineResult() defined?
SSLEngineResult() is defined in handler/src/main/java/io/netty/handler/ssl/ReferenceCountedOpenSslEngine.java at line 777.
What does SSLEngineResult() call?
SSLEngineResult() calls 24 function(s): SSLException, bufferAddress, closeAll, doSSLShutdown, getApplicationBufferSize, getHandshakeStatus, handshake, handshakeException, and 16 more.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free