CertBag.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.Pkcs
  5. {
  6. public class CertBag
  7. : Asn1Encodable
  8. {
  9. public static CertBag GetInstance(object obj)
  10. {
  11. if (obj is CertBag)
  12. return (CertBag)obj;
  13. if (obj == null)
  14. return null;
  15. return new CertBag(Asn1Sequence.GetInstance(obj));
  16. }
  17. private readonly DerObjectIdentifier certID;
  18. private readonly Asn1Object certValue;
  19. private CertBag(Asn1Sequence seq)
  20. {
  21. if (seq.Count != 2)
  22. throw new ArgumentException("Wrong number of elements in sequence", "seq");
  23. this.certID = DerObjectIdentifier.GetInstance(seq[0]);
  24. this.certValue = Asn1TaggedObject.GetInstance(seq[1]).GetObject();
  25. }
  26. public CertBag(
  27. DerObjectIdentifier certID,
  28. Asn1Object certValue)
  29. {
  30. this.certID = certID;
  31. this.certValue = certValue;
  32. }
  33. public virtual DerObjectIdentifier CertID
  34. {
  35. get { return certID; }
  36. }
  37. public virtual Asn1Object CertValue
  38. {
  39. get { return certValue; }
  40. }
  41. public override Asn1Object ToAsn1Object()
  42. {
  43. return new DerSequence(certID, new DerTaggedObject(0, certValue));
  44. }
  45. }
  46. }
  47. #pragma warning restore
  48. #endif