2010-08-30 49 views
2

試圖獲得的HelloWorld通過SSL工作。閱讀所有這些文檔:WCF SSL配置錯誤也許

  1. X509FindType

  2. How to: Use wsHttpBinding with Windows Authentication and Transport Security in WCF Calling from Windows Forms

  3. How to: Configure a Port with an SSL Certificate

  4. How to: Create Temporary Certificates for Use During Development

  5. Windows Communication Foundation (WCF) Screencasts

我所知道的是,證書似乎是創建並正確部署(這兩個證書,實際上)。不過,我想我的web.config有問題(對不起,在這一點上不能更具體)。這就像沒有服務器監聽443或客戶期望的HTTP而不是HTTPS。有人可以請我指出適當的資源和/或告訴我做錯了什麼?

的Web.config是在這裏:

<?xml version="1.0" encoding="utf-8" ?> 

<configuration> 
    <appSettings> 
    <add key="HTTPBaseAddress" value=""/> 
    </appSettings> 
    <system.serviceModel> 
    <services> 
     <service behaviorConfiguration="MyServiceTypeBehaviors" name="MyWCFServices.HelloWorldService"> 
     <clear /> 
     <endpoint address="mex" binding="mexHttpBinding" name="mexEndpoint" contract="IMetadataExchange" listenUriMode="Explicit"> 
      <identity> 
      <dns value="localhost" /> 
      <certificateReference storeName="My" storeLocation="LocalMachine" x509FindType="FindBySubjectDistinguishedName" /> 
      </identity> 
     </endpoint> 
     <endpoint address="" binding="wsHttpBinding" bindingConfiguration="" name="SSLendpoint" contract="MyWCFServices.IHelloWorldService"> 
      <identity> 
      <dns value="localhost" /> 
      <certificateReference x509FindType="FindByThumbprint" findValue="‎82a39faaeb18bf9585b334ca83264add3d5b26ee" /> 
      </identity> 
     </endpoint> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="MyServiceTypeBehaviors" > 
      <serviceMetadata httpGetEnabled="true" /> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    </system.serviceModel> 
</configuration> 

客戶端的app.config是在這裏:

<?xml version="1.0" encoding="utf-8"?> 
<configuration> 
    <system.serviceModel> 
     <bindings> 
      <wsHttpBinding> 
       <binding name="NoSecurity"> 
        <security mode="None" /> 
       </binding> 
       <binding name="SSLsecurity"> 
        <security mode="Transport"> 
         <transport clientCredentialType="None" /> 
         <message clientCredentialType="Certificate"/
        </security> 
       </binding> 
      </wsHttpBinding> 
     </bindings> 
     <client> 
      <endpoint address="https://localhost:443/HelloWorldSSL/HelloWorldService.svc" 
       binding="wsHttpBinding" bindingConfiguration="" contract="IHelloWorldService" 
       name="wsHttpBinding_IHelloWorldService" /> 
     </client> 
    </system.serviceModel> 
</configuration> 

如果需要任何額外的信息/截圖 - 我會樂意爲它(照常)。希望這是一個回答的問題:)

回答

3

你的配置不正確。您沒有在端點中定義自定義綁定配置,因此不使用HTTPS。使用這一個服務器:

<bindings> 
    <wsHttpBinding> 
    <binding name="SSLSecurity"> 
     <security mode="Transport"> 
     <transport clientCredentialType="None" /> 
     </security> 
    </binding> 
    </wsHttpBinding> 
</bindings> 
<behaviors> 
    <serviceBehaviors> 
    <behavior name="MyServiceTypeBehaviors" > 
     <serviceMetadata httpGetEnabled="true" /> 
    </behavior> 
    </serviceBehaviors> 
</behaviors> 
<services> 
    <service behaviorConfiguration="MyServiceTypeBehaviors" 
    name="MyWCFServices.HelloWorldService"> 
    <endpoint address="mex" binding="mexHttpBinding" name="mexEndpoint" 
     contract="IMetadataExchange" listenUriMode="Explicit" /> 
    <endpoint address="" binding="wsHttpBinding" bindingConfiguration="SSLSecurity" 
     name="SSLendpoint" contract="MyWCFServices.IHelloWorldService" /> 
    </service> 
</services> 

對於客戶端使用:

<bindings> 
    <wsHttpBinding>  
    <binding name="SSLSecurity"> 
     <security mode="Transport"> 
     <transport clientCredentialType="None" /> 
     </security> 
    </binding> 
    </wsHttpBinding> 
</bindings> 
<client> 
    <endpoint address="https://localhost:443/HelloWorldSSL/HelloWorldService.svc"  
    binding="wsHttpBinding" bindingConfiguration="SSLSecurity" 
    contract="IHelloWorldService" name="wsHttpBinding_IHelloWorldService" /> 
</client> 
+0

謝謝你 - 這解決了一些probs(有一些自定義)。但是,現在收到另一個錯誤:根據驗證過程,遠程證書無效。但在此,在接下來我的stackoverflow問題:) – BreakPhreak 2010-08-31 12:43:30