我很努力地使用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
我已經綁定到端口(見我的問題的最後一部分)的SSL證書,我有我的證書稱爲「本地主機」。我只是很堅持如何正確配置服務器和客戶端的WCF配置文件正常工作 –
我知道它看起來像我張貼的大文章和嘗試它,但你真的應該通讀它和試一試。讓SSL爲自己託管的服務工作需要一段時間,還需要一系列的研究,以便您可以閱讀整個流程。至少,看看博客文章中的配置設置與您的相比。這主要是您需要擔心的服務器端。一旦你有一個可用的SSL服務,客戶端在添加服務引用後不需要修改。 – atconway
我實際上在來這裏之前使用了您的博客文章。我再次看到它,但我認爲我需要一些手上的幫助 –