use of sun.security.provider.certpath.CertId in project jdk8u_jdk by JetBrains.
the class CheckCertId method main.
public static void main(String[] args) throws Exception {
X509CertImpl cert = loadCert(CERT_FILENAME);
/* Compute the hash in the same way as CertId constructor */
MessageDigest hash = MessageDigest.getInstance("SHA1");
hash.update(cert.getSubjectX500Principal().getEncoded());
byte[] expectedHash = hash.digest();
CertId certId = new CertId(cert, null);
byte[] receivedHash = certId.getIssuerNameHash();
if (!Arrays.equals(expectedHash, receivedHash)) {
throw new Exception("Bad hash value for issuer name in CertId object");
}
}
Aggregations