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


C# Certificate.ExtendedProperties方法代码示例

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


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

示例1: DisplayCertificate


//.........这里部分代码省略.........
                {
                    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());
                Console.WriteLine( "  Hardware storage = " + Certificate.PrivateKey.IsHardwareDevice());
            }
            else
            {
                Console.WriteLine( "Private Key: Not found." );
            }
            Console.WriteLine();

            if (true)
            {
                int iIndex = 0;

                foreach (Extension Extension in Certificate.Extensions())
                {
                    iIndex++;
                    Console.WriteLine( "Extension #" + Convert.ToString(iIndex) + ": " + Extension.OID.FriendlyName + "(" + Extension.OID.Value + ")");
                    Console.WriteLine( "  " + Extension.EncodedData.Format(true));

                    if (Extension.EncodedData.Decoder() != null)
                    {
                        switch (Extension.OID.Value)
                        {
                            case Constants.CAPICOM_CERT_POLICIES_OID:
                            {
                                CertificatePolicies CertPolicies;
                                int pIndex = 0;

                                CertPolicies = (CertificatePolicies)Extension.EncodedData.Decoder();
                                Console.WriteLine( "Decoded Certificate Policies: " + Convert.ToString(CertPolicies.Count) + " PolicyInformation(s)");

                                foreach  (PolicyInformation PolicyInformation in CertPolicies)
                                {
                                    int qIndex = 0;
                                    pIndex++;
                                    Console.WriteLine( "  PolicyInformation #" + Convert.ToString(pIndex) + ": " + Convert.ToString(PolicyInformation.Qualifiers.Count) + " Qualifier(s)");
                                    Console.WriteLine( "    OID = " + PolicyInformation.OID.FriendlyName + "(" + PolicyInformation.OID.Value + ")");

                                    foreach (Qualifier Qualifier  in PolicyInformation.Qualifiers)
                                    {
                                        qIndex++;
                                        Console.WriteLine( "    Qualifier #" + Convert.ToString(qIndex) + ":");
                                        Console.WriteLine( "      OID               = " + Qualifier.OID.FriendlyName + "(" + Qualifier.OID.Value + ")");
                                        Console.WriteLine( "      CPS URI           = " + Qualifier.CPSPointer);
                                        Console.WriteLine( "      Organization name = " + Qualifier.OrganizationName);
                                        Console.WriteLine( "      Notice number(s)  = ");
                                        if (Qualifier.NoticeNumbers != null)
                                        {
                                            foreach (NoticeNumbers NoticeNumber in Qualifier.NoticeNumbers)
                                            {
                                                Console.WriteLine( Convert.ToString(NoticeNumber));
                                            }
                                        }
                                        Console.WriteLine();
                                        Console.WriteLine( "      Explicit text     = " + Qualifier.ExplicitText);
                                    }
                                    Console.WriteLine();
                                }
                                break;
                            }
                        }
                    }
                }
                if (iIndex == 0)
                {
                    Console.WriteLine( "Extension: None.");
                    Console.WriteLine();
                }

                iIndex = 0;
                foreach (ExtendedProperty ExtendedProperty in Certificate.ExtendedProperties())
                {
                    iIndex ++;
                    Console.WriteLine( "Property #" + Convert.ToString(iIndex) + " (ID = " + ExtendedProperty.PropID + "):" );
                    Console.WriteLine( "  " + ExtendedProperty.get_Value(CAPICOM_ENCODING_TYPE.CAPICOM_ENCODE_BASE64));
                }
                if (iIndex == 0)
                {
                    Console.WriteLine( "Property: None.");
                    Console.WriteLine();
                }

            }
        }
开发者ID:SatishSara,项目名称:zxlooong,代码行数:101,代码来源:storesh.cs


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