public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { X509Certificate2 cert = (X509Certificate2)value; writer.WriteValue( UrlSafeBase64.EncodeBytes( cert.Export(X509ContentType.Pkcs12) ) ); }
public void SeralizeCertificate() { CheckCertificate(); if (PasswordEncrypt) { if (EncryptionPassword == null) { throw new Exception("No decryption password was specified, can't encrypt the certificate"); } CertificateBase64 = UrlSafeBase64.EncodeBytes(_certificate.Export(X509ContentType.Pkcs12, EncryptionPassword)); } if (ProtectedStoragePath != null) { throw new NotImplementedException("Todo: implement OS storage"); } if (!PasswordEncrypt && ProtectedStoragePath == null) { CertificateBase64 = UrlSafeBase64.EncodeBytes(_certificate.Export(X509ContentType.Pkcs12)); } }
public static string GetBytesB64(int ByteLength) { var b = GetBytes(ByteLength); return(UrlSafeBase64.EncodeBytes(b)); }