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


C# X509Certificate.GetExtensionValue方法代码示例

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


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

示例1: FromCertificate

		private static Asn1Sequence FromCertificate(
			X509Certificate certificate)
		{
			try
			{
				GeneralName genName = new GeneralName(
					PrincipalUtilities.GetIssuerX509Principal(certificate));

				if (certificate.Version == 3)
				{
					Asn1OctetString ext = certificate.GetExtensionValue(X509Extensions.SubjectKeyIdentifier);

					if (ext != null)
					{
						Asn1OctetString str = (Asn1OctetString) X509ExtensionUtilities.FromExtensionValue(ext);

						return (Asn1Sequence) new AuthorityKeyIdentifier(
							str.GetOctets(), new GeneralNames(genName), certificate.SerialNumber).ToAsn1Object();
					}
				}

				SubjectPublicKeyInfo info = SubjectPublicKeyInfoFactory.CreateSubjectPublicKeyInfo(
					certificate.GetPublicKey());

				return (Asn1Sequence) new AuthorityKeyIdentifier(
					info, new GeneralNames(genName), certificate.SerialNumber).ToAsn1Object();
			}
			catch (Exception e)
			{
				throw new CertificateParsingException("Exception extracting certificate details", e);
			}
		}
开发者ID:Xanagandr,项目名称:DisaOpenSource,代码行数:32,代码来源:AuthorityKeyIdentifierStructure.cs

示例2: GetSubjectAlternativeNames

		public static ICollection GetSubjectAlternativeNames(
			X509Certificate cert)
		{
			Asn1OctetString extVal = cert.GetExtensionValue(X509Extensions.SubjectAlternativeName);

			return GetAlternativeName(extVal);
		}
开发者ID:Xanagandr,项目名称:DisaOpenSource,代码行数:7,代码来源:X509ExtensionUtil.cs

示例3: MatchExtension

		private static bool MatchExtension(
			byte[]				b,
			X509Certificate		c,
			DerObjectIdentifier	oid)
		{
			if (b == null)
				return true;

			Asn1OctetString extVal = c.GetExtensionValue(oid);

			if (extVal == null)
				return false;

			return Arrays.AreEqual(b, extVal.GetOctets());
		}
开发者ID:ktw,项目名称:OutlookPrivacyPlugin,代码行数:15,代码来源:X509CertStoreSelector.cs

示例4: GetAccessLocation

		/// <exception cref="System.IO.IOException"></exception>
		private string GetAccessLocation(X509Certificate certificate, DerObjectIdentifier
			 accessMethod)
		{
            //byte[] authInfoAccessExtensionValue = certificate.GetExtensionValue(X509Extensions
            //    .AuthorityInfoAccess);
            Asn1OctetString authInfoAccessExtensionValue = certificate.GetExtensionValue(X509Extensions
                .AuthorityInfoAccess);
			if (null == authInfoAccessExtensionValue)
			{
				return null;
			}
			AuthorityInformationAccess authorityInformationAccess;
            //DerOctetString oct = (DerOctetString)(new Asn1InputStream(new MemoryStream
            //    (authInfoAccessExtensionValue)).ReadObject());
            DerOctetString oct = (DerOctetString)authInfoAccessExtensionValue;            
            //authorityInformationAccess = new AuthorityInformationAccess((Asn1Sequence)new Asn1InputStream
            //    (oct.GetOctets()).ReadObject());
            authorityInformationAccess = AuthorityInformationAccess.GetInstance((Asn1Sequence)new Asn1InputStream
                (oct.GetOctets()).ReadObject());            
			AccessDescription[] accessDescriptions = authorityInformationAccess.GetAccessDescriptions
				();
			foreach (AccessDescription accessDescription in accessDescriptions)
			{
				LOG.Info("access method: " + accessDescription.AccessMethod);
				bool correctAccessMethod = accessDescription.AccessMethod.Equals(accessMethod
					);
				if (!correctAccessMethod)
				{
					continue;
				}
				GeneralName gn = accessDescription.AccessLocation;
				if (gn.TagNo != GeneralName.UniformResourceIdentifier)
				{
					LOG.Info("not a uniform resource identifier");
					continue;
				}
				DerIA5String str = (DerIA5String)((DerTaggedObject)gn.ToAsn1Object()).GetObject();
				string accessLocation = str.GetString();
				LOG.Info("access location: " + accessLocation);
				return accessLocation;
			}
			return null;
		}
开发者ID:Gianluigi,项目名称:dssnet,代码行数:44,代码来源:OnlineOcspSource.cs

示例5: GetCrlUri

		/// <summary>Gives back the CRL URI meta-data found within the given X509 certificate.
		/// 	</summary>
		/// <remarks>Gives back the CRL URI meta-data found within the given X509 certificate.
		/// 	</remarks>
		/// <param name="certificate">the X509 certificate.</param>
		/// <returns>the CRL URI, or <code>null</code> if the extension is not present.</returns>
		/// <exception cref="System.UriFormatException">System.UriFormatException</exception>
		public virtual string GetCrlUri(X509Certificate certificate)
		{
            //byte[] crlDistributionPointsValue = certificate.GetExtensionValue(X509Extensions.
            //    CrlDistributionPoints);
            Asn1OctetString crlDistributionPointsValue = certificate.GetExtensionValue(X509Extensions.
                CrlDistributionPoints);
			if (null == crlDistributionPointsValue)
			{
				return null;
			}
			Asn1Sequence seq;
			try
			{
				DerOctetString oct;
                //oct = (DEROctetString)(new ASN1InputStream(new ByteArrayInputStream(crlDistributionPointsValue
                //    )).ReadObject());
                oct = (DerOctetString)crlDistributionPointsValue;                
                seq = (Asn1Sequence)new Asn1InputStream(oct.GetOctets()).ReadObject();
			}
			catch (IOException e)
			{
				throw new RuntimeException("IO error: " + e.Message, e);
			}
			CrlDistPoint distPoint = CrlDistPoint.GetInstance(seq);
			DistributionPoint[] distributionPoints = distPoint.GetDistributionPoints();
			foreach (DistributionPoint distributionPoint in distributionPoints)
			{
                DistributionPointName distributionPointName = distributionPoint.DistributionPointName;
				if (DistributionPointName.FullName != distributionPointName.PointType)
				{
					continue;
				}
				GeneralNames generalNames = (GeneralNames)distributionPointName.Name;
				GeneralName[] names = generalNames.GetNames();
				foreach (GeneralName name in names)
				{
					if (name.TagNo != GeneralName.UniformResourceIdentifier)
					{
						LOG.Info("not a uniform resource identifier");
						continue;
					}
					string str = null;
					if (name.ToAsn1Object() is DerTaggedObject)
					{
						DerTaggedObject taggedObject = (DerTaggedObject)name.ToAsn1Object();
						DerIA5String derStr = DerIA5String.GetInstance(taggedObject.GetObject());
						str = derStr.GetString();
					}
					else
					{
						DerIA5String derStr = DerIA5String.GetInstance(name.ToAsn1Object());
						str = derStr.GetString();
					}
					if (str != null && (str.StartsWith("http://") || str.StartsWith("https://"))
                        && str.ToUpperInvariant().Contains("CRL")) //jbonilla - El URL del CRL para el BCE está en la tercera posición y solo se puede acceder desde HTTP.
					{
						return str;
					}
					else
					{
						LOG.Info("Supports only http:// and https:// protocol for CRL");
					}            
				}
			}

            //jbonilla
            #region BCE
            if (certificate.SubjectDN.ToString()
                .Contains("AC BANCO CENTRAL DEL ECUADOR"))
            {
                return this.IntermediateAcUrl;
            }
            #endregion

			return null;
		}
开发者ID:Gianluigi,项目名称:dssnet,代码行数:83,代码来源:OnlineCrlSource.cs


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