コード例 #1
0
        public void GenerateCert()
        {
            var keypair       = new RSAKeyPairGenerator().Generate();
            var certGenerator = new CertGenerator().SetPublicKey(keypair.PublicKey);

            certGenerator.AddALternativeName("127.0.0.1");
            var cert     = certGenerator.Generate(keypair.PrivateKey);
            var cert_gen = new X509CertificateParser().ReadCertificate(cert.GetEncoded());

            Assert.Equal(cert, cert_gen);
            Assert.Equal(keypair.PublicKey, cert.GetPublicKey());
        }
コード例 #2
0
        public void Generate_Certificate()
        {
            var keypair       = new RSAKeyPairGenerator().Generate();
            var certGenerator = new CertGenerator().SetPublicKey(keypair.PublicKey);

            certGenerator.AddAlternativeName("127.0.0.1");
            var cert    = certGenerator.Generate(keypair.PrivateKey);
            var certGen = new X509CertificateParser().ReadCertificate(cert.GetEncoded());

            cert.ShouldBe(certGen);
            cert.GetPublicKey().ShouldBe(keypair.PublicKey);
        }