本文整理汇总了C#中Org.BouncyCastle.Asn1.X509.X509Name.GetValues方法的典型用法代码示例。如果您正苦于以下问题:C# X509Name.GetValues方法的具体用法?C# X509Name.GetValues怎么用?C# X509Name.GetValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Org.BouncyCastle.Asn1.X509.X509Name
的用法示例。
在下文中一共展示了X509Name.GetValues方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PerformTest
//.........这里部分代码省略.........
ord2.Add(X509Name.O);
ord2.Add(X509Name.C);
name1 = new X509Name(ord1, attrs);
name2 = new X509Name(ord2, attrs);
if (name1.Equivalent(name2))
{
Fail("Failed different name test");
}
ord2 = new ArrayList();
ord2.Add(X509Name.ST);
ord2.Add(X509Name.L);
ord2.Add(X509Name.O);
ord2.Add(X509Name.C);
name1 = new X509Name(ord1, attrs);
name2 = new X509Name(ord2, attrs);
if (name1.Equivalent(name2))
{
Fail("Failed subset name test");
}
compositeTest();
//
// getValues test
//
ArrayList v1 = name1.GetValues(X509Name.O);
if (v1.Count != 1 || !v1[0].Equals("The Legion of the Bouncy Castle"))
{
Fail("O test failed");
}
ArrayList v2 = name1.GetValues(X509Name.L);
if (v2.Count != 1 || !v2[0].Equals("Melbourne"))
{
Fail("L test failed");
}
//
// general subjects test
//
for (int i = 0; i != subjects.Length; i++)
{
X509Name name = new X509Name(subjects[i]);
byte[] encodedName = name.GetEncoded();
name = X509Name.GetInstance(Asn1Object.FromByteArray(encodedName));
if (!name.ToString().Equals(subjects[i]))
{
Fail("Failed regeneration test " + i);
}
}
//
// sort test
//
X509Name unsorted = new X509Name("SERIALNUMBER=BBB + CN=AA");
示例2: GetSubjectOrganizationalUnit
public static string GetSubjectOrganizationalUnit(X509Certificate2 certificate)
{
var x509Name = new X509Name(certificate.SubjectName.Name);
var oids = x509Name.GetOids();
for (int i = 0; i < oids.Count; i++)
{
var oid = oids[i];
if (ObjectIdentifiers.OrganizationalUnit.Equals(oid.ToString()))
{
return x509Name.GetValues()[i].ToString();
}
}
return null;
}
示例3: GetFriendlyName
private string GetFriendlyName(X509Name name)
{
return (string)name.GetValues(X509Name.CN)[0];
}