簡體   English   中英

具有SSL加密的WCF身份驗證服務

[英]WCF Authentication Service with SSL encryption

我已經創建了WCF身份驗證服務,並且一切正常。 當我嘗試對通信實施SSL加密時,出現以下錯誤:

沒有頻道正在https://myDomain/WebSite/MyAuthenticationSvcWrap.svc上積極監聽。 這通常是由不正確的地址URI引起的。 確保將消息發送到的地址與正在偵聽服務的地址匹配。

http服務主機的web.config:

<system.serviceModel>

<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />

<services>
  <service behaviorConfiguration="AppServiceBehaviors" name="WebSite.System.Web.ApplicationServices.AuthenticationService">
    <endpoint binding="basicHttpBinding" bindingConfiguration="Binding1" bindingNamespace="http://asp.net/ApplicationServices/v200" contract="WebSite.System.Web.ApplicationServices.AuthenticationService" />
  </service>
</services>

<bindings>
  <basicHttpBinding>
    <binding name="Binding1" >
      <security mode="None">
        <transport clientCredentialType="None" proxyCredentialType="None"
            realm="" />
      </security>
    </binding>
  </basicHttpBinding>
</bindings>   

<behaviors>
  <serviceBehaviors>
    <behavior name="AppServiceBehaviors">
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="true" />
    </behavior>
  </serviceBehaviors>
</behaviors>

和客戶端app.config:

<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="BasicHttpBinding_AuthenticationService">
                <security mode="None">
                  <transport clientCredentialType="None" proxyCredentialType="None"/>                        
                </security>
            </binding>
        </basicHttpBinding>
    </bindings>
    <client>
        <endpoint address="http://mydomain/WebSite/MyAuthenticationSvcWrap.svc"
            binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_AuthenticationService"
            contract="AuthenticationService" name="BasicHttpBinding_AuthenticationService" />
    </client>
</system.serviceModel>

https服務主機:

<system.serviceModel>

<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />

<services>
  <service behaviorConfiguration="AppServiceBehaviors" name="WebSite.System.Web.ApplicationServices.AuthenticationService">
    <endpoint binding="basicHttpBinding" bindingConfiguration="Binding1" bindingNamespace="http://asp.net/ApplicationServices/v200" contract="WebSite.System.Web.ApplicationServices.AuthenticationService" />
  </service>
</services>

<bindings>
  <basicHttpBinding>
    <binding name="Binding1" >
      <security mode="Transport">
        <transport clientCredentialType="None" proxyCredentialType="None"
            realm="" />
      </security>
    </binding>
  </basicHttpBinding>
</bindings>   

<behaviors>
  <serviceBehaviors>
    <behavior name="AppServiceBehaviors">
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="true" />
    </behavior>
  </serviceBehaviors>
</behaviors>

和客戶端的app.config:

<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="BasicHttpBinding_AuthenticationService">
                <security mode="Transport">
                  <transport clientCredentialType="None" proxyCredentialType="None"/>                        
                </security>
            </binding>
        </basicHttpBinding>
    </bindings>
    <client>
        <endpoint address="https://mydomain/WebSite/MyAuthenticationSvcWrap.svc"
            binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_AuthenticationService"
            contract="AuthenticationService" name="BasicHttpBinding_AuthenticationService" />
    </client>
</system.serviceModel>

實際上,我已經在兩個文件的basicHttpBinding中將元素的mode屬性更改為Transport,並且還將客戶端端點地址從http更改為https。 我在這里還必須注意,通過在瀏覽器中點擊https://mydomain/WebSite/MyAuthenticationSvcWrap.svc可以找到頁面並獲得響應。

有人可以建議為什么會發生這種現象嗎?

非常感謝

我終於設法解決了這個問題,盡管答案並不能使我感到更好。

解決方案是在IIS的SSL設置中勾選“需要SSL”。 這沒有任何意義,因為如果未選中“需要SSL”,則我的理解方式意味着仍可以以相同方式處理SSL請求。

此外,盡管這次更容易解決,但錯誤消息仍在繼續。 事實證明,如果將安全模式設置為“傳輸”,則必須從元素的name屬性中省略程序集名稱。 換句話說,它必須與.svc文件中聲明的服務名稱完全相同。 在我的情況下,System.Web.ApplicationServices.AuthenticationService,而WebSite.System.Web.ApplicationServices.AuthenticationService給出了錯誤。 合同屬性必須相應地更改。

令我驚訝的不是為什么發生這種情況,而是當mode屬性設置為“ Nothing”時為什么沒有發生這種情況。 盡管我的應用程序現在可以按我希望的方式運行,但是我仍然希望對以前的問題有所了解,以期獲得更好的理解。 如果有人能進一步幫助我,我將不勝感激。

非常感謝。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM