以下是方案。我們通過所有由我們託管的Web界面提供軟件。但是,該服務確實需要與我們的客戶進行溝通,所以我們計劃在他們的網站上安裝一個WCF服務,以便與我們的服務進行對話。WCF中的安全性的最佳方法 - 以及證書錯誤
這項服務的一部分工作就是通過Active Directory對用戶進行身份驗證,這意味着通過網絡發送用戶名和密碼。這些需要保證。原來的計劃只是加密他們,但後來我到達該項目,並知道WCF服務可以證書安全。
但是,我們並不希望爲每個本地安裝購買並安裝正確簽名的證書。這意味着使用makecert.exe證書,這反過來意味着關閉大量的安全檢查。在這一點上,當涉及到安全性時,我處於專業知識的極限 - 在生產環境中嘗試使用未簽名證書是一個壞主意?如果是這樣,它以什麼方式不安全?
我碰到了一個障礙,在任何情況下獲得本地運行證書的服務,如果有人可以幫助它,將不勝感激。該服務運行良好,沒有證書,所以問題顯然不存在。當我嘗試和啓動服務,我得到:
System.InvalidOperationException: The service certificate is not provided. Specify a service certificate in ServiceCredentials.
所以這似乎意味着它不能找到證書。但它可以:因爲如果我更改查找條件,我會得到一條不同的消息,說明我所處的證書不在商店中。以下是配置的相關位:
<system.serviceModel>
<services>
<service name="Namespace.Endpoint"
behaviorConfiguration="default">
<host>
<baseAddresses>
<add baseAddress="http://localhost:8000/Endpoint"/>
</baseAddresses>
</host>
<endpoint address=""
binding="wsHttpBinding"
bindingConfiguration="secureWsHttpBinding"
contract="Namespace.IContract" />
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
<bindings>
<wsHttpBinding>
<binding name="secureWsHttpBinding">
<security mode="Message">
<message clientCredentialType="Certificate" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="default">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="False"/>
<serviceCredentials>
<clientCertificate>
<authentication
certificateValidationMode="ChainTrust"
revocationMode="NoCheck" />
<certificate storeName="My"
x509FindType="FindBySubjectName"
storeLocation="LocalMachine"
findValue="MyTestCert" />
</clientCertificate>
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
證書和私鑰都可由運行該服務的用戶訪問。那麼爲什麼它不能使用安裝的證書?