2016-09-22 136 views
0

我有一個帶有basicHttpBinding,消息安全模式和證書客戶端憑證類型的wcf服務。我可以通過wcf客戶端來使用這個服務,但是這個服務也必須在另一個帶有java客戶端的系統中使用。我正在使用soapui進行測試,但是我獲得了空的響應或安全消息錯誤。我已經嘗試variuos soapui配置來加載客戶端證書,但沒有一個工作。我通過http(非https)公開了服務,這是服務器wcf配置:與客戶端證書身份驗證的WCF與soapui不起作用

<system.serviceModel> 
    <bindings> 
     <basicHttpBinding> 
     <binding name="basicEndPoint" closeTimeout="00:01:00" openTimeout="00:01:00" 
       receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" 
       bypassProxyOnLocal="false" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" 
       maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" 
       transferMode="Buffered" useDefaultWebProxy="true"> 
      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" 
         maxArrayLength="2147483647" maxBytesPerRead="2147483647" 
         maxNameTableCharCount="2147483647"/> 
      <security mode="Message"> 
      <message clientCredentialType="Certificate" /> 
      </security> 
     </binding> 
     </basicHttpBinding> 
    </bindings> 
    <behaviors> 
     <endpointBehaviors> 
     <behavior name="customBehavior"> 
      <clientCredentials> 
      <clientCertificate findValue="ClientSide" x509FindType="FindBySubjectName" storeLocation="LocalMachine" storeName="My"/> 
      <serviceCertificate> 
       <defaultCertificate findValue="ServerSide" x509FindType="FindBySubjectName" storeLocation="LocalMachine" storeName="My"/> 
       <authentication certificateValidationMode="PeerOrChainTrust"/> 
      </serviceCertificate> 
      </clientCredentials> 
     </behavior> 
     </endpointBehaviors> 
    </behaviors> 
    <client> 
     <endpoint address="http://localhost:8080/WebServices/ExternalServices.svc" 
     behaviorConfiguration="customBehavior" binding="basicHttpBinding" 
     bindingConfiguration="basicEndPoint" contract="ServiceReference1.IExternalServices" 
     name="BasicHttpBinding_IExternalServices" > 
     <identity> 
      <certificateReference findValue="ServerSide" storeName="My" storeLocation="LocalMachine" x509FindType="FindBySubjectName" /> 
      <dns value="ServerSide"/> 
     </identity> 
     </endpoint> 
     <endpoint address="mex" 
       binding="mexHttpBinding" 
       contract="IMetadataExchange"/> 
    </client> 
    </system.serviceModel> 

這個設置有什麼問題? 在此先感謝

回答

0

我不是WCF專家(甚至沒有用戶:P),但基於配置:

<endpointBehaviors> 
    <behavior name="customBehavior"> 
     <clientCredentials> 
     <clientCertificate findValue="ClientSide" x509FindType="FindBySubjectName" storeLocation="LocalMachine" storeName="My"/> 
     <serviceCertificate> 
      <defaultCertificate findValue="ServerSide" x509FindType="FindBySubjectName" storeLocation="LocalMachine" storeName="My"/> 
      <authentication certificateValidationMode="PeerOrChainTrust"/> 
     </serviceCertificate> 
     </clientCredentials> 
    </behavior> 
</endpointBehaviors> 

似乎是爲了打你的服務器端點必須出示證明客戶端憑據。

所以要從SOAPUI調用您的服務,您可以做兩件事情,首先使用https公開您的服務,以便客戶端可以提供證書憑證。其次配置SOAPUI爲遵循客戶端證書發送到端點:

從菜單中選擇文件>首選項,然後SSL設置。在此面板中選擇包含有效的服務客戶端密鑰和證書密鑰庫,並把存儲密碼,可選擇標示所需的客戶端身份驗證

enter image description here

注:根據您的配置:

<clientCertificate findValue="ClientSide" 
      x509FindType="FindBySubjectName" storeLocation="LocalMachine" storeName="My"/> 

有效客戶證書必須是在位於服務器的Windows本地密鑰庫中的證書頒發機構頒發的最終實體證書。

+0

感謝您的回覆。我已經嘗試過這些配置;在使用basichttpbinding之前,我已經使用https設置了wshttpbinding,並且選擇了密鑰存儲和密碼,但沒有成功。谷歌搜索,我讀到wshttpbinding不是很好的互操作性,所以我改變它basichttpbinding和嘗試沒有https。我很想知道是否有某些地方存在一些關於如何使用soap wcf身份驗證證書開發服務的官方指南,這些證書不僅與wcf客戶端兼容。 – VariableName

+0

@VariableName我有一些關於PKI,SSL等的知識。但正如我在答案中所說的,我沒有* WCF *的混合體驗......我想這個主題肯定有gudelines,但我不'不知道在哪裏可以找到它,對不起。 – albciff

0

我很難設置SOAPUI進行WCF客戶端證書認證測試。最後我得到了它的工作。 面對不同的問題,如:SNI支持問題,無符號'To'標題Getting WCF to accept unsigned 'To' Header和其他。

我建議打開WCF跟蹤,您可以在服務器上獲得詳細的錯誤信息:https://msdn.microsoft.com/en-us/library/ms732023(v=vs.110).aspx因此可以輕鬆排除故障。

+0

歡迎來到StackOverflow!將鏈接中的相關材料複製到答案可能是一個好主意,因此如果鏈接發生變化,您的答案仍然有幫助 – DeadChex

相關問題