Search in sources :

Example 1 with CertId

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");
    }
}
Also used : CertId(sun.security.provider.certpath.CertId) X509CertImpl(sun.security.x509.X509CertImpl) MessageDigest(java.security.MessageDigest)

Aggregations

MessageDigest (java.security.MessageDigest)1 CertId (sun.security.provider.certpath.CertId)1 X509CertImpl (sun.security.x509.X509CertImpl)1