Skip to content

Commit 898c007

Browse files
Alexey Bakhtingnu-andrew
authored andcommitted
8349594: Enhance TLS protocol support
Reviewed-by: mbalao, andrew Backport-of: d40052ee9789908fb7c06527ab644fdd217a6bea
1 parent 77d75a1 commit 898c007

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, 2020, 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
@@ -1166,6 +1166,15 @@ public void consume(ConnectionContext context,
11661166

11671167
// clean up this consumer
11681168
hc.handshakeConsumers.remove(SSLHandshake.CERTIFICATE.id);
1169+
1170+
// Ensure that the Certificate message has not been sent w/o
1171+
// an EncryptedExtensions preceding
1172+
if (hc.handshakeConsumers.containsKey(
1173+
SSLHandshake.ENCRYPTED_EXTENSIONS.id)) {
1174+
throw hc.conContext.fatal(Alert.UNEXPECTED_MESSAGE,
1175+
"Unexpected Certificate handshake message");
1176+
}
1177+
11691178
T13CertificateMessage cm = new T13CertificateMessage(hc, message);
11701179
if (hc.sslConfig.isClientMode) {
11711180
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, 2018, 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
@@ -1157,6 +1157,14 @@ public void consume(ConnectionContext context,
11571157
// Clean up this consumer
11581158
hc.handshakeConsumers.remove(SSLHandshake.CERTIFICATE_VERIFY.id);
11591159

1160+
// Ensure that the Certificate Verify message has not been sent w/o
1161+
// a Certificate message preceding
1162+
if (hc.handshakeConsumers.containsKey(
1163+
SSLHandshake.CERTIFICATE.id)) {
1164+
throw hc.conContext.fatal(Alert.UNEXPECTED_MESSAGE,
1165+
"Unexpected Certificate Verify handshake message");
1166+
}
1167+
11601168
T13CertificateVerifyMessage cvm =
11611169
new T13CertificateVerifyMessage(hc, message);
11621170
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, 2018, 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
@@ -881,6 +881,14 @@ public void consume(ConnectionContext context,
881881

882882
private void onConsumeFinished(ClientHandshakeContext chc,
883883
ByteBuffer message) throws IOException {
884+
// Ensure that the Finished message has not been sent w/o
885+
// an EncryptedExtensions preceding
886+
if (chc.handshakeConsumers.containsKey(
887+
SSLHandshake.ENCRYPTED_EXTENSIONS.id)) {
888+
throw chc.conContext.fatal(Alert.UNEXPECTED_MESSAGE,
889+
"Unexpected Finished handshake message");
890+
}
891+
884892
// Make sure that any expected CertificateVerify message
885893
// has been received and processed.
886894
if (!chc.isResumption) {

0 commit comments

Comments
 (0)