Skip to content

Commit 645ef7b

Browse files
Alexey BakhtinRealCLanger
authored andcommitted
8349594: Enhance TLS protocol support
Reviewed-by: mbalao, andrew Backport-of: d40052ee9789908fb7c06527ab644fdd217a6bea
1 parent f07c7d3 commit 645ef7b

File tree

3 files changed

+28
-3
lines changed

3 files changed

+28
-3
lines changed

src/java.base/share/classes/sun/security/ssl/CertificateMessage.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -1160,6 +1160,15 @@ public void consume(ConnectionContext context,
11601160

11611161
// clean up this consumer
11621162
hc.handshakeConsumers.remove(SSLHandshake.CERTIFICATE.id);
1163+
1164+
// Ensure that the Certificate message has not been sent w/o
1165+
// an EncryptedExtensions preceding
1166+
if (hc.handshakeConsumers.containsKey(
1167+
SSLHandshake.ENCRYPTED_EXTENSIONS.id)) {
1168+
throw hc.conContext.fatal(Alert.UNEXPECTED_MESSAGE,
1169+
"Unexpected Certificate handshake message");
1170+
}
1171+
11631172
T13CertificateMessage cm = new T13CertificateMessage(hc, message);
11641173
if (hc.sslConfig.isClientMode) {
11651174
if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {

src/java.base/share/classes/sun/security/ssl/CertificateVerify.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -1160,6 +1160,14 @@ public void consume(ConnectionContext context,
11601160
// Clean up this consumer
11611161
hc.handshakeConsumers.remove(SSLHandshake.CERTIFICATE_VERIFY.id);
11621162

1163+
// Ensure that the Certificate Verify message has not been sent w/o
1164+
// a Certificate message preceding
1165+
if (hc.handshakeConsumers.containsKey(
1166+
SSLHandshake.CERTIFICATE.id)) {
1167+
throw hc.conContext.fatal(Alert.UNEXPECTED_MESSAGE,
1168+
"Unexpected Certificate Verify handshake message");
1169+
}
1170+
11631171
T13CertificateVerifyMessage cvm =
11641172
new T13CertificateVerifyMessage(hc, message);
11651173
if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {

src/java.base/share/classes/sun/security/ssl/Finished.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -900,6 +900,14 @@ public void consume(ConnectionContext context,
900900

901901
private void onConsumeFinished(ClientHandshakeContext chc,
902902
ByteBuffer message) throws IOException {
903+
// Ensure that the Finished message has not been sent w/o
904+
// an EncryptedExtensions preceding
905+
if (chc.handshakeConsumers.containsKey(
906+
SSLHandshake.ENCRYPTED_EXTENSIONS.id)) {
907+
throw chc.conContext.fatal(Alert.UNEXPECTED_MESSAGE,
908+
"Unexpected Finished handshake message");
909+
}
910+
903911
// Make sure that any expected CertificateVerify message
904912
// has been received and processed.
905913
if (!chc.isResumption) {

0 commit comments

Comments
 (0)