尝试通过SSL使HelloWorld工作。阅读所有这些文档:
How to: Create Temporary Certificates for Use During Development
我所知道的是,证书似乎是正确创建和部署的(实际上都是证书)。不过,我猜我的web.config有问题(对不起,此时不能更具体)。这就像没有服务器监听443或客户端期望 http 而不是 https 。有人可以请我指出适当的资源和/或告诉我我做错了什么?
web.config在这里:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="HTTPBaseAddress" value=""/>
</appSettings>
<system.serviceModel>
<services>
<service behaviorConfiguration="MyServiceTypeBehaviors" name="MyWCFServices.HelloWorldService">
<clear />
<endpoint address="mex" binding="mexHttpBinding" name="mexEndpoint" contract="IMetadataExchange" listenUriMode="Explicit">
<identity>
<dns value="localhost" />
<certificateReference storeName="My" storeLocation="LocalMachine" x509FindType="FindBySubjectDistinguishedName" />
</identity>
</endpoint>
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="" name="SSLendpoint" contract="MyWCFServices.IHelloWorldService">
<identity>
<dns value="localhost" />
<certificateReference x509FindType="FindByThumbprint" findValue="82a39faaeb18bf9585b334ca83264add3d5b26ee" />
</identity>
</endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MyServiceTypeBehaviors" >
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
客户端app.config位于:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="NoSecurity">
<security mode="None" />
</binding>
<binding name="SSLsecurity">
<security mode="Transport">
<transport clientCredentialType="None" />
<message clientCredentialType="Certificate" /
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="https://localhost:443/HelloWorldSSL/HelloWorldService.svc"
binding="wsHttpBinding" bindingConfiguration="" contract="IHelloWorldService"
name="wsHttpBinding_IHelloWorldService" />
</client>
</system.serviceModel>
</configuration>
如果需要任何其他信息/屏幕截图 - 我会很乐意提供它(像往常一样)。希望这是一个可回答的问题:)
答案 0 :(得分:3)
您的配置不正确。您没有在端点中定义自定义绑定配置,因此未使用HTTPS。将此服务用于服务器:
<bindings>
<wsHttpBinding>
<binding name="SSLSecurity">
<security mode="Transport">
<transport clientCredentialType="None" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="MyServiceTypeBehaviors" >
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="MyServiceTypeBehaviors"
name="MyWCFServices.HelloWorldService">
<endpoint address="mex" binding="mexHttpBinding" name="mexEndpoint"
contract="IMetadataExchange" listenUriMode="Explicit" />
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="SSLSecurity"
name="SSLendpoint" contract="MyWCFServices.IHelloWorldService" />
</service>
</services>
供客户使用:
<bindings>
<wsHttpBinding>
<binding name="SSLSecurity">
<security mode="Transport">
<transport clientCredentialType="None" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="https://localhost:443/HelloWorldSSL/HelloWorldService.svc"
binding="wsHttpBinding" bindingConfiguration="SSLSecurity"
contract="IHelloWorldService" name="wsHttpBinding_IHelloWorldService" />
</client>