我有一个带有以下配置文件的WCF服务。即使我已指定clientCredentialType = None
,WCF服务(来自VS2013)也会抛出异常,指出未指定证书。
为什么会这样?仅当clientCredentialType
设置为证书时,才应该要求证书。
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding>
<security mode="Message">
<message clientCredentialType="Windows"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service name="WCFBindingwshttpBinding.Service1">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="" contract="WCFBindingwshttpBinding.IService1">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8733/Design_Time_Addresses/WCFBindingwshttpBinding/Service1/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information,
set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="True" httpsGetEnabled="True"/>
<!-- To receive exception details in faults for debugging purposes,
set the value below to true. Set to false before deployment
to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
答案 0 :(得分:2)
我认为您收到错误是因为您没有指定服务器证书。
我记得,在使用消息加密(<security mode="Message">
)时,WCF需要传输级别的安全性,以便安全地交换“共享密钥”并建立安全上下文。因此,由于您使用的是WSHttpBinding
,因此使用服务器证书来建立安全通道。
以下链接提供了良好的相关信息:
WCF message security without certificate and windows auth