PEMWriter.cs 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System.IO;
  4. using Best.HTTP.SecureProtocol.Org.BouncyCastle.Security;
  5. using Best.HTTP.SecureProtocol.Org.BouncyCastle.Utilities.IO.Pem;
  6. namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.OpenSsl
  7. {
  8. /// <remarks>General purpose writer for OpenSSL PEM objects.</remarks>
  9. public class PemWriter
  10. : Utilities.IO.Pem.PemWriter
  11. {
  12. /// <param name="writer">The TextWriter object to write the output to.</param>
  13. public PemWriter(TextWriter writer)
  14. : base(writer)
  15. {
  16. }
  17. public void WriteObject(object obj)
  18. {
  19. try
  20. {
  21. base.WriteObject(new MiscPemGenerator(obj));
  22. }
  23. catch (PemGenerationException e)
  24. {
  25. if (e.InnerException is IOException inner)
  26. throw inner;
  27. throw e;
  28. }
  29. }
  30. public void WriteObject(
  31. object obj,
  32. string algorithm,
  33. char[] password,
  34. SecureRandom random)
  35. {
  36. base.WriteObject(new MiscPemGenerator(obj, algorithm, password, random));
  37. }
  38. }
  39. }
  40. #pragma warning restore
  41. #endif