本文整理汇总了C#中X509Certificate2Collection.ToArray方法的典型用法代码示例。如果您正苦于以下问题:C# X509Certificate2Collection.ToArray方法的具体用法?C# X509Certificate2Collection.ToArray怎么用?C# X509Certificate2Collection.ToArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类X509Certificate2Collection
的用法示例。
在下文中一共展示了X509Certificate2Collection.ToArray方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ImportStoreSavedAsPfxData
public static void ImportStoreSavedAsPfxData()
{
using (var msCer = new X509Certificate2(TestData.MsCertificate))
using (var pfxCer = new X509Certificate2(TestData.PfxData, TestData.PfxDataPassword))
{
X509Certificate2Collection cc2 = new X509Certificate2Collection();
cc2.Import(TestData.StoreSavedAsPfxData);
int count = cc2.Count;
Assert.Equal(2, count);
X509Certificate2[] cs = cc2.ToArray().OrderBy(c => c.Subject).ToArray();
Assert.NotSame(msCer, cs[0]);
Assert.Equal(msCer, cs[0]);
Assert.Equal(msCer.Thumbprint, cs[0].Thumbprint);
Assert.NotSame(pfxCer, cs[1]);
Assert.Equal(pfxCer, cs[1]);
Assert.Equal(pfxCer.Thumbprint, cs[1].Thumbprint);
}
}
示例2: TestExportStore
private static void TestExportStore(X509ContentType ct)
{
using (var msCer = new X509Certificate2(TestData.MsCertificate))
using (var pfxCer = new X509Certificate2(TestData.PfxData, TestData.PfxDataPassword))
{
X509Certificate2Collection cc = new X509Certificate2Collection(new X509Certificate2[] { msCer, pfxCer });
byte[] blob = cc.Export(ct);
Assert.Equal(ct, X509Certificate2.GetCertContentType(blob));
X509Certificate2Collection cc2 = new X509Certificate2Collection();
cc2.Import(blob);
int count = cc2.Count;
Assert.Equal(2, count);
X509Certificate2[] cs = cc2.ToArray().OrderBy(c => c.Subject).ToArray();
using (X509Certificate2 first = cs[0])
{
Assert.NotSame(msCer, first);
Assert.Equal(msCer, first);
}
using (X509Certificate2 second = cs[1])
{
Assert.NotSame(pfxCer, second);
Assert.Equal(pfxCer, second);
}
}
}