我使用basicHttpBinding,消息安全模式和证书客户端凭据类型的wcf服务。我可以通过wcf客户端使用此服务,但是此服务也必须在具有Java客户端的另一个系统中使用。我正在使用soapui进行测试,但是我获得了空响应或安全消息错误。我已经尝试了variuos soapui配置来加载客户端证书,但这些都没有奏效。我通过http(非https)公开了服务,这是服务器wcf配置:
<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 :(得分: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 ,将客户端证书发送到端点:
从菜单中选择文件&gt;首选项,然后是SSL设置。在此面板中,选择一个密钥库,其中包含对服务有效的客户端密钥和证书,并放置密钥库密码,可选择标记所需的客户端身份验证:
注意:根据您的配置:
<clientCertificate findValue="ClientSide"
x509FindType="FindBySubjectName" storeLocation="LocalMachine" storeName="My"/>
有效的客户端证书必须是位于服务器的Windows本地密钥库中的证书颁发机构颁发的最终实体证书。
答案 1 :(得分:0)
我很难通过客户端证书身份验证为WCF测试设置SOAPUI。最后,我得到了它的工作。 面临不同的问题,如:SNI支持问题,未签名的“收件人”标题Getting WCF to accept unsigned 'To' Header等。
我建议打开WCF跟踪,您可以在服务器上获取详细的错误信息:https://msdn.microsoft.com/en-us/library/ms732023(v=vs.110).aspx,以便轻松排除故障。