Secure channel cannot be opened because security negotiation with the remote endpoint has failed. This may be due to absent or incorrectly specified EndpointIdentity in the EndpointAddress used to create the channel. Please verify the EndpointIdentity specified or implied by the EndpointAddress correctly identifies the remote endpoint.
<wsHttpBinding>
<binding name="MyBindingConfigration">
<security mode="Message">
<transport clientCredentialType="None"/>
<message clientCredentialType="Certificate"/>
</security>
</binding>
</wsHttpBinding>
<serviceBehaviors>
<behavior name="WCFService.WCFServiceBehavior">
<serviceCredentials>
<serviceCertificate storeName="My" x509FindType="FindBySubjectName" findValue="WCFServerPK" storeLocation="LocalMachine"/>
</serviceCredentials>
</behavior>
</serviceBehaviors>
確認 findValue 與本機憑證主體名稱一致,且憑證擁有私鑰、位於 LocalMachine\My 存儲區。
Visual Studio 方案包含服務與客戶端兩個專案時:
錯誤提示「與遠端端點協商失敗」實際上是服務未聽聽,導致無法進行安全握手,而非憑證本身有問題。
遇到安全協商失敗,優先檢查服務是否已正確啟動並監聽端點,再驗證雙端綁定與憑證配置一致性。