CertificateList.cs 2.6 KB

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