1

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>
4

1 に答える 1

1

定義済みのモードでは、このようなセキュリティを実現できません。TransportWithMessageCredentials意味:

  • HTTPS
  • トランスポート認証なし
  • クライアント認証用のメッセージ内のセキュリティ トークン
  • メッセージの暗号化なし

NTLM + 相互メッセージ セキュリティで HTTPS を取得するには、これを試してください (テストされていません)。

<bindings>
  <customBinding>
    <binding name="MegaSecurity">
      <security authenticationMode="MutualCertificate"
                messageSecurityVersion="WSSecurity11WSTrust13WSSecureConversation13WSSecurityPolicy12BasicSecurityProfile10"
                includeTimestamp="true" />
      <textMessageEncoding messageVersion="Soap12WSAddressing10" />
      <httpsTransport authenticationScheme="Ntlm" />
    </binding>
  </customBinding>
</bindings>

MutualSslNegotiated認証モードを試して、サービス資格情報のネゴシエーションを行いNegotiate、事前定義されたバインディングのオプションauthenticationSchemeをより適切に一致させることもできます。Windows

于 2012-09-25T09:29:03.680 に答える