当前位置: 首页>>代码示例>>C#>>正文


C# X509Certificate2.GetECDsaPrivateKey方法代码示例

本文整理汇总了C#中X509Certificate2.GetECDsaPrivateKey方法的典型用法代码示例。如果您正苦于以下问题:C# X509Certificate2.GetECDsaPrivateKey方法的具体用法?C# X509Certificate2.GetECDsaPrivateKey怎么用?C# X509Certificate2.GetECDsaPrivateKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在X509Certificate2的用法示例。


在下文中一共展示了X509Certificate2.GetECDsaPrivateKey方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ReadECDsaPrivateKey_OpenSslPfx

        public static void ReadECDsaPrivateKey_OpenSslPfx()
        {
            using (var cert = new X509Certificate2(TestData.ECDsaP256_DigitalSignature_Pfx_OpenSsl, "Test"))
            using (ECDsa ecdsa = cert.GetECDsaPrivateKey())
            {
                Assert.NotNull(ecdsa);

                if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
                {
                    // If Windows were to start detecting this case as ECDSA that wouldn't be bad,
                    // but this assert is the only proof that this certificate was made with OpenSSL.
                    //
                    // Windows ECDSA PFX files contain metadata in the private key keybag which identify it
                    // to Windows as ECDSA.  OpenSSL doesn't have anywhere to persist that data when
                    // extracting it to the key PEM file, and so no longer has it when putting the PFX
                    // together.  But, it also wouldn't have had the Windows-specific metadata when the
                    // key was generated on the OpenSSL side in the first place.
                    //
                    // So, again, it's not important that Windows "mis-detects" this as ECDH.  What's
                    // important is that we were able to create an ECDsa object from it.
                    AssertEccAlgorithm(ecdsa, "ECDH_P256");
                }
            }
        }
开发者ID:ESgarbi,项目名称:corefx,代码行数:24,代码来源:PfxTests.cs

示例2: ReadECDsaPrivateKey_WindowsPfx

        public static void ReadECDsaPrivateKey_WindowsPfx()
        {
            using (var cert = new X509Certificate2(TestData.ECDsaP256_DigitalSignature_Pfx_Windows, "Test"))
            using (ECDsa ecdsa = cert.GetECDsaPrivateKey())
            {
                Assert.NotNull(ecdsa);

                if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
                {
                    AssertEccAlgorithm(ecdsa, "ECDSA_P256");
                }
            }
        }
开发者ID:ESgarbi,项目名称:corefx,代码行数:13,代码来源:PfxTests.cs

示例3: ReadECDsaPrivateKey_BrainpoolP160r1_Pfx

        public static void ReadECDsaPrivateKey_BrainpoolP160r1_Pfx(byte[] pfxData)
        {
            try
            {
                using (var cert = new X509Certificate2(pfxData, TestData.PfxDataPassword))
                {
                    using (ECDsa ecdsa = cert.GetECDsaPrivateKey())
                    {
                        Assert.NotNull(ecdsa);

                        if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
                        {
                            AssertEccAlgorithm(ecdsa, "ECDH");
                        }
                    }
                }
            }
            catch (CryptographicException)
            {
                // Windows 7, Windows 8, Ubuntu 14, CentOS can fail. Verify known good platforms don't fail.
                Assert.False(PlatformDetection.IsWindows && PlatformDetection.WindowsVersion >= 10);
                Assert.False(PlatformDetection.IsUbuntu1604);
                Assert.False(PlatformDetection.IsOSX);

                return;
            }
        }
开发者ID:ESgarbi,项目名称:corefx,代码行数:27,代码来源:PfxTests.cs

示例4: ReadECDsaPrivateKey_WindowsPfx

 public static void ReadECDsaPrivateKey_WindowsPfx(X509KeyStorageFlags keyStorageFlags)
 {
     using (var cert = new X509Certificate2(TestData.ECDsaP256_DigitalSignature_Pfx_Windows, "Test", keyStorageFlags))
     {
         using (ECDsa ecdsa = cert.GetECDsaPrivateKey())
         {
             Verify_ECDsaPrivateKey_WindowsPfx(ecdsa);
         }
     }
 }
开发者ID:dotnet,项目名称:corefx,代码行数:10,代码来源:PfxTests.cs


注:本文中的X509Certificate2.GetECDsaPrivateKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。