【发布时间】:2015-07-23 12:16:58
【问题描述】:
我确定我遗漏了一些关键事实,但我可以为您找到这些。我真的很困惑这一切需要如何运作:
- 服务器 1 – IIS 8,托管供应商的 WebAPI、匿名和 Windows 身份验证。提供者是 Negotiate、NTLM。 HTTPS 和签名证书 (Cert1)。
- 服务器 2 – IIS8,连接到服务器 1 的 WebAPI 的新 WebAPI。我假设我需要将 Cert1 存储在服务器 2 上。我们将有另一个证书 https (Cert2)
- 服务器 3 – IIS 8,网站连接到服务器 2 的 webAPI。
- 用户 - 连接到服务器 3 的浏览器,仅 Windows 身份验证。 每台服务器和用户的浏览器都连接到同一个 Active Directory。
我可以访问 Server1 的 web.config 来更改绑定,但不能更改代码。在 Visual Studio 2013 中,当我为 Server 2 添加服务引用时,web.config 是这样添加的:
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_ICoreWebService">
<security mode="Transport">
<transport clientCredentialType="Windows" proxyCredentialType="None" realm="" />
<message clientCredentialType="Certificate" negotiateServiceCredential="true" algorithmSuite="Default" establishSecurityContext="true" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="https://dave.domain.com/webService/CoreWebService.svc" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_ICoreWebService" contract="Dave.ICoreWebService" name="WSHttpBinding_ICoreWebService">
<identity>
<userPrincipalName value="Server1ServiceAccount@dave.domain.com" />
</identity>
</endpoint>
</client>
这是 Server1 的 WebAPI web.config
<system.serviceModel>
<bindings>
<wsHttpBinding>
<!-- The following block is used for secure connection (HTTPS)-->
<binding name="DaveServiceBinding" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647" receiveTimeout="00:05:00" sendTimeout="00:05:00">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="None" />
<message clientCredentialType="UserName" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service name="Dave.WebService.CoreWebService" behaviorConfiguration="DaveWebServiceBehavior">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="DaveWebServiceBinding" contract="Dave.WebService.ICoreWebService" />
<endpoint address="wauth" binding="wsHttpBinding" bindingConfiguration="DaveWebServiceBindingWauth" contract="Dave.WebService.ICoreWebService" />
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="DaveWebServiceBehavior">
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="Dave.WebService.WebServiceAuthValidator,Dave.WebService" />
</serviceCredentials>
<serviceMetadata httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
-
我在服务器 1 和服务器 2 之间的证书如何工作时遇到问题。我只需要下载 Cert1 并将其存储在 Server2 上?然后在我拨打电话时参考该证书。此代码未找到证书:
svc.ClientCredentials.ServiceCertificate.SetDefaultCertificate(StoreLocation.LocalMachine, StoreName.TrustedPublisher, X509FindType.FindBySubjectName, "CN = dave.domain.com, OU = ZZ123, O = Dave, Inc., L = Chicago, S = Illinois, C = US"); 如何将 Windows 身份验证从用户冒泡到 server1?供应商的 API 将通过该消息进行身份验证。
现在,我可以在本地浏览到服务,但我一直卡在服务器 2 上并获取证书。我想确保我正确地存储和引用它。
提前致谢。
【问题讨论】:
标签: c# asp.net-mvc rest iis asp.net-web-api