CertId.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.X509;
  5. using BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities;
  6. namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.Crmf
  7. {
  8. public class CertId
  9. : Asn1Encodable
  10. {
  11. private readonly GeneralName issuer;
  12. private readonly DerInteger serialNumber;
  13. private CertId(Asn1Sequence seq)
  14. {
  15. issuer = GeneralName.GetInstance(seq[0]);
  16. serialNumber = DerInteger.GetInstance(seq[1]);
  17. }
  18. public static CertId GetInstance(object obj)
  19. {
  20. if (obj is CertId)
  21. return (CertId)obj;
  22. if (obj is Asn1Sequence)
  23. return new CertId((Asn1Sequence)obj);
  24. throw new ArgumentException("Invalid object: " + BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities.Platform.GetTypeName(obj), "obj");
  25. }
  26. public static CertId GetInstance(Asn1TaggedObject obj, bool isExplicit)
  27. {
  28. return GetInstance(Asn1Sequence.GetInstance(obj, isExplicit));
  29. }
  30. public virtual GeneralName Issuer
  31. {
  32. get { return issuer; }
  33. }
  34. public virtual DerInteger SerialNumber
  35. {
  36. get { return serialNumber; }
  37. }
  38. /**
  39. * <pre>
  40. * CertId ::= SEQUENCE {
  41. * issuer GeneralName,
  42. * serialNumber INTEGER }
  43. * </pre>
  44. * @return a basic ASN.1 object representation.
  45. */
  46. public override Asn1Object ToAsn1Object()
  47. {
  48. return new DerSequence(issuer, serialNumber);
  49. }
  50. }
  51. }
  52. #pragma warning restore
  53. #endif