培训考核三期,新版培训,网页版培训登录器
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

86 lines
2.0 KiB

#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
#pragma warning disable
using System;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.X509;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities.Collections;
namespace BestHTTP.SecureProtocol.Org.BouncyCastle.X509
{
public abstract class X509ExtensionBase
: IX509Extension
{
protected abstract X509Extensions GetX509Extensions();
protected virtual ISet GetExtensionOids(
bool critical)
{
X509Extensions extensions = GetX509Extensions();
if (extensions != null)
{
HashSet set = new HashSet();
foreach (DerObjectIdentifier oid in extensions.ExtensionOids)
{
X509Extension ext = extensions.GetExtension(oid);
if (ext.IsCritical == critical)
{
set.Add(oid.Id);
}
}
return set;
}
return null;
}
/// <summary>
/// Get non critical extensions.
/// </summary>
/// <returns>A set of non critical extension oids.</returns>
public virtual ISet GetNonCriticalExtensionOids()
{
return GetExtensionOids(false);
}
/// <summary>
/// Get any critical extensions.
/// </summary>
/// <returns>A sorted list of critical entension.</returns>
public virtual ISet GetCriticalExtensionOids()
{
return GetExtensionOids(true);
}
/// <summary>
/// Get the value of a given extension.
/// </summary>
/// <param name="oid">The object ID of the extension. </param>
/// <returns>An Asn1OctetString object if that extension is found or null if not.</returns>
public Asn1OctetString GetExtensionValue(
string oid)
{
return GetExtensionValue(new DerObjectIdentifier(oid));
}
public virtual Asn1OctetString GetExtensionValue(
DerObjectIdentifier oid)
{
X509Extensions exts = GetX509Extensions();
if (exts != null)
{
X509Extension ext = exts.GetExtension(oid);
if (ext != null)
{
return ext.Value;
}
}
return null;
}
}
}
#pragma warning restore
#endif