簡體   English   中英

通過SSL的WCF服務無法使用授權'test-service.hostname.com'為SSL / TLS建立安全通道

[英]WCF Service over SSL Could not establish secure channel for SSL/TLS with authority 'test-service.hostname.com'

我有一個問題。 我們正在嘗試通過所需的SSL將客戶端證書附加到WCF服務。 當我嘗試通過瀏覽器導航到該服務時,它將向我顯示“您已經創建了一個服務頁面”,但只有在我附加證書時,所以我不認為它是一個IIS問題。

我經歷了很多堆棧溢出問題,我認為每次我都取得一點進展。 但是對於我的生活,我無法動搖這個問題。 我添加了日志記錄,這是我看到的錯誤:

System.Net Information: 0 : [12444] SecureChannel#15775260 - Certificate 

is of type X509Certificate2 and contains the private key.
System.Net Information: 0 : [12444] AcquireCredentialsHandle(package = Microsoft Unified Security Protocol Provider, intent  = Outbound, scc     = System.Net.SecureCredential)
System.Net Error: 0 : [12444] AcquireCredentialsHandle() failed with error 0X8009030D.
System.Net Information: 0 : [12444] AcquireCredentialsHandle(package =



Microsoft Unified Security Protocol Provider, intent  = Outbound, scc     = System.Net.SecureCredential)
System.Net Error: 0 : [12444] AcquireCredentialsHandle() failed with error 0X8009030D.
System.Net.Sockets Verbose: 0 : [8000] Socket#13431269::Dispose()
System.Net Error: 0 : [8000] Exception in HttpWebRequest#55386345:: - The request was aborted: Could not create SSL/TLS secure channel..
System.Net Error: 0 : [8000] Exception in HttpWebRequest#55386345::GetResponse - The request was aborted: Could not create SSL/TLS secure channel..
System.ServiceModel Error: 131075 : <TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Error"><TraceIdentifier>http://msdn.microsoft.com/en-US/library/System.ServiceModel.Diagnostics.ThrowingException.aspx</TraceIdentifier><Description>Throwing an exception.</Description><AppDomain>/LM/W3SVC/1/ROOT/Application.TestHarness.Blah-1-130676061695261461</AppDomain><Exception><ExceptionType>System.ServiceModel.Security.SecurityNegotiationException, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType><Message>Could not establish secure channel for SSL/TLS with authority 'test-bolt.homesite.com'.</Message><StackTrace>   at System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException, HttpWebRequest request, HttpAbortReason abortReason)
   at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
   at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&amp;amp; msgData, Int32 type)
   at Application.TestHarness.IntegrationService.QuickQuote()

服務配置:

<system.serviceModel>
<behaviors>
  <serviceBehaviors>
    <behavior name="WebBehavior">
      <serviceMetadata httpGetEnabled="false" httpsGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="false" />
    </behavior>
  </serviceBehaviors>
</behaviors>

<services>
  <service name="Service.Namwe" behaviorConfiguration="WebBehavior">
    <endpoint address=""
              binding="wsHttpBinding"
              bindingConfiguration="transportSecurity"
              contract="Service.IContract"/>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
  </service>
</services>
<bindings>
  <wsHttpBinding>
    <binding name="transportSecurity">
      <security mode="Transport">
        <transport clientCredentialType="Certificate"/>
      </security>
    </binding>
  </wsHttpBinding>
</bindings>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />

客戶端配置:

<system.serviceModel>
<bindings>
  <wsHttpBinding>
    <binding name="transportSecurity">
      <security mode="Transport">
        <transport clientCredentialType="Certificate"/>
      </security>
    </binding>
  </wsHttpBinding>
</bindings>
<behaviors>
  <endpointBehaviors>
    <behavior name ="defaultClientCertificate">
      <clientCredentials>
        <clientCertificate storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName" findValue="hostname.com"/>
      </clientCredentials>
    </behavior>
  </endpointBehaviors>
</behaviors>
<client>
  <endpoint name="boltService" behaviorConfiguration="defaultClientCertificate"
            address="https://hostname.com/Service/Integration.svc"
            binding="wsHttpBinding"
            bindingConfiguration="transportSecurity"
            contract="ServiceRef.IServiceContract" />
</client>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />

任何建議將不勝感激。

我弄清楚我的問題是什么。 運行該服務的App池無權訪問該證書。 我以為自從我將其卡在IIS中以來,所有應用程序池都可以訪問(不是這種情況)。 如果有人發現這個並且有一個simialar問題,這里是我最終發現和修復它的原因。 https://msdn.microsoft.com/en-us/library/aa702621.aspx如果您喜歡GUI而不是cmd行工具,也可以在MMC中執行此操作。

我有同樣的問題,解決了這個代碼的問題;

ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls;

或者試試這段代碼

ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;

以管理員模式運行visual studio為我解決了這個問題。

暫無
暫無

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

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