gpt4 book ai didi

wcf - WebHttpBinding 安全问题

转载 作者:太空宇宙 更新时间:2023-11-03 13:05:02 25 4
gpt4 key购买 nike

我已经创建了一个 RESTful 服务并实现了身份验证。它接受用户名和密码,然后授予对所请求服务的访问权限。它工作正常。现在我想在我的服务之上使用 SSL。为此我创建了证书,然后在 IIS 中我给出了所需的设置。但是我的服务不工作。我正在使用 webHttpBinding。

我在服务端的 Web.Config 是:

 <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
<services>
<service behaviorConfiguration="ServiceBehavior" name="TestAPI">
<host>
<baseAddresses>
<add baseAddress="https://localhost/AuthWithSSLTest/API/TestAPI.svc" />
</baseAddresses>
</host>
<endpoint address="" behaviorConfiguration="RESTFriendly" bindingConfiguration="MywebHttpBinding" binding="webHttpBinding" contract="ITestAPI" >
</endpoint>
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
</service>
</services>
<client /><bindings>
<webHttpBinding>
<binding name="MywebHttpBinding">
<security mode="Transport" >
<transport clientCredentialType="Certificate"/>
</security>
</binding>
</webHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="RESTFriendly">
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata httpGetEnabled="false" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceCredentials>
<clientCertificate>
<authentication revocationMode="NoCheck" />
</clientCertificate>
<serviceCertificate findValue="CN=tempCertClient" />
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>

在我的客户端 app.config 中有

<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="NewBehavior">
<clientCredentials>
<clientCertificate findValue="CN=tempCertClient" storeLocation="LocalMachine" />
<serviceCertificate>
<authentication certificateValidationMode="PeerTrust" revocationMode="NoCheck" />
</serviceCertificate>
</clientCredentials>
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<customBinding>
<binding name="WebHttpBinding_ITestAPI">

<httpTransport/>
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="https://localhost/AuthWithSSLTest/API/API.svc/TestMethod"
behaviorConfiguration="NewBehavior" binding="customBinding"
bindingConfiguration="WebHttpBinding_ITestAPI"
contract="TestAPI.ITestAPI" name="WebHttpBinding_ITestAPI" />
</client>
</system.serviceModel>

当我尝试运行客户端时,它显示提供的 URI 方案 Https 无效,需要 http。

此外,当我尝试从 VS2008 调用 Web 服务时,它说“找不到与具有绑定(bind) WebHttpBinding 的端点的方案 https 匹配的基地址。注册的基地址方案是 [http]。”

如果我尝试从 IIS 运行 Web 服务,它会显示“找不到与具有绑定(bind) WebHttpBinding 的端点的方案 http 相匹配的基地址。注册的基地址方案是 [https]。”

我已经尝试谷歌搜索并尝试了所有建议的事情,但没有成功。请帮忙。

提前致谢,塔拉·辛格

最佳答案

在您的客户端配置中,尝试更改:

<httpTransport/>

到:

<httpsTransport/>

关于wcf - WebHttpBinding 安全问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1717485/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com