コード例 #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
        }
コード例 #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);
 }
コード例 #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);
        }
コード例 #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));
 }