2012-09-22 5 views
1

Je veux installer un service WCF qui utilise l'authentification NTLM via HTTPS et utilise la sécurité de certificat pour le message (je sais, généralement HTTPS nie la nécessité pour le chiffrement des messages)WCF avec NTLM sur HTTPS et certificats pour le message?

Je le travail des certificats sur la sécurité des messages, mais quand J'essaie d'utiliser TransportWithMessageCredential, le client lance une exception:

exception non gérée: System.ServiceModel.Security.MessageSecurityException: la requête HTTP est non autorisé avec le schéma d'authentification client 'Anonymous'. L'en-tête d'authentification reçue du serveur était « Negotiate, NTLM »

IIS est configuré pour supporter uniquement Windows Auth, SSL requis et accepter des certificats clients, les machines sont dans le même domaine Active Directory (en fait, je suis en cours d'exécution localement en ce moment)

Des idées que je fais mal?

Mon service web.config ressemble à ceci:

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

Mes clients app.config est ceci:

<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> 
+0

Je suppose que votre certificat client est enregistré dans les certificats de confiance du client? –

+0

@ M.Babcock Oui, c'est dans le magasin de personnes de confiance. Cela fonctionne si j'utilise la sécurité des messages par rapport à un point de terminaison HTTP non authentifié. –

+0

Utilisez-vous localhost dans votre adresse de point de terminaison? –

Répondre

1

modes prédéfinis ne vous permettra pas parvenir à une telle sécurité. TransportWithMessageCredentials moyens:

  • HTTPS
  • Pas de transport authentifications
  • jeton de sécurité dans le message pour l'authentification client
  • Pas de chiffrement des messages

Essayez cette (non testé) pour obtenir HTTPS avec NTLM + sécurité mutuelle des messages:

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

Vous pouvez également essayer le mode d'authentification MutualSslNegotiated pour avoir la négociation des informations d'identification de service et Negotiate dans authenticationScheme pour mieux correspondre à l'option Windows à partir de liaisons prédéfinies.