Skip to content

Commit bab305a

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

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, 2022, 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
@@ -1129,6 +1129,15 @@ public void consume(ConnectionContext context,
11291129

11301130
// clean up this consumer
11311131
hc.handshakeConsumers.remove(SSLHandshake.CERTIFICATE.id);
1132+
1133+
// Ensure that the Certificate message has not been sent w/o
1134+
// an EncryptedExtensions preceding
1135+
if (hc.handshakeConsumers.containsKey(
1136+
SSLHandshake.ENCRYPTED_EXTENSIONS.id)) {
1137+
throw hc.conContext.fatal(Alert.UNEXPECTED_MESSAGE,
1138+
"Unexpected Certificate handshake message");
1139+
}
1140+
11321141
T13CertificateMessage cm = new T13CertificateMessage(hc, message);
11331142
if (hc.sslConfig.isClientMode) {
11341143
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, 2022, 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
@@ -1163,6 +1163,14 @@ public void consume(ConnectionContext context,
11631163
// Clean up this consumer
11641164
hc.handshakeConsumers.remove(SSLHandshake.CERTIFICATE_VERIFY.id);
11651165

1166+
// Ensure that the Certificate Verify message has not been sent w/o
1167+
// a Certificate message preceding
1168+
if (hc.handshakeConsumers.containsKey(
1169+
SSLHandshake.CERTIFICATE.id)) {
1170+
throw hc.conContext.fatal(Alert.UNEXPECTED_MESSAGE,
1171+
"Unexpected Certificate Verify handshake message");
1172+
}
1173+
11661174
T13CertificateVerifyMessage cvm =
11671175
new T13CertificateVerifyMessage(hc, message);
11681176
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, 2022, 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)