8287109: Distrust.java failed with CertificateExpiredException

Reviewed-by: mullan
This commit is contained in:
Rajan Halade 2022-05-23 20:32:52 +00:00
parent 6a192206b8
commit 5b7d066ca5
4 changed files with 24 additions and 152 deletions

View File

@ -628,8 +628,6 @@ sun/security/provider/PolicyParser/ExtDirsChange.java 8039280 generic-
sun/security/provider/PolicyParser/PrincipalExpansionError.java 8039280 generic-all
sun/security/ssl/SSLSessionImpl/NoInvalidateSocketException.java 8277970 linux-all,macosx-x64
sun/security/ssl/X509TrustManagerImpl/Symantec/Distrust.java 8287109 generic-all
############################################################################
# jdk_sound

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -54,15 +54,14 @@ public class Distrust {
// Each of the roots have a test certificate chain stored in a file
// named "<root>-chain.pem".
private static String[] rootsToTest = new String[] {
"geotrustglobalca", "geotrustprimarycag2", "geotrustprimarycag3",
"geotrustprimarycag2", "geotrustprimarycag3",
"geotrustuniversalca", "thawteprimaryrootca", "thawteprimaryrootcag2",
"thawteprimaryrootcag3", "verisignclass3g3ca", "verisignclass3g4ca",
"verisignclass3g5ca", "verisignuniversalrootca" };
// Each of the subCAs with a delayed distrust date have a test certificate
// chain stored in a file named "<subCA>-chain.pem".
private static String[] subCAsToTest = new String[] {
"appleistca2g1", "appleistca8g1" };
private static String[] subCAsToTest = new String[]{"appleistca8g1"};
// A date that is after the restrictions take affect
private static final Date APRIL_17_2019 =
@ -180,6 +179,11 @@ public class Distrust {
throw new Exception("chain should be invalid");
}
} catch (CertificateException ce) {
// expired TLS certificates should not be treated as failure
if (expired(ce)) {
System.err.println("Test is N/A, chain is expired");
return;
}
if (valid) {
throw new Exception("Unexpected exception, chain " +
"should be valid", ce);
@ -187,6 +191,7 @@ public class Distrust {
if (ce instanceof ValidatorException) {
ValidatorException ve = (ValidatorException)ce;
if (ve.getErrorType() != ValidatorException.T_UNTRUSTED_CERT) {
ce.printStackTrace(System.err);
throw new Exception("Unexpected exception: " + ce);
}
} else {
@ -195,6 +200,21 @@ public class Distrust {
}
}
// check if a cause of exception is an expired cert
private static boolean expired(CertificateException ce) {
if (ce instanceof CertificateExpiredException) {
return true;
}
Throwable t = ce.getCause();
while (t != null) {
if (t instanceof CertificateExpiredException) {
return true;
}
t = t.getCause();
}
return false;
}
private static X509Certificate[] loadCertificateChain(String name)
throws Exception {
try (InputStream in = new FileInputStream(TEST_SRC + File.separator +

View File

@ -1,80 +0,0 @@
-----BEGIN CERTIFICATE-----
MIIGGzCCBQOgAwIBAgIITJltLCqcD0gwDQYJKoZIhvcNAQELBQAwYjEcMBoGA1UE
AxMTQXBwbGUgSVNUIENBIDIgLSBHMTEgMB4GA1UECxMXQ2VydGlmaWNhdGlvbiBB
dXRob3JpdHkxEzARBgNVBAoTCkFwcGxlIEluYy4xCzAJBgNVBAYTAlVTMB4XDTE5
MDEwODIxMTcxNFoXDTIwMDgwODIxMjcwMFowgaoxSjBIBgNVBAMMQWFjdGl2ZS5n
ZW90cnVzdC1nbG9iYWwtY2EudGVzdC1wYWdlcy5jZXJ0aWZpY2F0ZW1hbmFnZXIu
YXBwbGUuY29tMSUwIwYDVQQLDBxtYW5hZ2VtZW50OmlkbXMuZ3JvdXAuODY0ODU5
MRMwEQYDVQQKDApBcHBsZSBJbmMuMRMwEQYDVQQIDApDYWxpZm9ybmlhMQswCQYD
VQQGEwJVUzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMCjFUrVHTEX
0aVU6x9LiGa6oVr9blaCsMFrLicPQguc43Vs/pN+g4jzRXsTSMe9XefezBQb6tzZ
SMRXVB4kWMr4K1BVgQDkXeyoh4KrXRkdEF9ZIJPNxwTmmYUOc5M6NOYwkLelYz+t
7n1iNIGylbjwU4qwauElk2alFVqYTEPDLzwvqV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