[英]Is TransportWithMessageCredential without certificate secure enough for a WCF service?
我開發了一個WCF自托管服務,我有兩個基本的安全要求,因為它將通過Internet訪問:
傳輸層應防止篡改和嗅探,尤其是檢索身份驗證憑據。 這就是SSL所做的,但從我所看到的設置SSL需要安裝證書(除非可能通過這種使用普通證書文件的hack ),我不想這樣做。
身份驗證層應包含用戶名/密碼驗證程序。
我配置我的服務使用:
<security mode="TransportWithMessageCredential">
<message clientCredentialType="UserName" />
<transport clientCredentialType="Basic" />
</security>
即使傳輸層是HTTP(而不是HTTPS),這是否會使WCF創建另一個與SSL等效的安全層? 如果沒有,安全強度方面有什么不同?
另外,有沒有辦法在不使用SSL證書的情況下保護元數據端點(不是必需的但是會受到贊賞)?
這是我自托管服務的完整配置代碼:
<?xml version="1.0"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup>
<system.serviceModel>
<services>
<service name="MyService">
<host>
<baseAddresses>
<add baseAddress = "http://localhost:8000/Services" />
</baseAddresses>
</host>
<endpoint address ="MyService" binding="wsHttpBinding" contract="IMyService">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<bindings>
<wsHttpBinding>
<binding name="Binding1" maxReceivedMessageSize="2147483647">
<security mode="TransportWithMessageCredential">
<message clientCredentialType="UserName" />
<transport clientCredentialType="Basic" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="True"/>
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="CR.Common.Services.CustomValidator, Common" />
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
謝謝!
默認情況下,所有安全的 WCF綁定(如wsHttpBinding)都將對消息進行加密和簽名。
SSL必須使用證書,你提供的鏈接中的黑客攻擊是黑客攻擊wcf,而不是SSL。 因為沒有SSL WCF禁止使用basicHttpBinding(以明文形式發送xml)和UserNamePasswordValidator,因為在這種情況下攔截消息的任何人都可以獲得用戶名/密碼。
使用WSHttpBinding,您可以避免使用SSL並將安全性置於消息級別。
我強烈建議您閱讀本文 ,尤其是服務憑據和協商章節:
為了支持相互身份驗證和郵件保護,服務必須向調用者提供憑據。 使用傳輸安全性(SSL)時,將通過傳輸協議協商服務憑據。 使用Windows憑據時,還可以協商消息安全性的服務憑據; 否則必須指定服務證書
使用UserNamePasswordValidator
,您必須在服務器上配置證書以允許客戶端簽名並加密每條消息(使用證書的公鑰)。 如果您使用的是Windows身份驗證,則不需要它。
你為什么這么擔心證書?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.