OtherSigningCertificate.cs 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.X509;
  5. using BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities;
  6. namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.Ess
  7. {
  8. [Obsolete("Use version in Asn1.Esf instead")]
  9. public class OtherSigningCertificate
  10. : Asn1Encodable
  11. {
  12. private Asn1Sequence certs, policies;
  13. public static OtherSigningCertificate GetInstance(
  14. object o)
  15. {
  16. if (o == null || o is OtherSigningCertificate)
  17. {
  18. return (OtherSigningCertificate) o;
  19. }
  20. if (o is Asn1Sequence)
  21. {
  22. return new OtherSigningCertificate((Asn1Sequence) o);
  23. }
  24. throw new ArgumentException(
  25. "unknown object in 'OtherSigningCertificate' factory : "
  26. + BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities.Platform.GetTypeName(o) + ".");
  27. }
  28. /**
  29. * constructors
  30. */
  31. public OtherSigningCertificate(
  32. Asn1Sequence seq)
  33. {
  34. if (seq.Count < 1 || seq.Count > 2)
  35. {
  36. throw new ArgumentException("Bad sequence size: " + seq.Count);
  37. }
  38. this.certs = Asn1Sequence.GetInstance(seq[0]);
  39. if (seq.Count > 1)
  40. {
  41. this.policies = Asn1Sequence.GetInstance(seq[1]);
  42. }
  43. }
  44. public OtherSigningCertificate(
  45. OtherCertID otherCertID)
  46. {
  47. certs = new DerSequence(otherCertID);
  48. }
  49. public OtherCertID[] GetCerts()
  50. {
  51. OtherCertID[] cs = new OtherCertID[certs.Count];
  52. for (int i = 0; i != certs.Count; ++i)
  53. {
  54. cs[i] = OtherCertID.GetInstance(certs[i]);
  55. }
  56. return cs;
  57. }
  58. public PolicyInformation[] GetPolicies()
  59. {
  60. if (policies == null)
  61. {
  62. return null;
  63. }
  64. PolicyInformation[] ps = new PolicyInformation[policies.Count];
  65. for (int i = 0; i != policies.Count; i++)
  66. {
  67. ps[i] = PolicyInformation.GetInstance(policies[i]);
  68. }
  69. return ps;
  70. }
  71. /**
  72. * The definition of OtherSigningCertificate is
  73. * <pre>
  74. * OtherSigningCertificate ::= SEQUENCE {
  75. * certs SEQUENCE OF OtherCertID,
  76. * policies SEQUENCE OF PolicyInformation OPTIONAL
  77. * }
  78. * </pre>
  79. * id-aa-ets-otherSigCert OBJECT IDENTIFIER ::= { iso(1)
  80. * member-body(2) us(840) rsadsi(113549) pkcs(1) pkcs9(9)
  81. * smime(16) id-aa(2) 19 }
  82. */
  83. public override Asn1Object ToAsn1Object()
  84. {
  85. Asn1EncodableVector v = new Asn1EncodableVector(certs);
  86. if (policies != null)
  87. {
  88. v.Add(policies);
  89. }
  90. return new DerSequence(v);
  91. }
  92. }
  93. }
  94. #pragma warning restore
  95. #endif