2013-02-13 411 views
7

這是一個常見問題,我已經查看了所有答案,但沒有任何幫助。HTTP請求被禁止,客戶端身份驗證方案'匿名'

我想讓SSL與iis上託管的basichttpbinding和WCF服務一起工作。我認爲問題出在iis或證書上。我在iis經理中創建了一個自簽名證書。我的證書被稱爲「mycomputer」,並已被置於受信任的根證書之下。客戶沒有問題找到證書。

我在iis中的設置是啓用匿名身份驗證,並禁用其他一切。還需要SSL並接受客戶端證書。那是對的嗎?如果我選擇忽略,則會出現錯誤。

我無法看到我的配置有什麼問題,這些是正確的嗎?

服務配置:

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

客戶端配置:

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

回答

6

我假設你的問題可能是在您的客戶端證書。設置clientCredentialType =「證書」您告訴WCF,該客戶端必須指定服務器信任的證書。據我所知,你只有服務器端生成的證書。嘗試設置

<transport clientCredentialType="None" /> 

這將允許您發送消息而不需要服務器信任的證書。或者您可以嘗試在客戶端生成證書並將其放入服務器上的Trusted文件夾中。 也許這個狀態會幫助你http://msdn.microsoft.com/en-us/library/ms731074.aspx

+1

謝謝,我認爲這可能是解決這個錯誤。但是,我收到「遠程服務器返回了意外的響應:(405)方法不允許。」在同一階段,所以即時通訊不知道如果它更好或更差 – Zeezer 2013-02-13 13:27:46

+0

看看你的合同界面是否有公共關鍵字。別忘了C:\ Windows \ Microsoft.NET \ Framework \ v4.0.30319> ServiceModelReg.exe -i – Alex 2013-02-13 13:31:49

+1

非常感謝!一直坐在這個問題的日子。現在它的工作和最後一個問題很容易解決。我的地址應該是https://mycomputer/wp/Service1.svc,而不是https:// mycomputer/wp /。 – Zeezer 2013-02-13 13:39:28

相關問題