我是一名使用soap的newbe,并且已经获得了一项任务,即创建一个带有消息加密和密码认证的soap客户端,以便与用java编写的服务进行交互。 问题是加密是一种方式(客户端到服务器)。响应未加密,基本上是通过/失败。证书将没有私钥。
在下面列出的代码中,如果我包含定义,我会收到失败'私钥在X.509证书中不存在。'
如果我删除它,我会收到失败'没有为目标提供服务证书'http:// localhost:65182 / services / ConnectTest'。在ClientCredentials中指定服务证书。'
如何告诉它我不会拥有服务凭据而且不需要解密响应?
private void SendEncrypted_Click(object sender, EventArgs e)
{
try
{
ConnectTest.ConnectWebServiceClient client = new ConnectTest.ConnectWebServiceClient();
PasswordDigestBehavior behavior = new PasswordDigestBehavior("joe", "password");
client.Endpoint.Behaviors.Add(behavior);
XmlDocument data = GetXmlData();
XmlNode payload = data.SelectSingleNode("xml");
string result;
result = client.postTransactionXML(payload.InnerXml);
textBox1.Text = result;
}
catch (Exception ex)
{
textBox1.Text = ex.Message;
if (ex.InnerException != null)
textBox1.Text += "\n" + ex.InnerException;
}
}
<configuration>
<system.serviceModel>
<client>
<endpoint address="http://localhost:65182/services/ConnectTest"
behaviorConfiguration="ClientCertificateBehavior" binding="basicHttpBinding"
bindingConfiguration="SOAPServiceSoapBinding" contract="ConnectTest.ConnectWebService"
name="ConnectWebPort">
<identity>
<dns value="Unknown" />
</identity>
</endpoint>
</client>
<bindings>
<basicHttpBinding>
<binding name="SOAPServiceSoapBinding" closeTimeout="00:00:10"
openTimeout="00:00:20" receiveTimeout="00:00:30" sendTimeout="00:00:40"
bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxReceivedMessageSize="1000" messageEncoding="Text" textEncoding="utf-8"
useDefaultWebProxy="false">
<security mode="Message">
<transport clientCredentialType="Digest" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Certificate" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="ClientCertificateBehavior">
<clientCredentials>
<clientCertificate findValue="foo.com" storeLocation="CurrentUser" storeName="My" x509FindType="FindBySubjectName" />
<serviceCertificate>
<defaultCertificate findValue="foo.com" storeLocation="CurrentUser" storeName="My" x509FindType="FindBySubjectName"/>
<authentication certificateValidationMode="None" />
</serviceCertificate>
</clientCredentials>
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
</configuration>