Exemplo n.º 1
0
        public void LoadECDsaCertificate()
        {
#if NET461 || NETCOREAPP2_1
            // Compatible with previous release. Goes through the LightweightPkcs8Decoder.DecodeRSAPkcs8().
            Assert.Throws <InvalidDataException>(() => PemReader.LoadCertificate(ECDsaCertificate.AsSpan(), keyType: PemReader.KeyType.RSA));
#else
            // Compatible with the previous release. Goes through RSA.ImportPKcs8PrivateKey().
            Assert.That(() => PemReader.LoadCertificate(ECDsaCertificate.AsSpan(), keyType: PemReader.KeyType.RSA), Throws.InstanceOf <CryptographicException>());
#endif
        }
Exemplo n.º 2
0
 public void LoadCertificateWithOnlyPublicKeyAllowed()
 {
     using X509Certificate2 certificate = PemReader.LoadCertificate(ECDsaCertificate.AsSpan(), allowCertificateOnly: true, keyType: PemReader.KeyType.ECDsa);
     Assert.AreEqual("CN=Azure SDK", certificate.Subject);
     Assert.IsFalse(certificate.HasPrivateKey);
 }
Exemplo n.º 3
0
        public void LoadCertificateWithoutPrivateKey()
        {
            Exception ex = Assert.Throws <InvalidDataException>(() => PemReader.LoadCertificate(ECDsaCertificate.AsSpan(), keyType: PemReader.KeyType.ECDsa));

            Assert.AreEqual("The certificate is missing the private key", ex.Message);
        }
Exemplo n.º 4
0
 public void LoadECDsaCertificateAutomatically()
 {
     // Support for ECDsa certificates are not supported by default. See Azure.Security.KeyVault.Certificates for support.
     Assert.Throws <NotSupportedException>(() => PemReader.LoadCertificate(ECDsaCertificate.AsSpan(), keyType: PemReader.KeyType.Auto));
 }