我正在尝试使用 WCF 通过 Internet 设计 Web 服务。要求是我们需要提供 TLS(传输层安全)和 MLS(消息层安全)。为此,我们使用安全模式为“ TransportWithMessageCredential ”的“ ws2007HttpBinding ”。在这里,我发现请求是通过 SSL 传输的,但是当使用 Fiddler(用于 https)时,我发现肥皂正文是明文格式。
对于传输级安全性,我使用 ClientCredentialType 作为“None”,对于消息级安全性,我使用“Certificate”作为 ClientCredentialType。
我正在使用 .net 框架 3.5。
供您参考,我正在为 SSL 和服务器使用不同的证书。
我的服务器 Web.config 如下。
<system.serviceModel>
<services>
<service behaviorConfiguration="API_WCF.Service1Behavior" name="API_WCF.API">
<endpoint address="https://localhost/API_WCF/API.svc" name="API" binding="ws2007HttpBinding" bindingConfiguration="customWsHttpBinding" contract="API_WCF.IARDAPI">
<identity>
<dns />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
</service>
</services>
<bindings>
<ws2007HttpBinding>
<binding name="customWsHttpBinding">
<!-- For http -->
<!--
<security mode="Message">
<message clientCredentialType="Certificate" negotiateServiceCredential="false" establishSecurityContext="false"/>
</security>
-->
<!-- For https -->
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="None"/>
<message clientCredentialType="Certificate" negotiateServiceCredential="false" establishSecurityContext="false"/>
</security>
</binding>
</ws2007HttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="API_WCF.Service1Behavior">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpsGetEnabled="true" httpsGetUrl="https://localhost/API_WCF/API.svc/API"/>
<serviceCredentials>
<serviceCertificate findValue="CN=WSE2QuickStartServer" storeLocation="LocalMachine" x509FindType="FindBySubjectDistinguishedName" storeName="My"/>
<clientCertificate>
<authentication certificateValidationMode="ChainTrust" revocationMode="NoCheck"/>
</clientCertificate>
</serviceCredentials>
<!-- 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="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<diagnostics wmiProviderEnabled="true" performanceCounters="ServiceOnly">
<messageLogging logEntireMessage="true" logMalformedMessages="true" logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" maxMessagesToLog="3000"/>
</diagnostics>
</system.serviceModel>
请指导如何通过 Internet 上的 WCF 中的传输层安全性实现消息级别的安全性。