コード例 #1
0
ファイル: Program.cs プロジェクト: Altinn/cert-generator
        static int RunCertificateOptions(Options o)
        {
            using (CertificateAuthority authority = new CertificateAuthority(o.InPfxFile, o.InPfxPassword))
            {
                X509Certificate2 cert     = authority.GenerateAndSignCertificate(o.SubjectName);
                byte[]           pfxBytes = cert.Export(X509ContentType.Pfx, o.PfxPassword);
                File.WriteAllBytes(o.PfxFile + ".pfx", pfxBytes);

                if (false == o.NoPem)
                {
                    File.WriteAllText(o.PfxFile + ".pem", cert.ToPem());
                }

                if (o.ExportKey)
                {
                    File.WriteAllText(o.PfxFile + ".key", cert.ToPrivateKeyPkcs());
                }
            }

            return(0);
        }