コード例 #1
0
 static void ExportPem(CertificateProvider certProvider, IssuedCertificate certificate, string filePath)
 {
     using (var fileStream = File.Create(filePath))
     {
         certProvider.ExportCertificate(certificate.PublicKey, EncodingFormat.PEM, fileStream);
         certProvider.ExportPrivateKey(certificate.PrivateKey, EncodingFormat.PEM, fileStream);
     }
 }
コード例 #2
0
 static void ExportPfx(CertificateProvider certProvider, IssuedCertificate certificate, string filePath)
 {
     using (var fileStream = File.Create(filePath))
     {
         certProvider.ExportArchive(
             certificate.PrivateKey,
             new[] { certificate.PublicKey, certificate.CAPublicKey },
             ArchiveFormat.PKCS12,
             fileStream);
     }
 }
コード例 #3
0
        public static void Export(CertificateProvider certProvider, IssuedCertificate certificate, CertOutputType outType, string filePath)
        {
            switch (outType)
            {
            case CertOutputType.Pfx:
                ExportPfx(certProvider, certificate, filePath);
                break;

            case CertOutputType.Pem:
                ExportPem(certProvider, certificate, filePath);
                break;
            }
        }