[英]WCF wsHttpBinding Client Certificate Authentication without using store in client
[英]WSHttpBinding binding, client authentication
我是 wcf 的新手並使用 wshttpbinding,但我想從服務客戶端(我必須通過)中刪除用戶名和密碼,我的客戶端代碼是
RServiceClient serviceClient = new RServiceClient();
serviceClient.ClientCredentials.Windows.ClientCredential.UserName = "UserName";
serviceClient.ClientCredentials.Windows.ClientCredential.Password = "Password";
我不想傳遞這個用戶名和密碼。
我的客戶端 app.config 是:
<binding name="WSHttpBinding_IRService"
closeTimeout="00:01:00"
openTimeout="00:01:00"
receiveTimeout="00:10:00"
sendTimeout="00:01:00"
bypassProxyOnLocal="false"
transactionFlow="false"
hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288"
maxReceivedMessageSize="65536"
messageEncoding="Text"
textEncoding="utf-8"
useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="32"
maxStringContentLength="8192"
maxArrayLength="16384"
maxBytesPerRead="4096"
maxNameTableCharCount="16384" />
<reliableSession ordered="true"
inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Message">
<transport clientCredentialType="Windows"
proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows"
negotiateServiceCredential="true"
algorithmSuite="Default" />
</security>
</binding>
rite now 服務托管在 web 中。 service.config 或客戶端 app.config 是否有任何更改。 谷歌搜索后我的薄弱知識是改變應該是客戶端,但我無法做到這一點。 :-(
注意:我的合同也需要會話。 提前謝謝。
您需要在服務器端更改 web.config,您的客戶端 web.config 將在 web 參考刷新后自動更新。 如果您不想使用登錄名/密碼,我可以建議您設置相互證書身份驗證。
這種方法安全且可與其他 WS 堆棧互操作(例如 Java CXF,...)
對於相互認證身份驗證:您將需要一個 X.509 證書以允許客戶端確保服務器確實是假裝的,並在客戶端需要另一個 X.509 證書。
這里是 web.config 的示例, MSDN上的更多信息:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="serviceCredentialBehavior">
<serviceCredentials>
<serviceCertificate findValue="Contoso.com"
storeLocation="LocalMachine"
storeName="My"
x509FindType="FindBySubjectName" />
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="serviceCredentialBehavior"
name="ServiceModel.Calculator">
<endpoint address="http://localhost/Calculator"
binding="wsHttpBinding"
bindingConfiguration="InteropCertificateBinding"
name="WSHttpBinding_ICalculator"
contract="ServiceModel.ICalculator" />
</service>
</services>
<bindings>
<wsHttpBinding>
<binding name="InteropCertificateBinding">
<security mode="Message">
<message clientCredentialType="Certificate"
negotiateServiceCredential="false"
establishSecurityContext="false" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client />
</system.serviceModel>
</configuration>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.