2012-11-15 49 views
6

我一直在使用自簽名證書將http應用程序轉換爲https和ssl。錯誤:無法從http獲取元數據......?wsdl

由於某些原因,我必須在瀏覽器中使用localhost:#####來啓動服務。

一旦該服務已啓動,我在Visual Studio 2012 comman提示以下調用測試:

svcutil.exe https://localhost:10201/?wsdl 

,並與

Error: Cannot obtain Metadata from https://localhost:10201/?wsdl 

If this is a Windows (R) Communication Foundation service to which you have access, please check that you have enabled metadata publishing at the specified address. For help enabling metadata publishing, please refer to the MSDN documentation at http://go.microsoft.com/fwlink/?LinkId=65455. 


WS-Metadata Exchange Error 
    URI: https://localhost:10201/?wsdl 

    Metadata contains a reference that cannot be resolved: 'https://localhost:10201/?wsdl'. 

    Could not establish trust relationship for the SSL/TLS secure channel with authority 'localhost:10201'. 

    The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel. 

    The remote certificate is invalid according to the validation procedure. 


HTTP GET Error 
    URI: https://localhost:10201/?wsdl 

    There was an error downloading 'https://localhost:10201/?wsdl'. 

    The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel. 

    The remote certificate is invalid according to the validation procedure. 

If you would like more help, type "svcutil /?" 

回來這是detremental我sucess與HTTPS?

我的配置看起來這樣:

<system.serviceModel> 

    <!--SERVICES--> 
    <services> 
     <service name="DuplexService.DuplexService" 
     behaviorConfiguration="sb"> 

     <endpoint 
      address="basic" 
      binding="customBinding" 
      bindingConfiguration="customDuplexBinding" 
      contract="DuplexService.Interface.IDuplexServiceContract"> 
     </endpoint> 

     <endpoint 
      address="" 
      binding="webHttpBinding" 
      behaviorConfiguration="webHttpEndpointBehavior" 
      bindingConfiguration="webHttpsBinding" 
      contract="Interface.IPolicyRetriever"> 
     </endpoint> 

     <endpoint 
      address="mex" 
      binding="mexHttpsBinding" 
      contract="IMetadataExchange"> 
     </endpoint> 

     <host> 
     <baseAddresses> 
      <add baseAddress="https://localhost:10201" /> 
     </baseAddresses> 
     </host> 
     </service> 


    </services> 


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


<!--behaviour for all of the enpoints --> 
     <serviceBehaviors> 
     <behavior name="sb"> 
      <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment --> 
      <serviceMetadata httpsGetEnabled="true" httpsGetUrl="https://localhost:10201"/> 
      <!-- 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> 



    <!-- BINDINGS--> 
    <bindings> 

    <webHttpBinding> 
     <binding name="webHttpsBinding"> 
      <security mode="Transport"> 
       <transport clientCredentialType="None" /> 
      </security> 
     </binding> 
    </webHttpBinding> 

     <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> 
      <httpsTransport 
     maxBufferSize="2147483647" 
     maxReceivedMessageSize="2147483647" 
     transferMode="StreamedResponse" /> 
     </binding> 
     </customBinding> 



    </bindings> 




    <!-- Register the binding extension from the SDK. --> 
    <extensions> 
     <bindingElementExtensions> 
     <add name="pollingDuplex" 
      type="System.ServiceModel.Configuration.PollingDuplexElement, System.ServiceModel.PollingDuplex" /> 
     </bindingElementExtensions> 
    </extensions> 
    </system.serviceModel> 

我怎樣才能擺脫它?並使元數據工作和GET工作?

回答

10

我可以想出4種方法來解決這個問題。

  1. 將自簽名證書安裝爲受信任的根認證。 MMC - >證書
  2. 使用瀏覽器導航到wsdl(單擊通過證書錯誤),將其保存並直接生成wsdl。
    • 將wsdl的URL放入瀏覽器中,然後單擊過去的證書警告,以便您可以看到實際的wsdl將wsdl保存到您的計算機。在Chrome中,您可以右鍵單擊,另存爲。
    • 在Visual Studio
      • 右鍵單擊該項目並選擇「添加服務引用」
      • 在地址框中,輸入物理路徑:下載的WSDL的(C \目錄...)。
      • 擊去
  3. 火了小提琴手,並告訴它進行解密,這將安裝一個證書,並給你一個選擇忽略遠程證書錯誤HTTPS。在這裏描述。 http://proq.blogspot.com/2012/02/svcutil-and-https.html
  4. 使用受信任根簽名的證書。

我沒有看到svcutil選項忽略證書錯誤。

+0

沒有幫助,但將有助於其他人在未來尋找答案 –

+1

選項3工作的一種享受!選項3同上 –

+0

! – rhoeting

0

我有同樣的問題。對我來說,我注意到https使用另一個證書,該證書在到期日期方面無效。不知道爲什麼發生。我更改了Https端口號和一個新的自簽名證書。 WCFtestClinet可以通過HTTPS連接到服務器!

相關問題