在C#中禁用客户端证书信任

时间:2010-12-22 09:41:54

标签: c# web-services ssl-certificate

是否有一种在C#中禁用客户端应用程序证书信任的编程方法?

1 个答案:

答案 0 :(得分:0)

您可以使用X509Certificate Class

也许X509Certificate2 Class

实施例

using System;

using System.Security.Cryptography.X509Certificates;


public class X509
{

    public static void Main()
    {

        // The path to the certificate.
        string Certificate = "Certificate.cer";

        // Load the certificate into an X509Certificate object.
        X509Certificate cert = new X509Certificate(Certificate);

        // Get the value.
        string resultsTrue = cert.ToString(true);

        // Display the value to the console.
        Console.WriteLine(resultsTrue);

        // Get the value.
        string resultsFalse = cert.ToString(false);

        // Display the value to the console.
        Console.WriteLine(resultsFalse);

    }

}