X500Principal Distinguished Name order

后端 未结 1 1321
猫巷女王i
猫巷女王i 2021-02-10 07:02

I\'m using the Bouncycastle lib to generate certificates from PKCS10 requests using the X509v3CertificateBuilder class.

It returns build a X509CertificateHolder object w

1条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-10 07:17

    Since I need to compare distinguished names, I resolved by parsing the DN with LdapName class and comparing the parsed rdns:

    boolean DNmatches(X500Principal p1, X500Principal p2) {
        List rdn1 = new LdapName(p1.getName()).getRdns();
        List rdn2 = new LdapName(p2.getName()).getRdns();
    
        if(rdn1.size() != rdn2.size())
            return false;
    
        return rdn1.containsAll(rdn2);
    }
    

    0 讨论(0)
提交回复
热议问题