私は SOAP の初心者であり、メッセージの暗号化とパスワード認証を使用して 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>