c# – WCF HTTPS SSL自托管证书.如何正确工作?

c# – WCF HTTPS SSL自托管证书.如何正确工作?,第1张

概述我正在努力使用WCF和在IIS中注册的自签名证书将Silverlight应用程序从HTTP转换为HTTPS. 我在Visual Studio 2010命令提示符中进行的调用: makecert -sv SignRoot.pvk -cy authority -r signroot.cer -a sha1 -n "CN=Dev Certification Authority" -ss my - 我正在努力使用WCF和在IIS中注册的自签名证书将Silverlight应用程序从http转换为httpS.

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

我将此作为终点(这是fiddler中仍然不是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应用程序部署到IIS中并添加了httpS协议,以便我可以通过在Web地址前添加httpS来实现它.

当我登录https网站(https:// localhost / FleetNew)时问题仍然存在,我仍然收到“显示MIxed内容”的错误

当我在fIDler中观看时,调用localhost:10201这是不安全的http调用.

我的netsh http show sslcert命令给我带来了这个:

IP:port                 : 0.0.0.0:10201Certificate Hash        : 0fb891e03c857d1c50b63163e5a0b999ed757ea1Application ID          : {3d5900ae-111a-45be-96b3-d9e4606ca793}Certificate Store name  : (null)Verify ClIEnt Certificate Revocation    : EnabledVerify Revocation Using Cached ClIEnt Certificate Only    : DisabledUsage Check    : EnabledRevocation Freshness Time : 0URL RetrIEval Timeout   : 0Ctl IDentifIEr          : (null)Ctl Store name          : (null)DS Mapper Usage    : DisabledNegotiate ClIEnt Certificate    : DisabledIP:port                 : 0.0.0.0:443Certificate Hash        : 0fb891e03c857d1c50b63163e5a0b999ed757ea1Application ID          : {4dc3e181-e14b-4a21-b022-59fc669b0914}Certificate Store name  : MYVerify ClIEnt Certificate Revocation    : EnabledVerify Revocation Using Cached ClIEnt Certificate Only    : DisabledUsage Check    : EnabledRevocation Freshness Time : 0URL RetrIEval Timeout   : 0Ctl IDentifIEr          : (null)Ctl Store name          : (null)DS Mapper Usage    : DisabledNegotiate ClIEnt Certificate    : Disabled

请帮我正确配置,以便对locahost:20102的调用将适用于ssl和httpS

解决方法 我可以告诉您,缺少使用SSL托管WCF自托管服务所需的几个httpS元数据端点和行为配置.做你需要的主要步骤如下:

>创建自签名证书(用于测试目的),其中包含端点URL域名的匹配公用名值(最好使用您的计算机名称)
>使用netsh.exe使用指纹将端口与SSL证书绑定.
>配置WCF .config文件以获得所需的SSL设置.

这是一个相当漫长的过程,所以我没有尝试记录这里的每一步,而是有一篇博文,详细介绍了使用SSL获取WCF自托管服务所需的内容.这应该可以帮助您查看可以应用于项目的有效解决方案:

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

总结

以上是内存溢出为你收集整理的c# – WCF HTTPS SSL自托管证书.如何正确工作?全部内容,希望文章能够帮你解决c# – WCF HTTPS SSL自托管证书.如何正确工作?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/langs/1252514.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-06-07
下一篇2022-06-07

发表评论

登录后才能评论

评论列表(0条)

    保存