本文整理汇总了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);
}
}
示例2: GetSubjectAlternativeNames
public static ICollection GetSubjectAlternativeNames(
X509Certificate cert)
{
Asn1OctetString extVal = cert.GetExtensionValue(X509Extensions.SubjectAlternativeName);
return GetAlternativeName(extVal);
}
示例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());
}
示例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;
}
示例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;
}