web developer tips (41):用自颁发的证书连接到远程IIS服务器
2009-09-02 01:07
363 查看
原文地址:establishing a remote connection to a IIS server with self-issued certificate will require a certificate validation delegate
要么通过WMSvc 要么通过自己的脚本,当你尝试与远程服务器建立一个连接,没有提供受信任的证书,你需要提供证书验证的委托,用来检查不受信任的证书。
http://www.watch-life.net/visual-studio/establishing-a-remote-connection-to-a-iis-server-with-self-issued-certificate.html
这个委托的签名如下:
Namespace: System.Net.Security
Assembly: System (in System.dll)
public delegate bool RemoteCertificateValidationCallback(
Object sender,
X509Certificate certificate,
X509Chain chain,
SslPolicyErrors sslPolicyErrors
)
于是,接受所有服务器证书,你需要设置一个ServicePointManager的回调来来验证一个服务器的证书,如下所示:
ServicePointManager.ServerCertificateValidationCallback = RemoteCertificateValidationCallbackFlag;
bool RemoteCertificateValidationCallbackCheck(
Object sender,
X509Certificate certificate,
X509Chain chain,
SslPolicyErrors sslPolicyErrors
)
{
return true;
}
关于这个“委托”可以参考MSDN文档:
1、RemoteCertificateValidationCallback Delegate
2、ServicePointManager.ServerCertificateValidationCallback Property
更多文章见:守望轩[http://www.watch-life.net/]
要么通过WMSvc 要么通过自己的脚本,当你尝试与远程服务器建立一个连接,没有提供受信任的证书,你需要提供证书验证的委托,用来检查不受信任的证书。
http://www.watch-life.net/visual-studio/establishing-a-remote-connection-to-a-iis-server-with-self-issued-certificate.html
这个委托的签名如下:
Namespace: System.Net.Security
Assembly: System (in System.dll)
public delegate bool RemoteCertificateValidationCallback(
Object sender,
X509Certificate certificate,
X509Chain chain,
SslPolicyErrors sslPolicyErrors
)
于是,接受所有服务器证书,你需要设置一个ServicePointManager的回调来来验证一个服务器的证书,如下所示:
ServicePointManager.ServerCertificateValidationCallback = RemoteCertificateValidationCallbackFlag;
bool RemoteCertificateValidationCallbackCheck(
Object sender,
X509Certificate certificate,
X509Chain chain,
SslPolicyErrors sslPolicyErrors
)
{
return true;
}
关于这个“委托”可以参考MSDN文档:
1、RemoteCertificateValidationCallback Delegate
2、ServicePointManager.ServerCertificateValidationCallback Property
更多文章见:守望轩[http://www.watch-life.net/]
相关文章推荐
- web developer tips (41):用自颁发的证书连接到远程IIS服务器
- web developer tips (41):用自颁发的证书连接到远程IIS服务器
- web developer tips (17):远程调试使用IIS的web应用
- web developer tips (20):使用IIS作为web服务器
- “服务器上远程桌面连接的加密设置”,“客户机的具有加密功能远程桌面功能的安装”以及“客户机证书的安装”等操作
- web developer tips (17):远程调试使用IIS的web应用
- HttpWebRequest加载证书请求远端https服务器时 : 基础连接已经关闭: 无法与远程服务器建立信任关系
- web developer tips (20):使用IIS作为web服务器
- web developer tips (20):使用IIS作为web服务器
- web developer tips (17):远程调试使用IIS的web应用
- 调用部署在本机IIS服务器的WCF服务并返回数据DataTable,一直报错:远程主机强迫关闭了一个现有的连接,但是服务访问正常
- 在建立与服务器的连接时出错。在连接到 SQL Server 2005 时,在默认的设置下 SQL Server 不允许进行远程连接可能会导致此失败。 (provider: 命名管道提供程序, error: 40 - 无法打开到 SQL Server 的连接
- 登录SQL Server2008出现错误未找到或无法访问服务器,出现与网络相关的或特定于实例的错误。请验证实例名称是否正确并且 SQL Server 已配置为允许远程连接
- CA(证书颁发机构)服务器配置图解过程 http://www.45it.com/net/200709/18036.htm
- SQL Server2005 远程连接服务器的设置
- 连接远程MySQL服务器
- 远程连接阿里云服务器----Linux学习笔记(2)
- 配置vnc远程连接Linux和Unix远程服务器图形界面安装oracle
- jmx连接远程服务器
- 路由器端口映射,远程桌面连接--端口映射+花生壳=让人访问你个人服务器或WEB站点