CertificateList.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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. namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.X509
  7. {
  8. /**
  9. * PKIX RFC-2459
  10. *
  11. * The X.509 v2 CRL syntax is as follows. For signature calculation,
  12. * the data that is to be signed is ASN.1 Der encoded.
  13. *
  14. * <pre>
  15. * CertificateList ::= Sequence {
  16. * tbsCertList TbsCertList,
  17. * signatureAlgorithm AlgorithmIdentifier,
  18. * signatureValue BIT STRING }
  19. * </pre>
  20. */
  21. public class CertificateList
  22. : Asn1Encodable
  23. {
  24. private readonly TbsCertificateList tbsCertList;
  25. private readonly AlgorithmIdentifier sigAlgID;
  26. private readonly DerBitString sig;
  27. public static CertificateList GetInstance(
  28. Asn1TaggedObject obj,
  29. bool explicitly)
  30. {
  31. return GetInstance(Asn1Sequence.GetInstance(obj, explicitly));
  32. }
  33. public static CertificateList GetInstance(
  34. object obj)
  35. {
  36. if (obj is CertificateList)
  37. return (CertificateList) obj;
  38. if (obj != null)
  39. return new CertificateList(Asn1Sequence.GetInstance(obj));
  40. return null;
  41. }
  42. private CertificateList(
  43. Asn1Sequence seq)
  44. {
  45. if (seq.Count != 3)
  46. throw new ArgumentException("sequence wrong size for CertificateList", "seq");
  47. tbsCertList = TbsCertificateList.GetInstance(seq[0]);
  48. sigAlgID = AlgorithmIdentifier.GetInstance(seq[1]);
  49. sig = DerBitString.GetInstance(seq[2]);
  50. }
  51. public TbsCertificateList TbsCertList
  52. {
  53. get { return tbsCertList; }
  54. }
  55. public CrlEntry[] GetRevokedCertificates()
  56. {
  57. return tbsCertList.GetRevokedCertificates();
  58. }
  59. public IEnumerable GetRevokedCertificateEnumeration()
  60. {
  61. return tbsCertList.GetRevokedCertificateEnumeration();
  62. }
  63. public AlgorithmIdentifier SignatureAlgorithm
  64. {
  65. get { return sigAlgID; }
  66. }
  67. public DerBitString Signature
  68. {
  69. get { return sig; }
  70. }
  71. public byte[] GetSignatureOctets()
  72. {
  73. return sig.GetOctets();
  74. }
  75. public int Version
  76. {
  77. get { return tbsCertList.Version; }
  78. }
  79. public X509Name Issuer
  80. {
  81. get { return tbsCertList.Issuer; }
  82. }
  83. public Time ThisUpdate
  84. {
  85. get { return tbsCertList.ThisUpdate; }
  86. }
  87. public Time NextUpdate
  88. {
  89. get { return tbsCertList.NextUpdate; }
  90. }
  91. public override Asn1Object ToAsn1Object()
  92. {
  93. return new DerSequence(tbsCertList, sigAlgID, sig);
  94. }
  95. }
  96. }
  97. #pragma warning restore
  98. #endif