8255348: NPE in PKIXCertPathValidator event logging code

Reviewed-by: mullan
This commit is contained in:
Sean Coffey 2021-01-22 15:31:35 +00:00
parent a97f3c18d5
commit 18eb6d9e34
6 changed files with 76 additions and 25 deletions

View file

@ -241,13 +241,13 @@ public final class PKIXCertPathValidator extends CertPathValidatorSpi {
X509ValidationEvent xve = new X509ValidationEvent();
if (xve.shouldCommit() || EventHelper.isLoggingSecurity()) {
int[] certIds = params.certificates().stream()
.mapToInt(x -> x.hashCode())
.mapToInt(Certificate::hashCode)
.toArray();
int anchorCertId =
anchor.getTrustedCert().hashCode();
int anchorCertId = (anchorCert != null) ?
anchorCert.hashCode() : anchor.getCAPublicKey().hashCode();
if (xve.shouldCommit()) {
xve.certificateId = anchorCertId;
int certificatePos = 1; //anchor cert
int certificatePos = 1; // most trusted CA
xve.certificatePosition = certificatePos;
xve.validationCounter = validationCounter.incrementAndGet();
xve.commit();