I have two certificates. One certificate is the issuer of another certificate.
how can I see with Java code that my issuer certificate is indeed an issuer?
I know that the AuthorityKeyIdentifier of my certificate and the SubjectKeyIdentifie of the issuer certificates must be the same. I am marked and they are the same .
but with java code I have this result:
CertificateFactory certFactory = CertificateFactory.getInstance("X.509"); InputStream usrCertificateIn = new FileInputStream("/usr.cer"); X509Certificate cert = (X509Certificate) certFactory.generateCertificate(usrCertificateIn); InputStream SiningCACertificateIn = new FileInputStream("/siningCA.cer"); X509Certificate issuer = (X509Certificate) certFactory.generateCertificate(SiningCACertificateIn); byte[] octets = (ASN1OctetString.getInstance(cert.getExtensionValue("2.5.29.35")).getOctets()); System.out.println(Arrays.toString(octets) + " bouncycastle, AuthorityKeyIdentifier"); System.out.println(Arrays.toString(cert.getExtensionValue("2.5.29.35")) + "java.security, AuthorityKeyIdentifier"); octets = ASN1OctetString.getInstance(issuer.getExtensionValue("2.5.29.14")).getOctets(); System.out.println((Arrays.toString(octets) + "bouncycastle, SubjectKeyIdentifie ")); System.out.println(Arrays.toString(issuer.getExtensionValue("2.5.29.14")) + "java.security, SubjectKeyIdentifie ");
and the result:
[48, 22, -128, 20, 52, -105, 49, -70, -24, 78, 127, -113, -25, 55, 39, 99, 46, 6, 31, 66, -55, -86, -79, 113 ] bouncycastle, AuthorityKeyIdentifier
[ 4 , 24, 48, 22, -128, 20, 52, -105, 49, -70, -24, 78, 127, -113, -25, 55, 39, 99, 46, 6, 31, 66 , -55, -86, -79, 113 ] java.security, AuthorityKeyIdentifier
and another array of bytes that MUST BE TESTED, BUT IT IS NOT at the beginning of the array another byte is added.
[ 4, 20, 52, -105, 49, -70, -24, 78, 127, -113, -25, 55, 39, 99, 46, 6, 31, 66, -55, -86, -79 , 113 ] bouncycastle, SubjectKeyIdentifie
[4, 22, 4, 20, 52, -105, 49, -70, -24, 78, 127, -113, -25, 55, 39, 99, 46, 6, 31, 66, -55, - 86, -79, 113 ] java.security, SubjectKeyIdentifie
question 1) Can I calculate key identifiers to get the same arrays ?
question 2) is there any other way to prove that one certificate is the issuer of other certificates .