当前位置: 首页>>代码示例>>C#>>正文


C# Certificate.Template方法代码示例

本文整理汇总了C#中Certificate.Template方法的典型用法代码示例。如果您正苦于以下问题:C# Certificate.Template方法的具体用法?C# Certificate.Template怎么用?C# Certificate.Template使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Certificate的用法示例。


在下文中一共展示了Certificate.Template方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DisplayCertificate


//.........这里部分代码省略.........
            {
                Console.WriteLine( "Key Usage: Not present.");

            }
            Console.WriteLine();

            if (Certificate.ExtendedKeyUsage().IsPresent)
            {
                if (Certificate.ExtendedKeyUsage().EKUs.Count > 0)
                {
                    OID OID;
                    OID = new OIDClass();
                    Console.WriteLine( "Extended Key Usage:");
                    Console.WriteLine( "  Critical = " + Certificate.ExtendedKeyUsage().IsCritical);
                    foreach (EKU EKU in Certificate.ExtendedKeyUsage().EKUs)
                    {
                        OID.Value = EKU.OID;
                        Console.WriteLine( "  " + OID.FriendlyName + " (" + OID.Value + ")" );
                    }
                    OID = null;
                }
                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))
开发者ID:SatishSara,项目名称:zxlooong,代码行数:67,代码来源:storesh.cs


注:本文中的Certificate.Template方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。