1.選擇IIS Management打開Server Certificates
2.選擇Create Selt—Signed Certificates
爲你的SSL取一個名字:TestSSL
3.下來把SSL證書綁定到你的站點:
4.這樣就可以用https去訪問了,
5.但是我們用客戶端訪問時必須加上證書信任纔可以去訪問:
public static class Util
{
/// <summary>
/// Sets the cert policy.
/// </summary>
public static void SetCertificatePolicy()
{
ServicePointManager.ServerCertificateValidationCallback += RemoteCertificateValidate;
}
/// <summary>
/// Remotes the certificate validate.
/// </summary>
private static bool RemoteCertificateValidate(
object sender, X509Certificate cert,
X509Chain chain, SslPolicyErrors error)
{
// trust any certificate!!!
System.Console.WriteLine("Warning, trust any certificate");
return true;
}
}