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


C# X509Certificates.X509Extension类代码示例

本文整理汇总了C#中System.Security.Cryptography.X509Certificates.X509Extension的典型用法代码示例。如果您正苦于以下问题:C# X509Extension类的具体用法?C# X509Extension怎么用?C# X509Extension使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


X509Extension类属于System.Security.Cryptography.X509Certificates命名空间,在下文中一共展示了X509Extension类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Add

 public int Add(X509Extension extension)
 {
     if (extension == null)
         throw new ArgumentNullException("extension");
     _list.Add(extension);
     return _list.Count - 1;
 }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:7,代码来源:X509ExtensionCollection.cs

示例2: Add

 public int Add(X509Extension extension)
 {
     if (extension == null)
     {
         throw new ArgumentNullException("extension");
     }
     return this.m_list.Add(extension);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:8,代码来源:X509ExtensionCollection.cs

示例3: CopyTo

		public void CopyTo (X509Extension[] array, int index) 
		{
			if (array == null)
				throw new ArgumentNullException ("array");
			if (index < 0)
				throw new ArgumentException ("negative index");
			if (index > array.Length)
				throw new ArgumentOutOfRangeException ("index > array.Length");
		}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:9,代码来源:X509ExtensionCollection.cs

示例4: ConstructorAsnEncodedData

		public void ConstructorAsnEncodedData ()
		{
			AsnEncodedData aed = new AsnEncodedData (new Oid ("2.5.29.37"), new byte[] { 0x30, 0x05, 0x06, 0x03, 0x2A, 0x03, 0x04 });
			X509Extension ex = new X509Extension (aed, true);
			Assert.IsTrue (ex.Critical, "Critical");
			Assert.AreEqual (7, ex.RawData.Length, "RawData");	// original Oid ignored
			Assert.AreEqual ("2.5.29.37", ex.Oid.Value, "Oid.Value");
			Assert.AreEqual ("Enhanced Key Usage", ex.Oid.FriendlyName, "Oid.FriendlyName");
			Assert.AreEqual ("Unknown Key Usage (1.2.3.4)" + Environment.NewLine, ex.Format (true), "Format(true)");
			Assert.AreEqual ("Unknown Key Usage (1.2.3.4)", ex.Format (false), "Format(false)");
		}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:11,代码来源:X509ExtensionTest.cs

示例5: MarshalX509Extension

 public MarshalX509Extension(X509Extension extension)
 {
     _extension = extension;
     _blobPtr = Marshal.AllocHGlobal(extension.RawData.Length);
     Marshal.Copy(extension.RawData, 0, _blobPtr, extension.RawData.Length);
     var blob = new CRYPT_OBJID_BLOB();
     blob.cbData = (uint)extension.RawData.Length;
     blob.pbData = _blobPtr;
     var nativeExtension = new CERT_EXTENSION();
     nativeExtension.fCritical = extension.Critical;
     nativeExtension.pszObjId = extension.Oid.Value;
     nativeExtension.Value = blob;
     _value = nativeExtension;
 }
开发者ID:blinds52,项目名称:FiddlerCertGen,代码行数:14,代码来源:MarshalX509Extension.cs

示例6: SafeX509Extension

 public SafeX509Extension(X509Extension extension)
 {
     this.blobPtr = Marshal.AllocHGlobal(extension.RawData.Length);
     Marshal.Copy(extension.RawData, 0, this.blobPtr, extension.RawData.Length);
     var blob = new CRYPTOAPI_BLOB
     {
         cbData = (uint)extension.RawData.Length,
         pbData = this.blobPtr
     };
     var nativeExtension = new CERT_EXTENSION
     {
         fCritical = extension.Critical,
         pszObjId = extension.Oid.Value,
         Value = blob
     };
     this.value = nativeExtension;
 }
开发者ID:yuriik83,项目名称:workstation-uaclient,代码行数:17,代码来源:SafeX509Extension.cs

示例7: X509ExtensionCollection

 internal unsafe X509ExtensionCollection(System.Security.Cryptography.SafeCertContextHandle safeCertContextHandle)
 {
     this.m_list = new ArrayList();
     using (System.Security.Cryptography.SafeCertContextHandle handle = CAPI.CertDuplicateCertificateContext(safeCertContextHandle))
     {
         CAPIBase.CERT_CONTEXT cert_context = *((CAPIBase.CERT_CONTEXT*) handle.DangerousGetHandle());
         CAPIBase.CERT_INFO cert_info = (CAPIBase.CERT_INFO) Marshal.PtrToStructure(cert_context.pCertInfo, typeof(CAPIBase.CERT_INFO));
         uint cExtension = cert_info.cExtension;
         IntPtr rgExtension = cert_info.rgExtension;
         for (uint i = 0; i < cExtension; i++)
         {
             X509Extension asnEncodedData = new X509Extension(new IntPtr(((long) rgExtension) + (i * Marshal.SizeOf(typeof(CAPIBase.CERT_EXTENSION)))));
             X509Extension extension2 = CryptoConfig.CreateFromName(asnEncodedData.Oid.Value) as X509Extension;
             if (extension2 != null)
             {
                 extension2.CopyFrom(asnEncodedData);
                 asnEncodedData = extension2;
             }
             this.Add(asnEncodedData);
         }
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:22,代码来源:X509ExtensionCollection.cs

示例8: ReadInhibitAnyPolicyExtension

 private static int ReadInhibitAnyPolicyExtension(X509Extension extension)
 {
     DerSequenceReader reader = DerSequenceReader.CreateForPayload(extension.RawData);
     return reader.ReadInteger();
 }
开发者ID:noahfalk,项目名称:corefx,代码行数:5,代码来源:CertificatePolicy.cs

示例9: ReadCertPolicyConstraintsExtension

        private static void ReadCertPolicyConstraintsExtension(X509Extension extension, CertificatePolicy policy)
        {
            DerSequenceReader reader = new DerSequenceReader(extension.RawData);

            while (reader.HasData)
            {
                // Policy Constraints context specific tag values are defined in RFC 3280 4.2.1.12,
                // and restated (unchanged) in RFC 5280 4.2.1.11.
                switch (reader.PeekTag())
                {
                    case DerSequenceReader.ContextSpecificTagFlag | 0:
                        policy.RequireExplicitPolicyDepth = reader.ReadInteger();
                        break;
                    case DerSequenceReader.ContextSpecificTagFlag | 1:
                        policy.InhibitMappingDepth = reader.ReadInteger();
                        break;
                    default:
                        if (extension.Critical)
                        {
                            // If an unknown value is read, but we're marked as critical,
                            // then we don't know what we're doing and MUST fail validation
                            // (RFC 3280).
                            // If it isn't critical then it means we're allowed to be ignorant
                            // of data defined more recently than we understand.
                            throw new CryptographicException();
                        }

                        break;
                }
            }
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:31,代码来源:CertificatePolicy.cs

示例10: WrongExtension_X509Extension

		public void WrongExtension_X509Extension ()
		{
			X509Extension ex = new X509Extension ("1.2.3", new byte [0], true);
			X509KeyUsageExtension ku = new X509KeyUsageExtension (X509KeyUsageFlags.CrlSign, true);
			ku.CopyFrom (ex);
			Assert.IsTrue (ku.Critical, "Critical");
			Assert.AreEqual (String.Empty, BitConverter.ToString (ku.RawData), "RawData");
			Assert.AreEqual ("1.2.3", ku.Oid.Value, "Oid.Value");
			Assert.IsNull (ku.Oid.FriendlyName, "Oid.FriendlyName");
		}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:10,代码来源:X509KeyUsageExtensionTest.cs

示例11: WrongExtension_X509Extension_KeyUsages

		public void WrongExtension_X509Extension_KeyUsages ()
		{
			X509Extension ex = new X509Extension ("1.2.3", new byte[0], true);
			X509KeyUsageExtension ku = new X509KeyUsageExtension ();
			ku.CopyFrom (ex);
			Assert.AreEqual (0, ku.KeyUsages, "KeyUsages");
		}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:7,代码来源:X509KeyUsageExtensionTest.cs

示例12: WrongExtension_X509Extension

		public void WrongExtension_X509Extension ()
		{
			X509Extension ex = new X509Extension ("1.2.3", new byte[0], true);
			X509BasicConstraintsExtension bc = new X509BasicConstraintsExtension (false, true, 1, false);
			Assert.IsFalse (bc.Critical, "Critical");
			bc.CopyFrom (ex);
			Assert.IsTrue (bc.Critical, "Critical");
			Assert.AreEqual (String.Empty, BitConverter.ToString (bc.RawData), "RawData");
			Assert.AreEqual ("1.2.3", bc.Oid.Value, "Oid.Value");
			Assert.IsNull (bc.Oid.FriendlyName, "Oid.FriendlyName");
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:11,代码来源:X509BasicConstraintsExtensionTest.cs

示例13: WrongExtension_X509Extension_CertificateAuthority

		public void WrongExtension_X509Extension_CertificateAuthority ()
		{
			X509Extension ex = new X509Extension ("1.2.3", new byte[0], true);
			X509BasicConstraintsExtension bc = new X509BasicConstraintsExtension ();
			bc.CopyFrom (ex);
			bool b = bc.CertificateAuthority;
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:7,代码来源:X509BasicConstraintsExtensionTest.cs

示例14: ReadCertPolicyMappingsExtension

        private static List<CertificatePolicyMapping> ReadCertPolicyMappingsExtension(X509Extension extension)
        {
            DerSequenceReader reader = new DerSequenceReader(extension.RawData);
            List<CertificatePolicyMapping> mappings = new List<CertificatePolicyMapping>();

            while (reader.HasData)
            {
                DerSequenceReader mappingSequence = reader.ReadSequence();
                mappings.Add(
                    new CertificatePolicyMapping
                    {
                        IssuerDomainPolicy = mappingSequence.ReadOidAsString(),
                        SubjectDomainPolicy = mappingSequence.ReadOidAsString(),
                    });
            }

            return mappings;
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:18,代码来源:CertificatePolicy.cs

示例15: Build_NetscapeCertTypeExtension

		public void Build_NetscapeCertTypeExtension ()
		{
			X509Extension ex = new X509Extension (new Oid ("2.16.840.1.113730.1.1"), new byte[] { 0x03, 0x02, 0x00, 0xFF }, false);
			// strangely no NewLine is being appended to Format(true)
			// FIXME: Don't expect that FriendlyName is English. This test fails under non-English Windows.
			//Assert.AreEqual ("SSL Client Authentication, SSL Server Authentication, SMIME, Signature, Unknown cert type, SSL CA, SMIME CA, Signature CA (ff)", ex.Format (true), "aed.Format(true)");
			//Assert.AreEqual ("SSL Client Authentication, SSL Server Authentication, SMIME, Signature, Unknown cert type, SSL CA, SMIME CA, Signature CA (ff)", ex.Format (false), "aed.Format(false)");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:8,代码来源:X509ExtensionTest.cs


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