Avatar billede zazzy Nybegynder
04. december 2009 - 11:52 Der er 2 kommentarer

WCF service med HTTPS - Problem!

Hej Eksperten,

Jeg har indtil videre kun rodet med WCF uden sikkerhed. Men da jeg skal sende lidt data over nettet tænkte jeg det ville være smart med noget sikkerhed. Så jeg har forsøgt mig hele morgenen at få HTTPS til at virke.

Min App.config ser pt. sådan ud (Bemærk det er en C# Windows Service og altså ikke til IIS):

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <connectionStrings>
  <add name="sqlconnectionstring" connectionString="Data Source=xxx; Initial Catalog=xxx; User ID=xxx; Password=x" />
  </connectionStrings>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior name="NewBehavior">
          <serviceMetadata httpsGetEnabled="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <bindings>
      <basicHttpBinding>
        <binding name="Binding">
          <security mode="Transport">
            <transport clientCredentialType="None"/>
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <services>
      <service behaviorConfiguration="NewBehavior"
            name="WCFData.WCFDataService">
        <endpoint
          address="https://localhost:10081/WCFsite"
          binding="basicHttpBinding"
          bindingConfiguration="Binding"
          contract="WCFData.IWCFDataService" />
        <host>
          <baseAddresses>
            <add baseAddress="https://localhost:10081/WCFsite" />
          </baseAddresses>
        </host>
      </service>
    </services>
  </system.serviceModel>
</configuration>

Servicen starter, men forsøger jeg at browse https://localhost:10081/WCFsite så kommer "Internet Explorer cannot display the webpage". Og prøver jeg at tilføje adressen som "Service Reference" i min klient, så får jeg:

There was an error downloading 'https://localhost:10081/WCFsite'.
The underlying connection was closed: An unexpected error occurred on a send.
Authentication failed because the remote party has closed the transport stream.
Metadata contains a reference that cannot be resolved: 'https://localhost:10081/WCFsite'.
An error occurred while making the HTTP request to https://localhost:10081/WCFsite. This could be due to the fact that the server certificate is not configured properly with HTTP.SYS in the HTTPS case. This could also be caused by a mismatch of the security binding between the client and the server.
The underlying connection was closed: An unexpected error occurred on a send.
Authentication failed because the remote party has closed the transport stream.
If the service is defined in the current solution, try building the solution and adding the service reference again.

--

Hvad mangler jeg / Gør jeg forkert?

Mvh.
ZazzY
04. december 2009 - 13:02 #1
Der kan være flere ting galt.

Kig lidt her og ændre din konfiguration ift. artiklen.
Avatar billede zazzy Nybegynder
04. december 2009 - 13:37 #2
Her hvor?
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester