X509Certificate: what's the difference between getIssuerDN () and getSubjectDN () methods

I am using the X509Certificate class in java and when I want to get the subject name I try:

x509certificate.getIssuerDN().getName();

      

and

x509certificate.getSubjectDN().getName();

      

both methods have the same result. So what's the difference between them?

+3


source to share


2 answers


These methods are read from two different certificate fields. It can return the same result in your case, but is not generic.



Refer to getIssuerDN () and getSubjectDN () .

+2


source


public abstract Principal getIssuerDN()

Desecrated method , replaced by getIssuerX500Principal()

. Returns the issuer as an implementation object that should not be used by portable code. Gets the value of the issuer certificate (distinguished name). The Issuer Name identifies the entity that signed (and issued) the certificate.

The issuer name field contains an X.500 distinguished name (DN).

The name describes a hierarchical name made up of attributes such as the country name and corresponding values, such as US. The AttributeValue component type is determined by the AttributeType attribute; in general it will be directoryString. The DirectoryString is usually one of PrintableString, TeletexString, or UniversalString.

Returns : The Principal whose name is the distinguished name of the issuer.



public abstract Principal getSubjectDN()

Desecrated method , replaced by getSubjectX500Principal()

. Returns the object as an implementation-specific Principal object that should not be relied on for portable code. Gets the subject value (subject distinguished name) from the certificate. If the object's value is empty, the getName()

Principal object's return method returns an empty string ("").

See getIssuerDN for Name and other relevant definitions.

Returns : The principal whose name is the name of the subject.

+1


source







All Articles