PEMWriter.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. using System.Diagnostics;
  5. using System.Globalization;
  6. using System.IO;
  7. using System.Text;
  8. using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1;
  9. using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.CryptoPro;
  10. using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.Pkcs;
  11. using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.X509;
  12. using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.X9;
  13. using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto;
  14. using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Generators;
  15. using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Parameters;
  16. using BestHTTP.SecureProtocol.Org.BouncyCastle.Math;
  17. using BestHTTP.SecureProtocol.Org.BouncyCastle.Pkcs;
  18. using BestHTTP.SecureProtocol.Org.BouncyCastle.Security;
  19. using BestHTTP.SecureProtocol.Org.BouncyCastle.Security.Certificates;
  20. using BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities.Encoders;
  21. using BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities.IO.Pem;
  22. using BestHTTP.SecureProtocol.Org.BouncyCastle.X509;
  23. namespace BestHTTP.SecureProtocol.Org.BouncyCastle.OpenSsl
  24. {
  25. /// <remarks>General purpose writer for OpenSSL PEM objects.</remarks>
  26. public class PemWriter
  27. : BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities.IO.Pem.PemWriter
  28. {
  29. /// <param name="writer">The TextWriter object to write the output to.</param>
  30. public PemWriter(
  31. TextWriter writer)
  32. : base(writer)
  33. {
  34. }
  35. public void WriteObject(
  36. object obj)
  37. {
  38. try
  39. {
  40. base.WriteObject(new MiscPemGenerator(obj));
  41. }
  42. catch (PemGenerationException e)
  43. {
  44. if (e.InnerException is IOException)
  45. throw (IOException)e.InnerException;
  46. throw e;
  47. }
  48. }
  49. public void WriteObject(
  50. object obj,
  51. string algorithm,
  52. char[] password,
  53. SecureRandom random)
  54. {
  55. base.WriteObject(new MiscPemGenerator(obj, algorithm, password, random));
  56. }
  57. }
  58. }
  59. #pragma warning restore
  60. #endif