PKCS12StoreBuilder.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. using Best.HTTP.SecureProtocol.Org.BouncyCastle.Asn1;
  5. using Best.HTTP.SecureProtocol.Org.BouncyCastle.Asn1.Pkcs;
  6. namespace Best.HTTP.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 bool useDerEncoding = false;
  14. public Pkcs12StoreBuilder()
  15. {
  16. }
  17. public Pkcs12Store Build()
  18. {
  19. return new Pkcs12Store(keyAlgorithm, keyPrfAlgorithm, certAlgorithm, useDerEncoding);
  20. }
  21. public Pkcs12StoreBuilder SetCertAlgorithm(DerObjectIdentifier certAlgorithm)
  22. {
  23. this.certAlgorithm = certAlgorithm;
  24. return this;
  25. }
  26. public Pkcs12StoreBuilder SetKeyAlgorithm(DerObjectIdentifier keyAlgorithm)
  27. {
  28. this.keyAlgorithm = keyAlgorithm;
  29. return this;
  30. }
  31. // Specify a PKCS#5 Scheme 2 encryption for keys
  32. public Pkcs12StoreBuilder SetKeyAlgorithm(DerObjectIdentifier keyAlgorithm, DerObjectIdentifier keyPrfAlgorithm)
  33. {
  34. this.keyAlgorithm = keyAlgorithm;
  35. this.keyPrfAlgorithm = keyPrfAlgorithm;
  36. return this;
  37. }
  38. public Pkcs12StoreBuilder SetUseDerEncoding(bool useDerEncoding)
  39. {
  40. this.useDerEncoding = useDerEncoding;
  41. return this;
  42. }
  43. }
  44. }
  45. #pragma warning restore
  46. #endif