c# - 在 localhost 上为 https/SSL 配置 wcf 服务
问题描述
编辑:已经修复它...我只需要更改项目属性并启用 SSL。
原始问题:
我正在开发一个 WCF 服务,该服务将托管在具有 SSL 证书的 IIS 服务器中。
当我将代码上传到服务器(具有所有证书)时,我的代码工作得非常好,但是由于我将安全性添加到 Web 配置中,当我尝试在本地机器上调试它时它会崩溃。
我将以下 Web 配置用于不需要 SSL 证书的 SOAP 服务和需要它的 REST 服务:
<configuration>
...
<bindings>
<basicHttpBinding>
<binding name="SOAPEndPoint" />
</basicHttpBinding>
<webHttpBinding>
<binding name="SecureBinding" >
<security mode="Transport"></security>
</binding>
</webHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="ServiceBehavior" name="xxx.WS">
<endpoint address="SOAP" binding="basicHttpBinding" name="SOAPEndPoint" contract="xxx.ISerSoap" />
<endpoint address="api" binding="webHttpBinding" name="RESTEndPoint" contract="xxx.ISerRest" behaviorConfiguration="RestBehavior" bindingConfiguration="SecureBinding"/>
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata httpsGetEnabled="true" httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="RestBehavior">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<directoryBrowse enabled="true" />
</system.webServer>
</configuration>
我希望能够调试它,而无需在每次在调试期间打开它时更改 Web 配置,并且如果我必须将其上传到服务器。
当我在调试模式下调用它时,有人知道绕过安全性的方法吗?或者在我的本地主机上添加对 https 的支持的简单方法?
解决方案
只是发现解决方案是在项目属性窗口上激活“SSL Enabled = true”。
推荐阅读
- reactjs - 如何在 React 中正确实现 HOC
- android - 如何在没有安全设置的安卓设备上安装网络证书?
- python - Pytest - 将测试运行生成的数据提取到conftest中的文件/夹具?
- c - C 有趣的 for 循环
- arrays - 谷歌表格拆分转置加入
- python - 无法从 firebase_admin 导入 firestore
- docker-registry - 如何配置或自定义 Docker Registry 以在标签级别授权访问
- node.js - 为什么这个反应组件不显示加载的内容?
- json - 在 Postgres 中操作嵌套的 JSON
- c# - 为为密码轮换调用的 aws lambda 设置有效负载