Skip to content

Commit

Permalink
Allow server initiated renegotiate when using OpenSSL / BoringSSL bas…
Browse files Browse the repository at this point in the history
…ed SSLEngine (netty#11601)


Motivation:

We should allow server initiated renegotiation when OpenSSL / BoringSSL bases SSLEngine is used as it might be used for client auth.

Modifications:

- Upgrade netty-tcnative version to be able to allow renegotiate once
- Adjust code

Result
Fixes netty#11529
  • Loading branch information
normanmaurer authored Aug 20, 2021
1 parent 36eb399 commit 33b63c3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,13 @@ public List<byte[]> getStatusResponses() {
}
}

if (OpenSsl.isBoringSSL() && clientMode) {
// If in client-mode and BoringSSL let's allow to renegotiate once as the server may use this
// for client auth.
//
// See https://github.com/netty/netty/issues/11529
SSL.setRenegotiateMode(ssl, SSL.SSL_RENEGOTIATE_ONCE);
}
// setMode may impact the overhead.
calculateMaxWrapOverhead();
} catch (Throwable cause) {
Expand Down Expand Up @@ -1359,7 +1366,9 @@ private void rejectRemoteInitiatedRenegotiation() throws SSLHandshakeException {
// As rejectRemoteInitiatedRenegotiation() is called in a finally block we also need to check if we shutdown
// the engine before as otherwise SSL.getHandshakeCount(ssl) will throw an NPE if the passed in ssl is 0.
// See https://github.com/netty/netty/issues/7353
if (!isDestroyed() && SSL.getHandshakeCount(ssl) > 1 &&
if (!isDestroyed() && (!clientMode && SSL.getHandshakeCount(ssl) > 1 ||
// Let's allow to renegotiate once for client auth.
clientMode && SSL.getHandshakeCount(ssl) > 2) &&
// As we may count multiple handshakes when TLSv1.3 is used we should just ignore this here as
// renegotiation is not supported in TLSv1.3 as per spec.
!SslProtocols.TLS_v1_3.equals(session.getProtocol()) && handshakeState == HandshakeState.FINISHED) {
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@
<!-- keep in sync with PlatformDependent#ALLOWED_LINUX_OS_CLASSIFIERS -->
<os.detection.classifierWithLikes>fedora,suse,arch</os.detection.classifierWithLikes>
<tcnative.artifactId>netty-tcnative</tcnative.artifactId>
<tcnative.version>2.0.40.Final</tcnative.version>
<tcnative.version>2.0.41.Final</tcnative.version>
<tcnative.classifier>${os.detected.classifier}</tcnative.classifier>
<conscrypt.groupId>org.conscrypt</conscrypt.groupId>
<conscrypt.artifactId>conscrypt-openjdk-uber</conscrypt.artifactId>
Expand Down

0 comments on commit 33b63c3

Please sign in to comment.