當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。