WCF 自托管 REST 服务器 (https) 不断要求客户端身份验证
WCF Self hosted REST server (https) keeps asking for client authentication
我创建了一个自托管的 WCF REST 服务器 (w/o IIS)。当我启用 SSL 支持时,在 Chrome.
中测试站点时,系统会不断要求我提供客户端认证
下面是我的 app.config,我相信我禁用了客户端身份验证。我在这里遗漏了什么吗?
照片:
Chrome asking for client certificate
App.config代码:
<system.serviceModel>
<services>
<service behaviorConfiguration="ADConnectorLibrary.Service1Behavior" name="ADConnectorLibrary.ADConnectorLibrary">
<endpoint address="" binding="webHttpBinding" bindingConfiguration="webHttpTransportSecurity" behaviorConfiguration="web" contract="ADConnectorLibrary.IADConnectorLibrary" >
</endpoint>
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="https://ADDRESS:8888/ADConnectorLibrary/"/>
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ADConnectorLibrary.Service1Behavior">
<serviceMetadata httpGetEnabled="false" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="False"/>
**<serviceCredentials>
<clientCertificate>
<authentication certificateValidationMode="None" />
</clientCertificate>
</serviceCredentials>**
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="web">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<webHttpBinding>
<binding name="webHttpTransportSecurity">
<security mode="Transport">
**<transport clientCredentialType="None" />**
</security>
</binding>
</webHttpBinding>
</bindings>
由于您使用的是 TransportSecurity,我认为您需要为您的服务分配证书,否则它将无法通过 HTTPS 上的 SSL 加密消息。
同样,客户端必须信任该证书,或者当客户端尝试在浏览器中通过 HTTPS 访问服务时将获得这些响应之一,并且来自代码的调用将失败。
您可能需要使用 netsh,因为您没有使用 IIS。您可能需要稍微研究一下 netsh 以满足您的需要。
像这样将证书注册到端口并映射到应用程序 guid:这是一个纯编造的示例:netsh http add sslcert ipport=127.0.0.1:8000 certhash=c20ed305ea705cc4e36b317af6ce35dc03cfb83d appid={c9670020-5288-47ea-70b3-5a13da258012} clientcertnegotiation=enable
你可能不需要这个,因为你没有申请证书:
**<serviceCredentials>
<clientCertificate>
<authentication certificateValidationMode="None" />
</clientCertificate>
</serviceCredentials>**
您唯一需要做的就是在 IIS 中托管服务时禁用 SSL 设置。
在我这边,我创建了一个控制台应用程序来托管服务,并使用以下命令将 sslcert 绑定到指定的端口。当客户端通过浏览器调用它时,它不会弹出对话框并提示我 select 客户端证书。
netsh http add sslcert ipport=0.0.0.0:8000
certhash=0000000000003ed9cd0c315bbb6dc1c08da5e6
appid={00112233-4455-6677-8899-AABBCCDDEEFF}
也许我们不需要打开支持客户端证书,或者禁用它。
clientcertnegotiation=disable
这是官方文档,希望对你有用。
https://docs.microsoft.com/en-us/windows/desktop/http/add-sslcert
https://docs.microsoft.com/en-us/dotnet/framework/wcf/feature-details/how-to-configure-a-port-with-an-ssl-certificate
如果有什么我可以帮忙的,请随时告诉我。
我创建了一个自托管的 WCF REST 服务器 (w/o IIS)。当我启用 SSL 支持时,在 Chrome.
中测试站点时,系统会不断要求我提供客户端认证下面是我的 app.config,我相信我禁用了客户端身份验证。我在这里遗漏了什么吗?
照片: Chrome asking for client certificate
App.config代码:
<system.serviceModel>
<services>
<service behaviorConfiguration="ADConnectorLibrary.Service1Behavior" name="ADConnectorLibrary.ADConnectorLibrary">
<endpoint address="" binding="webHttpBinding" bindingConfiguration="webHttpTransportSecurity" behaviorConfiguration="web" contract="ADConnectorLibrary.IADConnectorLibrary" >
</endpoint>
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="https://ADDRESS:8888/ADConnectorLibrary/"/>
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ADConnectorLibrary.Service1Behavior">
<serviceMetadata httpGetEnabled="false" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="False"/>
**<serviceCredentials>
<clientCertificate>
<authentication certificateValidationMode="None" />
</clientCertificate>
</serviceCredentials>**
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="web">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<webHttpBinding>
<binding name="webHttpTransportSecurity">
<security mode="Transport">
**<transport clientCredentialType="None" />**
</security>
</binding>
</webHttpBinding>
</bindings>
由于您使用的是 TransportSecurity,我认为您需要为您的服务分配证书,否则它将无法通过 HTTPS 上的 SSL 加密消息。
同样,客户端必须信任该证书,或者当客户端尝试在浏览器中通过 HTTPS 访问服务时将获得这些响应之一,并且来自代码的调用将失败。
您可能需要使用 netsh,因为您没有使用 IIS。您可能需要稍微研究一下 netsh 以满足您的需要。
像这样将证书注册到端口并映射到应用程序 guid:这是一个纯编造的示例:netsh http add sslcert ipport=127.0.0.1:8000 certhash=c20ed305ea705cc4e36b317af6ce35dc03cfb83d appid={c9670020-5288-47ea-70b3-5a13da258012} clientcertnegotiation=enable
你可能不需要这个,因为你没有申请证书:
**<serviceCredentials>
<clientCertificate>
<authentication certificateValidationMode="None" />
</clientCertificate>
</serviceCredentials>**
您唯一需要做的就是在 IIS 中托管服务时禁用 SSL 设置。
在我这边,我创建了一个控制台应用程序来托管服务,并使用以下命令将 sslcert 绑定到指定的端口。当客户端通过浏览器调用它时,它不会弹出对话框并提示我 select 客户端证书。
netsh http add sslcert ipport=0.0.0.0:8000 certhash=0000000000003ed9cd0c315bbb6dc1c08da5e6 appid={00112233-4455-6677-8899-AABBCCDDEEFF}
也许我们不需要打开支持客户端证书,或者禁用它。
clientcertnegotiation=disable
这是官方文档,希望对你有用。
https://docs.microsoft.com/en-us/windows/desktop/http/add-sslcert
https://docs.microsoft.com/en-us/dotnet/framework/wcf/feature-details/how-to-configure-a-port-with-an-ssl-certificate
如果有什么我可以帮忙的,请随时告诉我。