TimeStampAndCRL.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.Cms
  5. {
  6. public class TimeStampAndCrl
  7. : Asn1Encodable
  8. {
  9. private ContentInfo timeStamp;
  10. private X509.CertificateList crl;
  11. public TimeStampAndCrl(ContentInfo timeStamp)
  12. {
  13. this.timeStamp = timeStamp;
  14. }
  15. private TimeStampAndCrl(Asn1Sequence seq)
  16. {
  17. this.timeStamp = ContentInfo.GetInstance(seq[0]);
  18. if (seq.Count == 2)
  19. {
  20. this.crl = X509.CertificateList.GetInstance(seq[1]);
  21. }
  22. }
  23. public static TimeStampAndCrl GetInstance(object obj)
  24. {
  25. if (obj is TimeStampAndCrl)
  26. return (TimeStampAndCrl)obj;
  27. if (obj != null)
  28. return new TimeStampAndCrl(Asn1Sequence.GetInstance(obj));
  29. return null;
  30. }
  31. public virtual ContentInfo TimeStampToken
  32. {
  33. get { return this.timeStamp; }
  34. }
  35. public virtual X509.CertificateList Crl
  36. {
  37. get { return this.crl; }
  38. }
  39. /**
  40. * <pre>
  41. * TimeStampAndCRL ::= SEQUENCE {
  42. * timeStamp TimeStampToken, -- according to RFC 3161
  43. * crl CertificateList OPTIONAL -- according to RFC 5280
  44. * }
  45. * </pre>
  46. * @return
  47. */
  48. public override Asn1Object ToAsn1Object()
  49. {
  50. Asn1EncodableVector v = new Asn1EncodableVector(timeStamp);
  51. v.AddOptional(crl);
  52. return new DerSequence(v);
  53. }
  54. }
  55. }
  56. #pragma warning restore
  57. #endif