我正在開發一個WCF服務,該服務必須使用用戶名憑據在HTTPS上運行,並且發現在IIS上運行的測試解決方案中可以使用以下配置:使用HTTPS配置WCF服務
服務器配置:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
<customErrors mode="Off" />
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="Behavior1">
<serviceMetadata httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="Service.UserNamePassValidator, Service" />
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<wsHttpBinding>
<binding name="Binding1">
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="None" />
<message clientCredentialType="UserName" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="Behavior1" name="Service.Service">
<host>
<baseAddresses>
<add baseAddress="https://localhost/" />
</baseAddresses>
</host>
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="Binding1" contract="Service.IService" />
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
</service>
</services>
</system.serviceModel>
</configuration>
客戶端配置:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IService">
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="None" />
<message clientCredentialType="UserName" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="https://localhost:44303/UsernamePasswordService.svc"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IService"
contract="ServiceReference1.IService" name="WSHttpBinding_IService" />
</client>
</system.serviceModel>
</configuration>
客戶端在我的方案是一個WinForms應用程序。
我是很新的構式這一點,只是想確認這是否是用於HTTPS(SSL)使用用戶名憑據的有效/設置好?
由於我使用的是自簽名證書,我必須繞過客戶端證書的驗證,因此我不覺得我可以清楚地看到這將有效證書工作。
我想象它的工作方式是,服務器開始通信時,然後在客戶端加密所有發送到與客戶端證書的服務器的流量經過客戶端證書給客戶端。該流量隨後通過服務器端的服務器證書進行解密。
但這是它的工作方式?現在它的配置方式是,僅在IIS偵聽端口上指定證書,那麼它是否會根據每個請求的服務器證書爲客戶端生成證書?或者來自客戶端的流量是否未加密?
我想對我的要求運行小提琴手並啓用了HTTPS進行解密,並注意到我可以閱讀在XML純文本用戶名和密碼。這是因爲小提琴手會通過我的證書加密來讀取一些魔法或者發送的消息根本沒有加密?
在這種情況下,我必須自己加密和解密數據嗎?
我不想在客戶端安裝證書。