本文整理汇总了C#中Certificate.HasPrivateKey方法的典型用法代码示例。如果您正苦于以下问题:C# Certificate.HasPrivateKey方法的具体用法?C# Certificate.HasPrivateKey怎么用?C# Certificate.HasPrivateKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Certificate
的用法示例。
在下文中一共展示了Certificate.HasPrivateKey方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DisplayCertificate
//.........这里部分代码省略.........
else
{
Console.WriteLine( "Extended Key Usage: Not valid for any usage.");
Console.WriteLine( " Critical = " + Certificate.ExtendedKeyUsage().IsCritical );
}
}
else
{
Console.WriteLine( "Extended Key Usage: Not present (valid for all usages).");
}
Console.WriteLine();
if (Certificate.Template().IsPresent)
{
Console.WriteLine( "Template:");
Console.WriteLine( " Critical = " + Certificate.Template().IsCritical);
Console.WriteLine( " Name = " + Certificate.Template().Name);
Console.WriteLine( " OID = " + Certificate.Template().OID.FriendlyName + "(" + Certificate.Template().OID.Value + ")");
Console.WriteLine( " Major = " + Certificate.Template().MajorVersion);
Console.WriteLine( " Minor = " + Certificate.Template().MinorVersion);
}
else
{
Console.WriteLine( "Template: Not present.");
}
Console.WriteLine();
Console.WriteLine( "Public Key:");
Console.WriteLine( " Algorithm = " + Certificate.PublicKey().Algorithm.FriendlyName + "(" + Certificate.PublicKey().Algorithm.Value + ")");
Console.WriteLine( " Length = " + Certificate.PublicKey().Length + " bits");
Console.WriteLine( " Key blob = " + Certificate.PublicKey().EncodedKey.Format(true));
Console.WriteLine( " Parameters = " + Certificate.PublicKey().EncodedParameters.Format(true));
if (Certificate.HasPrivateKey())
{
Console.WriteLine( "Private Key:");
Console.WriteLine( " Container name = " + Certificate.PrivateKey.ContainerName);
//Don't display unique container name for hardware token because it may cause UI to be displayed.
if (! Certificate.PrivateKey.IsHardwareDevice())
{
Console.WriteLine( " Unique name = " + Certificate.PrivateKey.UniqueContainerName);
}
Console.WriteLine( " Provider name = " + Certificate.PrivateKey.ProviderName);
Console.WriteLine( " Provider type = " );
if (Convert.ToInt32(Certificate.PrivateKey.ProviderType) > ProviderTypes.GetUpperBound(0))
{
Console.WriteLine( ProviderTypes[0] + " (" + Convert.ToString(Certificate.PrivateKey.ProviderType) + ")");
}
else
{
Console.WriteLine( ProviderTypes[Convert.ToInt32(Certificate.PrivateKey.ProviderType)] + " (" + Convert.ToString(Certificate.PrivateKey.ProviderType) + ")");
}
Console.WriteLine( " Key spec = " );
if (Convert.ToInt32(Certificate.PrivateKey.KeySpec) > KeySpecStrings.GetUpperBound(0))
{
Console.WriteLine( KeySpecStrings[0] + " (" + Convert.ToString(Certificate.PrivateKey.KeySpec) + ")");
}
else
{
Console.WriteLine( KeySpecStrings[Convert.ToInt32(Certificate.PrivateKey.KeySpec)] + " (" + Convert.ToString(Certificate.PrivateKey.KeySpec) + ")");
}
Console.WriteLine( " Accessible = " + Certificate.PrivateKey.IsAccessible());
Console.WriteLine( " Protected = " + Certificate.PrivateKey.IsProtected());
Console.WriteLine( " Exportable = " + Certificate.PrivateKey.IsExportable());
Console.WriteLine( " Removable = " + Certificate.PrivateKey.IsRemovable());
Console.WriteLine( " Machine keyset = " + Certificate.PrivateKey.IsMachineKeyset());