2012-11-14 67 views
4

我很努力地使用WCF和注册到IIS的自签名证书将silverlight应用程序从HTTP转换为HTTPS。WCF HTTPS SSL自托管证书。如何正确工作?

呼叫我已经在Visual Studio 2010中的命令提示符制成:

makecert -sv SignRoot.pvk -cy authority -r signroot.cer -a 
    sha1 -n "CN=Dev Certification Authority" -ss my -sr localmachine  

makecert -iv SignRoot.pvk -ic signroot.cer -cy end -pe -n 
    CN="localhost" -eku 1.3.6.1.5.5.7.3.1 -ss my -sr 
    localmachine -sky exchange -sp 
    "Microsoft RSA SChannel Cryptographic Provider" -sy 12 

我有这个作为结束点(这是仍然不小提琴手HTTP调用)

<!-- Address that the Silverlight clients will connect to --> 
<!-- as specified in their web.config --> 
<add key="gatewayListeningHttpURI" value="http://localhost:10201/" /> 

当前服务器配置:

<!-- set up binding for duplex service --> 
<bindings> 
    <customBinding> 
    <binding name="customDuplexBinding"> 
     <pollingDuplex duplexMode="MultipleMessagesPerPoll" 
      maxOutputDelay="00:00:01" 
    serverPollTimeout="00:01:00" 
    inactivityTimeout="02:00:00" 
    maxPendingMessagesPerSession="2147483647" 
    maxPendingSessions="2147483647" /> 
     <binaryMessageEncoding> 
     <readerQuotas 
      maxDepth="2147483647" 
      maxStringContentLength="2147483647" 
      maxArrayLength="2147483647" 
      maxBytesPerRead="2147483647" 
      maxNameTableCharCount="2147483647" /> 
     </binaryMessageEncoding> 
     <httpTransport 
    maxBufferSize="2147483647" 
    maxReceivedMessageSize="2147483647" 
    transferMode="StreamedResponse" 
      /> 
    </binding> 
    </customBinding> 

</bindings> 

<behaviors> 
    <endpointBehaviors> 
    <!-- For Policy Service --> 
    <behavior name="webHttpEndpointBehavior"> 
     <webHttp /> 
    </behavior> 
    </endpointBehaviors> 

    <serviceBehaviors> 
    <behavior name="sb"> 
     <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment --> 
     <serviceMetadata httpGetEnabled="true"/> 
     <!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information --> 
     <serviceDebug includeExceptionDetailInFaults="true"/> 
     <!-- This will solve a bug that happens if too many items are sent at once from the gateway to the client --> 
     <dataContractSerializer maxItemsInObjectGraph="2147483647"/> 
     <serviceThrottling 
     maxConcurrentCalls="200" 
     maxConcurrentSessions="200" 
     maxConcurrentInstances="200" /> 
    </behavior> 
    </serviceBehaviors> 
</behaviors> 

<services> 
    <service name="ME.Streets.WebGateway.DuplexService.DuplexService" 
    behaviorConfiguration="sb"> 
    <endpoint 
     address="basic" 
     binding="customBinding" 
     bindingConfiguration="customDuplexBinding" 
     contract="ME.Streets.WebGateway.DuplexService.Interface.IDuplexServiceContract"> 
    </endpoint> 
    <endpoint 
     address="" 
     binding="webHttpBinding" 
     behaviorConfiguration="webHttpEndpointBehavior" 
     contract="ME.Streets.WebGateway.DuplexService.Interface.IPolicyRetriever"/> 
    <endpoint 
     address="mex" 
     binding="mexHttpBinding" 
     contract="IMetadataExchange"/> 
    </service> 
</services> 

当前的客户端配置:

private DuplexServiceContractClient CreateDuplexServiceClient(EndpointAddress endPoint) 
    { 
     PollingDuplexBindingElement pollingDuplexBindingElement = new PollingDuplexBindingElement(); 
     pollingDuplexBindingElement.DuplexMode = PollingDuplexMode.MultipleMessagesPerPoll; 

     #if DEBUG 
     pollingDuplexBindingElement.ClientPollTimeout = TimeSpan.FromMinutes(15); 
     pollingDuplexBindingElement.InactivityTimeout = TimeSpan.FromMinutes(14); 
     #else 
     pollingDuplexBindingElement.ClientPollTimeout = TimeSpan.FromMinutes(60); 
     pollingDuplexBindingElement.InactivityTimeout = TimeSpan.FromMinutes(60); 
     #endif 

     HttpsTransportBindingElement httpsTransportBindingElement = new HttpsTransportBindingElement(); 
     httpsTransportBindingElement.MaxBufferSize = int.MaxValue; 
     httpsTransportBindingElement.MaxReceivedMessageSize = int.MaxValue; 
     httpsTransportBindingElement.TransferMode = TransferMode.StreamedResponse; 

     CustomBinding binding = new CustomBinding(
      pollingDuplexBindingElement, 
      new BinaryMessageEncodingBindingElement(), 
     httpsTransportBindingElement); 

     var dscc = new DuplexServiceContractClient(binding, endPoint); 

     dscc.InnerChannel.OperationTimeout = TimeSpan.FromMinutes(5); 

#if DEBUG 
     dscc.InnerChannel.OperationTimeout = TimeSpan.FromMinutes(15); 
#endif 
     return dscc; 
    } 

我已经部署了我的Silverlight applicatoin到IIS并添加HTTPS协议,以便我可以通过在前面添加HTTPS达到它网址。

问题仍然是,当我登录到HTTPS站点(https://开头本地主机/ FleetNew),我还收到“显示混合内容”的错误

,当我在看菲德勒,它是呼叫本地主机:10201这是不安全的http调用。

我的netsh HTTP显示的sslcert命令给我带来了这一点:

IP:port     : 0.0.0.0:10201 
Certificate Hash  : 0fb891e03c857d1c50b63163e5a0b999ed757ea1 
Application ID   : {3d5900ae-111a-45be-96b3-d9e4606ca793} 
Certificate Store Name : (null) 
Verify Client Certificate Revocation : Enabled 
Verify Revocation Using Cached Client Certificate Only : Disabled 
Usage Check : Enabled 
Revocation Freshness Time : 0 
URL Retrieval Timeout : 0 
Ctl Identifier   : (null) 
Ctl Store Name   : (null) 
DS Mapper Usage : Disabled 
Negotiate Client Certificate : Disabled 

IP:port     : 0.0.0.0:443 
Certificate Hash  : 0fb891e03c857d1c50b63163e5a0b999ed757ea1 
Application ID   : {4dc3e181-e14b-4a21-b022-59fc669b0914} 
Certificate Store Name : MY 
Verify Client Certificate Revocation : Enabled 
Verify Revocation Using Cached Client Certificate Only : Disabled 
Usage Check : Enabled 
Revocation Freshness Time : 0 
URL Retrieval Timeout : 0 
Ctl Identifier   : (null) 
Ctl Store Name   : (null) 
DS Mapper Usage : Disabled 
Negotiate Client Certificate : Disabled 

请帮我正确地配置,从而使调用的locahost:20102将努力通过SSL和HTTPS

回答

2

那么从我所告诉您缺少使用SSL托管WCF自托管服务所需的几个HTTPS元数据端点和行为配置。这样做的主要步骤,你需要的是以下内容:

  1. 创建一个自签名证书(用于测试目的)与您的端点URL的域名的匹配通用名称值(最好使用你的机器名)
  2. 使用netsh.exe使用它的指纹将端口与SSL证书绑定。
  3. 配置您的WCF .config文件以具有所需的SSL设置。

这是一个相当漫长的过程,所以不要尝试和记录每一步,我有一篇博客文章详细介绍了使用SSL获取WCF自托管服务所需的内容。这会帮助你看到一个可行的解决方案,你可以申请到您的项目:

Applying and Using a SSL Certificate With A Self-Hosted WCF Service

+0

我已经绑定到端口(见我的问题的最后一部分)的SSL证书,我有我的证书称为“本地主机”。我只是很坚持如何正确配置服务器和客户端的WCF配置文件正常工作 –

+0

我知道它看起来像我张贴的大文章和尝试它,但你真的应该通读它和试一试。让SSL为自己托管的服务工作需要一段时间,还需要一系列的研究,以便您可以阅读整个流程。至少,看看博客文章中的配置设置与您的相比。这主要是您需要担心的服务器端。一旦你有一个可用的SSL服务,客户端在添加服务引用后不需要修改。 – atconway

+0

我实际上在来这里之前使用了您的博客文章。我再次看到它,但我认为我需要一些手上的帮助 –

相关问题