2013-02-13 11 views
7

Questo problema è un problema comune e ho visto tutte le risposte qui ma nessuna ha aiutato.La richiesta HTTP è stata vietata con lo schema di autenticazione del client 'Anonimo'

Sto cercando di ottenere SSL per lavorare con basichttpbinding e il servizio WCF ospitato su iis. Penso che il problema sia in iis o con i certificati. Ho creato un certificato autofirmato in iis manager. Il mio certificato si chiama "mycomputer" e sono anche stati inseriti in Certificazione radice di fiducia. Il cliente non ha problemi a trovare il certificato.

Le mie impostazioni in iis servono per abilitare l'autenticazione anonima e disabilitare tutto il resto. Richiede anche SSL e accetta il certificato client. È corretto? Ottengo un errore se scelgo di ignorare.

Non riesco a vedere niente di sbagliato con le mie configurazioni, sono corrette?

config Servizio:

<system.serviceModel> 
<services> 
    <service behaviorConfiguration="MyBehaviour" name="BasicHttpSecTest.Service1"> 
    <endpoint name="MyEndPoint" address="https://mycomputer/wp/" binding="basicHttpBinding" bindingConfiguration="ClientCertificateTransportSecurity" contract="BasicHttpSecTest.IService1" /> 
    <!--<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />--> 
    </service> 
</services> 
<behaviors> 
    <serviceBehaviors> 
    <behavior name="MyBehaviour"> 
     <serviceMetadata httpsGetEnabled="true" /> 
     <serviceDebug includeExceptionDetailInFaults="true" /> 
     <serviceCredentials> 
     <clientCertificate> 
      <authentication certificateValidationMode="PeerOrChainTrust" revocationMode="NoCheck"/> 
     </clientCertificate> 
     </serviceCredentials> 
    </behavior> 
    </serviceBehaviors> 
</behaviors> 
<bindings> 
    <basicHttpBinding> 
    <binding name="ClientCertificateTransportSecurity"> 
     <security mode="Transport"> 
     <transport clientCredentialType="Certificate" /> 
     </security> 
    </binding> 
    </basicHttpBinding> 
</bindings> 
</system.serviceModel> 

configurazione client:

<system.serviceModel> 
<client> 
    <endpoint address="https://mycomputer/wp/Service1.svc" binding="basicHttpBinding" 
     bindingConfiguration="MyEndPoint" contract="ServiceSSLref.IService1" 
     name="MyEndPoint1" behaviorConfiguration="ClientCertificateCredential"/> 
</client> 

<bindings> 
    <basicHttpBinding> 
     <binding name="MyEndPoint"> 
      <security mode="Transport"> 
       <transport clientCredentialType="Certificate" /> 
      </security> 
     </binding> 
    </basicHttpBinding> 
</bindings> 

<behaviors> 
    <endpointBehaviors> 
    <behavior name="ClientCertificateCredential"> 
     <clientCredentials> 
     <clientCertificate findValue="mycomputer" storeLocation="LocalMachine" storeName="My" x509FindType="FindByIssuerName" /> 
     <serviceCertificate> 
      <authentication certificateValidationMode="PeerOrChainTrust" revocationMode="NoCheck"/> 
     </serviceCertificate> 
     </clientCredentials> 
    </behavior> 
    </endpointBehaviors> 
</behaviors> 
</system.serviceModel> 

risposta

6

suppongo che il problema potrebbe essere nel vostro certificato client. Impostazione di clientCredentialType = "Certificato" indica a WCF che quel client deve specificare un certificato attendibile dal server. Come ho capito, hai solo certificato generato lato server. Prova a impostare

<transport clientCredentialType="None" /> 

Questo vi permetterà di inviare messaggi senza richiedere certificato attendibile dal server. Oppure puoi provare a generare un certificato sul lato client e metterlo nella cartella Trusted sul tuo server. Forse questo stato ti aiuterà http://msdn.microsoft.com/en-us/library/ms731074.aspx

+1

Grazie, penso che avrebbe potuto essere la soluzione a tale errore. Tuttavia, ottengo "Il server remoto ha restituito una risposta imprevista: (405) Metodo non consentito." allo stesso tempo, quindi non sono sicuro che sia meglio o peggio – Zeezer

+0

Controlla se hai una parola chiave pubblica nell'interfaccia del contratto. E non dimenticarti di C: \ Windows \ Microsoft.NET \ Framework \ v4.0.30319> ServiceModelReg.exe -i – Alex

+1

Grazie mille! Sono stato seduto nei giorni con questo problema. Ora il suo funzionamento e l'ultimo problema era una soluzione semplice. Il mio indirizzo dovrebbe essere https: //mycomputer/wp/Service1.svc, e non https: // mycomputer/wp /. – Zeezer