Skip to content

Commit 820ba50

Browse files
committed
Backport 99b4bab
1 parent 37f8029 commit 820ba50

File tree

6 files changed

+494
-13
lines changed

6 files changed

+494
-13
lines changed

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

Lines changed: 10 additions & 7 deletions
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, 2021, 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
@@ -706,13 +706,16 @@ public void consume(ConnectionContext context,
706706
chc.handshakeProducers.put(SSLHandshake.CERTIFICATE.id,
707707
SSLHandshake.CERTIFICATE);
708708

709-
List<SignatureScheme> sss = new LinkedList<>();
710-
for (int id : crm.algorithmIds) {
711-
SignatureScheme ss = SignatureScheme.valueOf(id);
712-
if (ss != null) {
713-
sss.add(ss);
714-
}
709+
List<SignatureScheme> sss =
710+
SignatureScheme.getSupportedAlgorithms(
711+
chc.sslConfig,
712+
chc.algorithmConstraints, chc.negotiatedProtocol,
713+
crm.algorithmIds);
714+
if (sss == null || sss.isEmpty()) {
715+
throw chc.conContext.fatal(Alert.HANDSHAKE_FAILURE,
716+
"No supported signature algorithm");
715717
}
718+
716719
chc.peerRequestedSignatureSchemes = sss;
717720
chc.peerRequestedCertSignSchemes = sss; // use the same schemes
718721
chc.handshakeSession.setPeerSupportedSignatureAlgorithms(sss);

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,10 @@ public void consume(ConnectionContext context,
281281
shc.sslConfig,
282282
shc.algorithmConstraints, shc.negotiatedProtocol,
283283
spec.signatureSchemes);
284+
if (sss == null || sss.isEmpty()) {
285+
throw shc.conContext.fatal(Alert.HANDSHAKE_FAILURE,
286+
"No supported signature algorithm");
287+
}
284288
shc.peerRequestedSignatureSchemes = sss;
285289

286290
// If no "signature_algorithms_cert" extension is present, then
@@ -332,7 +336,7 @@ public void absent(ConnectionContext context,
332336
if (shc.negotiatedProtocol.useTLS13PlusSpec()) {
333337
throw shc.conContext.fatal(Alert.MISSING_EXTENSION,
334338
"No mandatory signature_algorithms extension in the " +
335-
"received CertificateRequest handshake message");
339+
"received ClientHello handshake message");
336340
}
337341
}
338342
}
@@ -516,6 +520,10 @@ public void consume(ConnectionContext context,
516520
chc.sslConfig,
517521
chc.algorithmConstraints, chc.negotiatedProtocol,
518522
spec.signatureSchemes);
523+
if (sss == null || sss.isEmpty()) {
524+
throw chc.conContext.fatal(Alert.HANDSHAKE_FAILURE,
525+
"No supported signature algorithm");
526+
}
519527
chc.peerRequestedSignatureSchemes = sss;
520528

521529
// If no "signature_algorithms_cert" extension is present, then

test/jdk/javax/net/ssl/templates/SSLContextTemplate.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2018, 2021, 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
@@ -478,7 +478,7 @@ private SSLContext createSSLContext(
478478
/*
479479
* Create an instance of KeyManager with the specified key materials.
480480
*/
481-
private KeyManager createKeyManager(
481+
static KeyManager createKeyManager(
482482
String[] keyMaterialCerts,
483483
String[] keyMaterialKeys,
484484
String[] keyMaterialKeyAlgs,
@@ -534,7 +534,7 @@ private KeyManager createKeyManager(
534534
/*
535535
* Create an instance of TrustManager with the specified trust materials.
536536
*/
537-
private TrustManager createTrustManager(
537+
static TrustManager createTrustManager(
538538
String[] trustedMaterials,
539539
ContextParameters params) throws Exception {
540540

test/jdk/javax/net/ssl/templates/SSLEngineTemplate.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ private void runTest() throws Exception {
197197
}
198198
}
199199

200-
private static boolean isOpen(SSLEngine engine) {
200+
static boolean isOpen(SSLEngine engine) {
201201
return (!engine.isOutboundDone() || !engine.isInboundDone());
202202
}
203203

@@ -240,7 +240,7 @@ protected static void runDelegatedTasks(SSLEngine engine) throws Exception {
240240
}
241241

242242
// Simple check to make sure everything came across as expected.
243-
private static void checkTransfer(ByteBuffer a, ByteBuffer b)
243+
static void checkTransfer(ByteBuffer a, ByteBuffer b)
244244
throws Exception {
245245
a.flip();
246246
b.flip();

0 commit comments

Comments
 (0)