首页 新闻 会员 周边 捐助

WCF客户端身份验证方案“Anonymous”禁止 HTTP 请求。

0
悬赏园豆:40 [已解决问题] 解决于 2015-02-14 22:54

项目用的是客户端提供证书给服务端验证,详细客户端异常如下

大虾帮帮忙吧~

紫陌轻风的主页 紫陌轻风 | 初学一级 | 园豆:48
提问于:2015-02-10 11:44
< >
分享
最佳答案
0

要用 HTTPS。

收获园豆:40
Launcher | 高人七级 |园豆:45050 | 2015-02-10 11:49

用的就是https啊

紫陌轻风 | 园豆:48 (初学一级) | 2015-02-10 11:51

@紫陌轻风: Endpoint Address 是啥?

Launcher | 园豆:45050 (高人七级) | 2015-02-10 11:55

@Launcher:   <endpoint address="" binding="wsHttpBinding" bindingConfiguration="LxWsHttpBinding" contract="LxContracts.IBookContract"></endpoint>

因为我是搭载在IIS上的

紫陌轻风 | 园豆:48 (初学一级) | 2015-02-10 11:57

@紫陌轻风: 你这段代码是运行在 IIS 上的?

Launcher | 园豆:45050 (高人七级) | 2015-02-10 11:59

@Launcher: 是服务搭载在IIS上,客户端的endpoint

<client>
<endpoint address="https://cn--20141114fqe:9010/BookSrv.svc"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IBookContract"
contract="WCF.Service.IBookContract" name="WSHttpBinding_IBookContract" behaviorConfiguration="cnt2Behavior" />
</client>

紫陌轻风 | 园豆:48 (初学一级) | 2015-02-10 12:00

@紫陌轻风: 客户端的 binding 配置是啥?

Launcher | 园豆:45050 (高人七级) | 2015-02-10 12:37

@Launcher: 整个servicemodel发给你看好了

紫陌轻风 | 园豆:48 (初学一级) | 2015-02-10 12:49

@Launcher: 

<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="cnt2Behavior">
<clientCredentials>
<clientCertificate storeName="My" x509FindType="FindBySubjectName" findValue="Client2-PC" storeLocation="CurrentUser"/>
</clientCredentials>
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IBookContract">
<security mode="Transport">
<transport clientCredentialType="Certificate" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="https://cn--20141114fqe:9010/BookSrv.svc"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IBookContract"
contract="WCF.Service.IBookContract" name="WSHttpBinding_IBookContract" behaviorConfiguration="cnt2Behavior" />
</client>
</system.serviceModel>

紫陌轻风 | 园豆:48 (初学一级) | 2015-02-10 12:49

@紫陌轻风: clientCredentials 中缺少 serviceCrtificate 的设置

Launcher | 园豆:45050 (高人七级) | 2015-02-10 13:08

@Launcher: 写成这样?

<clientCredentials>
<serviceCertificate>
<authentication certificateValidationMode="Custom" customCertificateValidatorType="Client2.vailtor,Client2"/>
</serviceCertificate>
<clientCertificate storeName="My" x509FindType="FindBySubjectName" findValue="Client2-PC" storeLocation="CurrentUser"/>
</clientCredentials>

紫陌轻风 | 园豆:48 (初学一级) | 2015-02-10 13:30

@紫陌轻风: 你咋能随便乱改呢?你服务器的安全模式是咋设置的?

Launcher | 园豆:45050 (高人七级) | 2015-02-10 13:34

@Launcher: 我刚学不久...我服务端设置

<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="LxBehavior">
<serviceMetadata httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
<serviceCredentials>
<clientCertificate>
<authentication customCertificateValidatorType="HostWeb_Server.Vailtor,HostWeb_Server" certificateValidationMode="Custom" />
</clientCertificate>
<serviceCertificate findValue="CN--20141114FQE" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName" />
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<wsHttpBinding>
<binding name="LxWsHttpBinding">
<security mode="Transport">
<transport clientCredentialType="Certificate"></transport>
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service name="LxServices.BookService" behaviorConfiguration="LxBehavior">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="LxWsHttpBinding" contract="LxContracts.IBookContract"></endpoint>
</service>
</services>


<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>

紫陌轻风 | 园豆:48 (初学一级) | 2015-02-10 13:36
其他回答(1)
0

你的iis有没有enable anonymous authentication

JanTian | 园豆:202 (菜鸟二级) | 2015-02-20 00:34
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册