Skip to content
This repository has been archived by the owner on Feb 2, 2023. It is now read-only.

Commit

Permalink
8287411: Enhance DTLS performance
Browse files Browse the repository at this point in the history
Reviewed-by: yan
Backport-of: 911c24564444096c0c98f6dc308220d48b42d6d3
  • Loading branch information
Alexey Bakhtin authored and Yuri Nesterenko committed Jan 16, 2023
1 parent 60eb61e commit 8dc1bee
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 17 deletions.
39 changes: 22 additions & 17 deletions src/java.base/share/classes/sun/security/ssl/ClientHello.java
Expand Up @@ -1374,25 +1374,30 @@ public void consume(ConnectionContext context,
shc.resumingSession = resumingSession ? previous : null;
}

HelloCookieManager hcm =
shc.sslContext.getHelloCookieManager(ProtocolVersion.DTLS10);
if (!shc.isResumption &&
!hcm.isCookieValid(shc, clientHello, clientHello.cookie)) {
//
// Perform cookie exchange for DTLS handshaking if no cookie
// or the cookie is invalid in the ClientHello message.
//
// update the responders
shc.handshakeProducers.put(
SSLHandshake.HELLO_VERIFY_REQUEST.id,
SSLHandshake.HELLO_VERIFY_REQUEST);

//
// produce response handshake message
//
SSLHandshake.HELLO_VERIFY_REQUEST.produce(context, clientHello);
// We will by default exchange DTLS cookies for all handshakes
// (new and resumed) unless jdk.tls.enableDtlsResumeCookie=false.
// The property only affects the cookie exchange for resumption.
if (!shc.isResumption || SSLConfiguration.enableDtlsResumeCookie) {
HelloCookieManager hcm =
shc.sslContext.getHelloCookieManager(ProtocolVersion.DTLS10);
if (!hcm.isCookieValid(shc, clientHello, clientHello.cookie)) {
//
// Perform cookie exchange for DTLS handshaking if no cookie
// or the cookie is invalid in the ClientHello message.
//
// update the responders
shc.handshakeProducers.put(
SSLHandshake.HELLO_VERIFY_REQUEST.id,
SSLHandshake.HELLO_VERIFY_REQUEST);

//
// produce response handshake message
//
SSLHandshake.HELLO_VERIFY_REQUEST.produce(context, clientHello);

return;
return;
}
}

// cache the client random number for further using
Expand Down
Expand Up @@ -113,6 +113,9 @@ final class SSLConfiguration implements Cloneable {
static final int maxCertificateChainLength = GetIntegerAction.privilegedGetProperty(
"jdk.tls.maxCertificateChainLength", 10);

static final boolean enableDtlsResumeCookie = Utilities.getBooleanProperty(
"jdk.tls.enableDtlsResumeCookie", true);

// Is the extended_master_secret extension supported?
static {
boolean supportExtendedMasterSecret = Utilities.getBooleanProperty(
Expand Down

0 comments on commit 8dc1bee

Please sign in to comment.