public async Task Should_Create_Certificate_With_Private_Key() { var ca = X509CertificateFactory.LoadCertificate(CertificateProvider.RootCA); var provider = new BouncyCastleCertificateProvider(ca); var cert = await provider.GetCertificateForSubjectAsync("*.proxy.com.ar"); Assert.IsNotNull(cert); Assert.AreEqual("CN=*.proxy.com.ar", cert.Subject); Assert.AreEqual("CN=*.proxy.com.ar", cert.Issuer); Assert.IsTrue(cert.HasPrivateKey); VerifyChain(cert); }
public async Task Should_Save_And_Load_Certificate_With_Private_Key() { var ca = X509CertificateFactory.LoadCertificate(CertificateProvider.RootCA); var provider = new BouncyCastleCertificateProvider(ca); var createdCert = await provider.GetCertificateForSubjectAsync("*.proxy.com.ar"); createdCert.Save("saved.certificate"); var loadedCert = X509CertificateFactory.LoadCertificateFromFile("saved.certificate"); Assert.IsNotNull(loadedCert); Assert.AreEqual("CN=*.proxy.com.ar", loadedCert.Subject); Assert.AreEqual("CN=*.proxy.com.ar", loadedCert.Issuer); Assert.IsTrue(loadedCert.HasPrivateKey); VerifyChain(loadedCert); }