I am using the Bouncycastle lib to create certificates from PKCS10 requests using the X509v3CertificateBuilder class.
It returns an X509CertificateHolder object that contains the generated certificate. If I call getIssuer on the holder, it returns the issuer outstanding name in the correct order (the same is returned if I call getSubjectX500Principal () in the issuer certificate), if I parse the encoded version from the holder using java CertificateFactory, getIssuerX500Principal () of the generated certificate returns DN in reverse, what's wrong?
Here is a sample code of what I'm trying to do:
X509CertificateHolder holder = certBuilder.build(sigGen); holder.getIssuer(); //Returns the DN in the correct order (same as in issuer cert) CertificateFactory certFactory = CertificateFactory.getInstance("X.509"); X509Certificate cert = (X509Certificate) certFactory.generateCertificate(new ByteArrayInputStream(holder.getEncoded())); cert.getIssuerX500Principal().getName(); //Returns issuer DN in reverse order
source share