Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit80ba42a

Browse files
clivevergheseRealCLanger
authored andcommitted
8268199: Correct certificate requests
Reviewed-by: yanBackport-of: afeccc7639d3d09041b58cf0f5672eb7310b2cbd
1 parent6dfe013 commit80ba42a

File tree

2 files changed

+37
-12
lines changed

2 files changed

+37
-12
lines changed

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

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
importjava.security.cert.X509Certificate;
3232
importjava.text.MessageFormat;
3333
importjava.util.ArrayList;
34+
importjava.util.Arrays;
3435
importjava.util.Collection;
3536
importjava.util.Collections;
3637
importjava.util.HashSet;
@@ -44,6 +45,7 @@
4445
importsun.security.ssl.CipherSuite.KeyExchange;
4546
importsun.security.ssl.SSLHandshake.HandshakeMessage;
4647
importsun.security.ssl.X509Authentication.X509Possession;
48+
importsun.security.ssl.X509Authentication.X509PossessionGenerator;
4749

4850
/**
4951
* Pack of the CertificateRequest handshake message.
@@ -716,12 +718,11 @@ public void consume(ConnectionContext context,
716718
chc.handshakeSession.setPeerSupportedSignatureAlgorithms(sss);
717719
chc.peerSupportedAuthorities =crm.getAuthorities();
718720

719-
// For TLS 1.2, we no longer use the certificate_types field
720-
// from the CertificateRequest message to directly determine
721-
// the SSLPossession. Instead, the choosePossession method
722-
// will use the accepted signature schemes in the message to
723-
// determine the set of acceptable certificate types to select from.
724-
SSLPossessionpos =choosePossession(chc);
721+
// For TLS 1.2, we need to use a combination of the CR message's
722+
// allowed key types and the signature algorithms in order to
723+
// find a certificate chain that has the right key and all certs
724+
// using one or more of the allowed cert signature schemes.
725+
SSLPossessionpos =choosePossession(chc,crm);
725726
if (pos ==null) {
726727
return;
727728
}
@@ -731,8 +732,8 @@ public void consume(ConnectionContext context,
731732
SSLHandshake.CERTIFICATE_VERIFY);
732733
}
733734

734-
privatestaticSSLPossessionchoosePossession(HandshakeContexthc)
735-
throwsIOException {
735+
privatestaticSSLPossessionchoosePossession(HandshakeContexthc,
736+
T12CertificateRequestMessagecrm)throwsIOException {
736737
if (hc.peerRequestedCertSignSchemes ==null ||
737738
hc.peerRequestedCertSignSchemes.isEmpty()) {
738739
if (SSLLogger.isOn &&SSLLogger.isOn("ssl,handshake")) {
@@ -742,6 +743,9 @@ private static SSLPossession choosePossession(HandshakeContext hc)
742743
returnnull;
743744
}
744745

746+
// Put the CR key type into a more friendly format for searching
747+
List<String>crKeyTypes =Arrays.asList(crm.getKeyTypes());
748+
745749
Collection<String>checkedKeyTypes =newHashSet<>();
746750
for (SignatureSchemess :hc.peerRequestedCertSignSchemes) {
747751
if (checkedKeyTypes.contains(ss.keyAlgorithm)) {
@@ -768,14 +772,35 @@ private static SSLPossession choosePossession(HandshakeContext hc)
768772
continue;
769773
}
770774

771-
SSLAuthenticationka =X509Authentication.valueOf(ss);
775+
X509Authenticationka =X509Authentication.valueOf(ss);
772776
if (ka ==null) {
773777
if (SSLLogger.isOn &&SSLLogger.isOn("ssl,handshake")) {
774778
SSLLogger.warning(
775779
"Unsupported authentication scheme: " +ss.name);
776780
}
777781
checkedKeyTypes.add(ss.keyAlgorithm);
778782
continue;
783+
}else {
784+
// Any auth object will have a possession generator and
785+
// we need to make sure the key types for that generator
786+
// share at least one common algorithm with the CR's
787+
// allowed key types.
788+
if (ka.possessionGeneratorinstanceof
789+
X509PossessionGenerator) {
790+
X509PossessionGeneratorxpg =
791+
(X509PossessionGenerator)ka.possessionGenerator;
792+
if (Collections.disjoint(crKeyTypes,
793+
Arrays.asList(xpg.keyTypes))) {
794+
if (SSLLogger.isOn &&
795+
SSLLogger.isOn("ssl,handshake")) {
796+
SSLLogger.warning(
797+
"Unsupported authentication scheme: " +
798+
ss.name);
799+
}
800+
checkedKeyTypes.add(ss.keyAlgorithm);
801+
continue;
802+
}
803+
}
779804
}
780805

781806
SSLPossessionpos =ka.createPossession(hc);

‎src/java.base/share/classes/sun/security/ssl/X509Authentication.java‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,9 @@ static final class X509Credentials implements SSLCredentials {
191191
}
192192
}
193193

194-
privatestaticfinal
195-
classX509PossessionGeneratorimplementsSSLPossessionGenerator {
196-
privatefinalString[]keyTypes;
194+
staticfinalclassX509PossessionGenerator
195+
implementsSSLPossessionGenerator {
196+
finalString[]keyTypes;
197197

198198
privateX509PossessionGenerator(String[]keyTypes) {
199199
this.keyTypes =keyTypes;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp