How to show SSL Issuer And Owner Information

+1 vote
asked Jan 13, 2015 by ganeshspy (900 points)
edited Jan 13, 2015

Hi,

How to show SSL Issuer And Owner Information?

When i get certificate from ValidatingCertificate event.

I need to show information about to Issuer and owner of that certificate.

Applies to: Rebex FTP/SSL

1 Answer

+1 vote
answered Jan 13, 2015 by Tomas Knopp (58,880 points)
edited Jan 13, 2015
 
Best answer

Hello, there are the Certificate.GetIssuerName and Certificate.GetIssuer() methods for the certificate issuer; and Certificate.GetSubjectName() and Certificate.GetSubject() methods for the certificate owner. Please see the following code for an example:

    void ShowCertificateInfo(Certificate cert)
    {
        // issuer of the certificate
        string issuerName = cert.GetIssuerName();
        DistinguishedName dnIssuer = cert.GetIssuer(); // DistiguishedName enables you to inspect/parse individual fields

        // owner of the certificate
        string ownerName = cert.GetSubjectName();
        DistinguishedName dnOwner = cert.GetSubject(); // DistiguishedName enables you to inspect/parse individual fields

        Console.WriteLine("Certificate info:\n Issuer = '{0}' \n Owner = '{1}'.", issuerName, ownerName);

        // -------
        // to uniquely identify a certificate, there is the Subject Key Identifier (SKI). It is actually a hash of the certificate
        byte[] ski = cert.GetSubjectKeyIdentifier();
    }

    void ftp_ValidatingCertificate(object sender, SslCertificateValidationEventArgs e)
    {
        // ...
        ShowCertificateInfo(e.Certificate);
        // ...
    }

    Ftp ftp = new Ftp();
    ftp.ValidatingCertificate += ftp_ValidatingCertificate;

    ftp.Connect("test.rebex.net", SslMode.Implicit);
    ftp.Disconnect();
...