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


C# Certificate.BasicConstraints方法代码示例

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


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

示例1: DisplayCertificate

        public static void DisplayCertificate( Certificate Certificate , String Title)
        {
            String[] KeySpecStrings = {"Unknown", "Exchange","Signature" };
            String[] ProviderTypes = {	"Unknown",
                                         "PROV_RSA_FULL",
                                         "PROV_RSA_SIG",
                                         "PROV_DSS",
                                         "PROV_FORTEZZA",
                                         "PROV_MS_EXCHANGE",
                                         "PROV_SSL",
                                         "PROV_STT_MER",
                                         "PROV_STT_ACQ",
                                         "PROV_STT_BRND",
                                         "PROV_STT_ROOT",
                                         "PROV_STT_ISS",
                                         "PROV_RSA_SCHANNEL",
                                         "PROV_DSS_DH",
                                         "PROV_EC_ECDSA_SIG",
                                         "PROV_EC_ECNRA_SIG",
                                         "PROV_EC_ECDSA_FULL",
                                         "PROV_EC_ECNRA_FULL",
                                         "PROV_DH_SCHANNEL",
                                         "PROV_SPYRUS_LYNKS",
                                         "PROV_RNG",
                                         "PROV_INTEL_SEC",
                                         "PROV_REPLACE_OWF",
                                         "PROV_RSA_AES" };

            //int iIndex = 0;

            Console.WriteLine( Title );
            Console.WriteLine();
            Console.WriteLine( "Subject Name:");
            Console.WriteLine( "  Simple name = " + Certificate.SubjectName);
            Console.WriteLine( "  Email name  = " + Certificate.GetInfo(CAPICOM_CERT_INFO_TYPE.CAPICOM_CERT_INFO_SUBJECT_EMAIL_NAME));
            Console.WriteLine( "  UPN name    = " + Certificate.GetInfo(CAPICOM_CERT_INFO_TYPE.CAPICOM_CERT_INFO_SUBJECT_UPN));
            Console.WriteLine( "  DNS name    = " + Certificate.GetInfo(CAPICOM_CERT_INFO_TYPE.CAPICOM_CERT_INFO_SUBJECT_DNS_NAME));
            Console.WriteLine();
            Console.WriteLine( "Issuer Name: " + Certificate.IssuerName);
            Console.WriteLine();
            Console.WriteLine( "Serial Number: " + Certificate.SerialNumber);
            Console.WriteLine();
            Console.WriteLine( "Not Before: " + Certificate.ValidFromDate);
            Console.WriteLine();
            Console.WriteLine( "Not After: " + Certificate.ValidToDate);
            Console.WriteLine();
            Console.WriteLine( "SHA1 Hash: " + Certificate.Thumbprint);
            Console.WriteLine();
            Console.WriteLine( "IsValid: " + Certificate.IsValid().Result);
            Console.WriteLine();
            Console.WriteLine( "Archived: " + Certificate.Archived);
            Console.WriteLine();

            if (Certificate.BasicConstraints().IsPresent)
            {
                Console.WriteLine( "Basic Constraints:" );
                Console.WriteLine( "  Critical          = " + Certificate.BasicConstraints().IsCritical );
                Console.WriteLine( "  CA                = " + Certificate.BasicConstraints().IsCertificateAuthority );
                Console.WriteLine( "  PathLenConstraint = ");
                if (Certificate.BasicConstraints().IsPathLenConstraintPresent)
                {
                    Console.WriteLine( Certificate.BasicConstraints().PathLenConstraint);
                }
                else
                {
                    Console.WriteLine( "Not present.");
                }
            }
            else
            {
                Console.WriteLine( "Basic Constraints: Not present." );
            }
            Console.WriteLine();

            if (Certificate.KeyUsage().IsPresent)
            {
                Console.WriteLine( "Key Usage:");
                Console.WriteLine( "  Critical                  = " + Certificate.KeyUsage().IsCritical);
                Console.WriteLine( "  IsDigitalSignatureEnabled = " + Certificate.KeyUsage().IsDigitalSignatureEnabled );
                Console.WriteLine( "  IsNonRepudiationEnabled   = " + Certificate.KeyUsage().IsNonRepudiationEnabled);
                Console.WriteLine( "  IsKeyEnciphermentEnabled  = " + Certificate.KeyUsage().IsKeyEnciphermentEnabled);
                Console.WriteLine( "  IsDataEnciphermentEnabled = " + Certificate.KeyUsage().IsDataEnciphermentEnabled);
                Console.WriteLine( "  IsKeyAgreementEnabled     = " + Certificate.KeyUsage().IsKeyAgreementEnabled);
                Console.WriteLine( "  IsKeyCertSignEnabled      = " + Certificate.KeyUsage().IsKeyCertSignEnabled);
                Console.WriteLine( "  IsCRLSignEnabled          = " + Certificate.KeyUsage().IsCRLSignEnabled);
                Console.WriteLine( "  IsEncipherOnlyEnabled     = " + Certificate.KeyUsage().IsEncipherOnlyEnabled);
                Console.WriteLine( "  IsDecipherOnlyEnabled     = " + Certificate.KeyUsage().IsDecipherOnlyEnabled);
            }
            else
            {
                Console.WriteLine( "Key Usage: Not present.");

            }
            Console.WriteLine();

            if (Certificate.ExtendedKeyUsage().IsPresent)
            {
                if (Certificate.ExtendedKeyUsage().EKUs.Count > 0)
                {
                    OID OID;
//.........这里部分代码省略.........
开发者ID:SatishSara,项目名称:zxlooong,代码行数:101,代码来源:storesh.cs


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