X509ExtensionUtil.cs 1.0 KB

12345678910111213141516171819202122232425262728293031
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. using Best.HTTP.SecureProtocol.Org.BouncyCastle.Asn1;
  5. namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.X509.Extension
  6. {
  7. public class X509ExtensionUtilities
  8. {
  9. public static Asn1Object FromExtensionValue(Asn1OctetString extensionValue)
  10. {
  11. return Asn1Object.FromByteArray(extensionValue.GetOctets());
  12. }
  13. /// <summary>
  14. /// Extract the value of the given extension, if it exists.
  15. /// </summary>
  16. /// <param name="extensions">The extensions object.</param>
  17. /// <param name="oid">The object identifier to obtain.</param>
  18. /// <returns>Asn1Object</returns>
  19. /// <exception cref="Exception">if the extension cannot be read.</exception>
  20. public static Asn1Object FromExtensionValue(IX509Extension extensions, DerObjectIdentifier oid)
  21. {
  22. Asn1OctetString extensionValue = extensions.GetExtensionValue(oid);
  23. return extensionValue == null ? null : FromExtensionValue(extensionValue);
  24. }
  25. }
  26. }
  27. #pragma warning restore
  28. #endif