WCF を使用して動作するユーザー名トークン プロファイルがあり、クライアント呼び出しで暗号化のサポートを追加しようとしています。Web サービスは暗号化された SOAP ヘッダーを期待しています。MMC を使用してローカル ストアに証明書をインストールしました。以下の私の c# コードには、証明書をロードしてプロキシに割り当てるコードがあります。custombindings に必要な他の設定や、C# コードに何が欠けているのかわかりません。助言がありますか?
app.config:
<customBinding>
<binding name="cbinding">
<security authenticationMode="UserNameOverTransport" includeTimestamp="false">
<secureConversationBootstrap />
</security>
<textMessageEncoding messageVersion="Soap11" />
<httpsTransport />
</binding>
<endpoint address="https://localhost:8443/p6ws/services/ProjectService?wsdl"
binding="customBinding" bindingConfiguration="cbinding" contract="P6.WCF.Project.ProjectPortType"
name="ProjectServiceEndPointCfg">
</endpoint>
私のC#コード:
ProjectPortTypeClient proxy = new ProjectPortTypeClient("ProjectServiceCertificateEndPointCfgUT", endpointAddress);
proxy.ClientCredentials.UserName.UserName = UserName;
proxy.ClientCredentials.UserName.Password= Password;
proxy.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.PeerOrChainTrust;
proxy.ClientCredentials.ServiceCertificate.Authentication.TrustedStoreLocation = System.Security.Cryptography.X509Certificates.StoreLocation.LocalMachine;
// Set the certificate
proxy.ClientCredentials.ClientCertificate.SetCertificate(StoreLocation.CurrentUser, StoreName.My, X509FindType.FindByThumbprint, "13 d3 6e f1 26 5e 5f 74 be f2 bb f5 57 a4 47 cf e7 1a c6 0a");
proxy.ClientCredentials.ServiceCertificate.SetDefaultCertificate(StoreLocation.CurrentUser, StoreName.My, X509FindType.FindByThumbprint, "13 d3 6e f1 26 5e 5f 74 be f2 bb f5 57 a4 47 cf e7 1a c6 0a");
ReadProjects readProjects = new ReadProjects();