8320372: test/jdk/sun/security/x509/DNSName/LeadingPeriod.java validity check failed
Reviewed-by: alanb
This commit is contained in:
parent
3aefd1ce71
commit
a2c0fa6f9c
@ -38,8 +38,8 @@ import java.security.cert.*;
|
|||||||
|
|
||||||
public class LeadingPeriod {
|
public class LeadingPeriod {
|
||||||
|
|
||||||
private static CertPath makeCertPath(String caStr, String targetCertStr)
|
private static CertPath makeCertPath(String targetCertStr,
|
||||||
throws CertificateException {
|
PKIXParameters params) throws CertificateException {
|
||||||
// generate certificate from cert strings
|
// generate certificate from cert strings
|
||||||
CertificateFactory cf = CertificateFactory.getInstance("X.509");
|
CertificateFactory cf = CertificateFactory.getInstance("X.509");
|
||||||
|
|
||||||
@ -47,12 +47,11 @@ public class LeadingPeriod {
|
|||||||
|
|
||||||
is = new ByteArrayInputStream(targetCertStr.getBytes());
|
is = new ByteArrayInputStream(targetCertStr.getBytes());
|
||||||
Certificate targetCert = cf.generateCertificate(is);
|
Certificate targetCert = cf.generateCertificate(is);
|
||||||
|
// set validity date so that validation won't fail when cert expires
|
||||||
is = new ByteArrayInputStream(caStr.getBytes());
|
params.setDate(((X509Certificate)targetCert).getNotBefore());
|
||||||
Certificate ca = cf.generateCertificate(is);
|
|
||||||
|
|
||||||
// generate certification path
|
// generate certification path
|
||||||
List<Certificate> list = List.of(targetCert, ca);
|
List<Certificate> list = List.of(targetCert);
|
||||||
|
|
||||||
return cf.generateCertPath(list);
|
return cf.generateCertPath(list);
|
||||||
}
|
}
|
||||||
@ -91,8 +90,8 @@ public class LeadingPeriod {
|
|||||||
String caWithoutLeadingPeriod = Files.readString(caWithoutLeadingPeriodPath);
|
String caWithoutLeadingPeriod = Files.readString(caWithoutLeadingPeriodPath);
|
||||||
|
|
||||||
PKIXParameters paramsForCAWithoutLeadingPeriod = genParams(caWithoutLeadingPeriod);
|
PKIXParameters paramsForCAWithoutLeadingPeriod = genParams(caWithoutLeadingPeriod);
|
||||||
CertPath pathWithoutLeadingPeriod = makeCertPath(caWithoutLeadingPeriod,
|
CertPath pathWithoutLeadingPeriod = makeCertPath(
|
||||||
targetFromCAWithoutPeriod);
|
targetFromCAWithoutPeriod, paramsForCAWithoutLeadingPeriod);
|
||||||
|
|
||||||
validator.validate(pathWithoutLeadingPeriod, paramsForCAWithoutLeadingPeriod);
|
validator.validate(pathWithoutLeadingPeriod, paramsForCAWithoutLeadingPeriod);
|
||||||
|
|
||||||
@ -106,7 +105,7 @@ public class LeadingPeriod {
|
|||||||
String caWithLeadingPeriod = Files.readString(caWithLeadingPeriodPath);
|
String caWithLeadingPeriod = Files.readString(caWithLeadingPeriodPath);
|
||||||
|
|
||||||
PKIXParameters paramsForCAWithLeadingPeriod = genParams(caWithLeadingPeriod);
|
PKIXParameters paramsForCAWithLeadingPeriod = genParams(caWithLeadingPeriod);
|
||||||
CertPath pathWithLeadingPeriod = makeCertPath(caWithLeadingPeriod, targetFromCAWithPeriod);
|
CertPath pathWithLeadingPeriod = makeCertPath(targetFromCAWithPeriod, paramsForCAWithLeadingPeriod);
|
||||||
|
|
||||||
validator.validate(pathWithLeadingPeriod, paramsForCAWithLeadingPeriod);
|
validator.validate(pathWithLeadingPeriod, paramsForCAWithLeadingPeriod);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user