SingleResp.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. using System.Collections;
  5. using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1;
  6. using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.Ocsp;
  7. using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.X509;
  8. using BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities.Date;
  9. using BestHTTP.SecureProtocol.Org.BouncyCastle.X509;
  10. namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Ocsp
  11. {
  12. public class SingleResp
  13. : X509ExtensionBase
  14. {
  15. internal readonly SingleResponse resp;
  16. public SingleResp(
  17. SingleResponse resp)
  18. {
  19. this.resp = resp;
  20. }
  21. public CertificateID GetCertID()
  22. {
  23. return new CertificateID(resp.CertId);
  24. }
  25. /**
  26. * Return the status object for the response - null indicates good.
  27. *
  28. * @return the status object for the response, null if it is good.
  29. */
  30. public object GetCertStatus()
  31. {
  32. CertStatus s = resp.CertStatus;
  33. if (s.TagNo == 0)
  34. {
  35. return null; // good
  36. }
  37. if (s.TagNo == 1)
  38. {
  39. return new RevokedStatus(RevokedInfo.GetInstance(s.Status));
  40. }
  41. return new UnknownStatus();
  42. }
  43. public DateTime ThisUpdate
  44. {
  45. get { return resp.ThisUpdate.ToDateTime(); }
  46. }
  47. /**
  48. * return the NextUpdate value - note: this is an optional field so may
  49. * be returned as null.
  50. *
  51. * @return nextUpdate, or null if not present.
  52. */
  53. public DateTimeObject NextUpdate
  54. {
  55. get
  56. {
  57. return resp.NextUpdate == null
  58. ? null
  59. : new DateTimeObject(resp.NextUpdate.ToDateTime());
  60. }
  61. }
  62. public X509Extensions SingleExtensions
  63. {
  64. get { return resp.SingleExtensions; }
  65. }
  66. protected override X509Extensions GetX509Extensions()
  67. {
  68. return SingleExtensions;
  69. }
  70. }
  71. }
  72. #pragma warning restore
  73. #endif