using System;
using System.Security.Cryptography.X509Certificates;
using System.Text;
namespace LetsEncrypt
{
class Library
{
///
/// Export a certificate to a PEM format string
///
/// The certificate to export
/// A PEM encoded string
public static string ExportToPEM(X509Certificate cert)
{
StringBuilder builder = new StringBuilder();
builder.AppendLine("-----BEGIN CERTIFICATE-----");
builder.AppendLine(Convert.ToBase64String(cert.Export(X509ContentType.Cert), Base64FormattingOptions.InsertLineBreaks));
builder.AppendLine("-----END CERTIFICATE-----");
return builder.ToString();
}
}
}