HTTPS 経由の NTLM 認証を使用し、メッセージに証明書セキュリティを使用する WCF サービスをセットアップしたい (通常、HTTPS はメッセージ暗号化の必要性を否定します)
メッセージ セキュリティで動作する証明書がありますが、TransportWithMessageCredential を使用しようとすると、クライアントが例外をスローします。
未処理の例外: System.ServiceModel.Security.MessageSecurityException: HTTP 要求は、クライアント認証スキーム 'Anonymous' で承認されていません。サーバーから受信した認証ヘッダーは「Negotiate,NTLM」でした
IIS は Windows 認証のみをサポートし、SSL を要求し、クライアント証明書を受け入れるように構成されており、マシンは同じ Active Directory ドメインにあります (実際、私は現在これをローカルで実行しています)。
私が間違っていることはありますか?
私のサービス web.config は次のようになります。
<services>
<service name="ServiceHost.MyTestService" behaviorConfiguration="CertificateServiceBehavior">
<endpoint address="" binding="ws2007HttpBinding" contract="SharedLibrary.ITestService" bindingConfiguration="CertificateBindingConfig">
</endpoint>
</service>
</services>
<bindings>
<ws2007HttpBinding>
<binding name="CertificateBindingConfig">
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="Windows" />
<message clientCredentialType="Certificate" negotiateServiceCredential="true" />
</security>
</binding>
</ws2007HttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="CertificateServiceBehavior">
<serviceCredentials>
<windowsAuthentication allowAnonymousLogons="false" />
<clientCertificate>
<authentication certificateValidationMode="PeerTrust" trustedStoreLocation="LocalMachine" />
</clientCertificate>
<serviceCertificate storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName" findValue="server" />
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
私のクライアント app.config は次のとおりです。
<client>
<endpoint address="https://server:9999/ServiceHost/TestService.svc" binding="ws2007HttpBinding"
contract="SharedLibrary.ITestService" bindingConfiguration="CertificateBindingConfig"
behaviorConfiguration="CertificateEndpointBehavior"
name="serviceEndpoint">
</endpoint>
</client>
<bindings>
<ws2007HttpBinding>
<binding name="CertificateBindingConfig">
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="Windows" />
<message clientCredentialType="Certificate" negotiateServiceCredential="true"/>
</security>
</binding>
</ws2007HttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="CertificateEndpointBehavior">
<clientCredentials>
<windows allowNtlm="true" allowedImpersonationLevel="Impersonation"/>
<clientCertificate storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName" findValue="client"/>
<serviceCertificate>
<authentication certificateValidationMode="PeerTrust"/>
</serviceCertificate>
</clientCredentials>
</behavior>
</endpointBehaviors>
</behaviors>