PKCS12StoreBuilder.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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.Pkcs;
  6. namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Pkcs
  7. {
  8. public class Pkcs12StoreBuilder
  9. {
  10. private DerObjectIdentifier keyAlgorithm = PkcsObjectIdentifiers.PbeWithShaAnd3KeyTripleDesCbc;
  11. private DerObjectIdentifier certAlgorithm = PkcsObjectIdentifiers.PbewithShaAnd40BitRC2Cbc;
  12. private DerObjectIdentifier keyPrfAlgorithm = null;
  13. private DerObjectIdentifier certPrfAlgorithm = null;
  14. private bool useDerEncoding = false;
  15. public Pkcs12StoreBuilder()
  16. {
  17. }
  18. public Pkcs12Store Build()
  19. {
  20. return new Pkcs12Store(keyAlgorithm, keyPrfAlgorithm, certAlgorithm, certPrfAlgorithm, useDerEncoding);
  21. }
  22. public Pkcs12StoreBuilder SetCertAlgorithm(DerObjectIdentifier certAlgorithm)
  23. {
  24. this.certAlgorithm = certAlgorithm;
  25. return this;
  26. }
  27. public Pkcs12StoreBuilder SetKeyAlgorithm(DerObjectIdentifier keyAlgorithm)
  28. {
  29. this.keyAlgorithm = keyAlgorithm;
  30. return this;
  31. }
  32. // Specify a PKCS#5 Scheme 2 encryption for keys
  33. public Pkcs12StoreBuilder SetKeyAlgorithm(DerObjectIdentifier keyAlgorithm, DerObjectIdentifier keyPrfAlgorithm)
  34. {
  35. this.keyAlgorithm = keyAlgorithm;
  36. this.keyPrfAlgorithm = keyPrfAlgorithm;
  37. return this;
  38. }
  39. public Pkcs12StoreBuilder SetUseDerEncoding(bool useDerEncoding)
  40. {
  41. this.useDerEncoding = useDerEncoding;
  42. return this;
  43. }
  44. }
  45. }
  46. #pragma warning restore
  47. #endif