public static string GetKey(CertificateAttribute attribute) { switch (attribute) { case CertificateAttribute.CommonName: return("CN"); case CertificateAttribute.CountryName: return("C"); case CertificateAttribute.GivenName: return("G"); case CertificateAttribute.Locality: return("L"); case CertificateAttribute.Organization: return("O"); case CertificateAttribute.OrganizationalUnit: return("OU"); case CertificateAttribute.StateOrProvinceName: return("ST"); case CertificateAttribute.Surname: return("SN"); default: return("<UNKNOWN>"); } }
/// <summary> /// Add an attribute to the certificate; /// </summary> /// <param name="attribute"></param> protected void AddAttribute(CertificateAttribute attribute) { if (SelfSignature == null) { this.attributes.Add(attribute); } else { throw new InvalidOperationException("Cannot add attribute after self signature."); } }
public static bool VerifyAttribute(string str, CertificateAttribute key, string target, StringComparison comp) { return(VerifyAttribute(str, GetKey(key), target, comp)); }
public static bool VerifyAttribute(string str, CertificateAttribute key, string target) { return(VerifyAttribute(str, GetKey(key), target)); }
public static string GetAttribute(string str, CertificateAttribute key, string fallback = null) { return(GetAttribute(str, GetKey(key), fallback)); }