RevokedStatus.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1;
  5. using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.Ocsp;
  6. using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.X509;
  7. namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Ocsp
  8. {
  9. /**
  10. * wrapper for the RevokedInfo object
  11. */
  12. public class RevokedStatus
  13. : CertificateStatus
  14. {
  15. internal readonly RevokedInfo info;
  16. public RevokedStatus(
  17. RevokedInfo info)
  18. {
  19. this.info = info;
  20. }
  21. public RevokedStatus(
  22. DateTime revocationDate,
  23. int reason)
  24. {
  25. this.info = new RevokedInfo(new DerGeneralizedTime(revocationDate), new CrlReason(reason));
  26. }
  27. public DateTime RevocationTime
  28. {
  29. get { return info.RevocationTime.ToDateTime(); }
  30. }
  31. public bool HasRevocationReason
  32. {
  33. get { return (info.RevocationReason != null); }
  34. }
  35. /**
  36. * return the revocation reason. Note: this field is optional, test for it
  37. * with hasRevocationReason() first.
  38. * @exception InvalidOperationException if a reason is asked for and none is avaliable
  39. */
  40. public int RevocationReason
  41. {
  42. get
  43. {
  44. if (info.RevocationReason == null)
  45. {
  46. throw new InvalidOperationException("attempt to get a reason where none is available");
  47. }
  48. return info.RevocationReason.IntValueExact;
  49. }
  50. }
  51. }
  52. }
  53. #pragma warning restore
  54. #endif