using System; using System.IO; using Org.BouncyCastle.Asn1; using Org.BouncyCastle.Asn1.X509; using Org.BouncyCastle.Security.Certificates; namespace Org.BouncyCastle.X509 { /// /// A utility class that will extract X509Principal objects from X.509 certificates. ///

/// Use this in preference to trying to recreate a principal from a string, not all /// DNs are what they should be, so it's best to leave them encoded where they /// can be.

///
// TODO[api] Make static public class PrincipalUtilities { /// Return the issuer of the given cert as an X509Principal. public static X509Name GetIssuerX509Principal(X509Certificate cert) { return cert.CertificateStructure.TbsCertificate.Issuer; } /// Return the subject of the given cert as an X509Principal. public static X509Name GetSubjectX509Principal(X509Certificate cert) { return cert.CertificateStructure.TbsCertificate.Subject; } /// Return the issuer of the given CRL as an X509Principal. public static X509Name GetIssuerX509Principal(X509Crl crl) { return crl.CertificateList.TbsCertList.Issuer; } } }