WCF分布式开发常见错误(27):Secure channel cannot be opened

简介:
这个问题是周宏伟在调试 WCF分布式安全开发实践(12):消息安全模式之自定义X509证书验证:Message_CustomX509Certificate_WSHttpBinding 。发现并提出来的,我帮助调试,找到了问题的解决办法。发出来一起分享给大家。
【1.问题描述】:
    1.项目类型:IIS托管的WCF服务。
    2.安全类型: 消息安全模式+ 自定义X509证书验证。+WSHttpBinding :Message_CustomX509Certificate_WSHttpBinding
   3.客户端类型:ASP.NET 网站。
   4.错误信息: Secure channel cannot be opened because security negotiation with the remote endpoint has failed. This may be due to absent or incorrectly specified EndpointIdentity in the EndpointAddress used to create the channel. Please verify the EndpointIdentity specified or implied by the EndpointAddress correctly identifies the remote endpoint.
  安全通道无法打开,因为安全与远程终结点协商已经失败。这可能是由于在EndpointAddress 缺少或不正确指定用于创建通道的EndpointIdentity。请验证EndpointIdentity指定或暗示的EndpointAddress正确标识远程终结点。
   5.错误截图:
【2.问题分析】:
     导致这个问题的可能原因有2个:
(1)没有服务端配置安全选项。
(2)服务没有启动。
    网上的同样的问题也很多,但是没有什么帮助。这里针对2个Web类型的应用项目。在调试的时候容易出现这样的问题。
【3.解决方案】:
  原因(1):
         检查服务配置,证书设置:
 
             < wsHttpBinding >
                
< binding  name ="MyBindingConfigration" >
                    
< security  mode ="Message" >
                        
< transport  clientCredentialType ="None" />
                        
< message  clientCredentialType ="Certificate" />
                    
</ security >
                
</ binding >
            
</ wsHttpBinding >
     原因(2):由于一个解决方案里包含2个项目,所以要保证服务启动。步骤如下:
            这个问题的关键在于,你虽然设置了证书,这里错误提示是,与服务终结点协商失败,原因不是证书。
            是整数标识的服务,没有启动,导致协商错误。你右键-》Debug->启动新的实例,先把服务启动。
            然后在右键-》Debug->启动新的客户端项目实例。这样单步调试就通过了。
            我把证书名称换为我本机的证书,你记得根据自己的证书名称修改配置文件。
参考链接:

 本文转自 frankxulei 51CTO博客,原文链接:http://blog.51cto.com/frankxulei/320966 ,如需转载请自行联系原作者
相关文章
|
9月前
|
C++
WCF框架-分布式联调
WCF框架-分布式联调
56 0
|
自然语言处理 网络协议 数据格式

热门文章

最新文章