Laden...

Richtige WCF Konfiguration für HTTPS?

Erstellt von xlShortylx vor 8 Jahren Letzter Beitrag vor 8 Jahren 1.578 Views
X
xlShortylx Themenstarter:in
8 Beiträge seit 2015
vor 8 Jahren
Richtige WCF Konfiguration für HTTPS?

Hallo,

ich habe einen funktionierenden WCF-Service, dieser läuft gerade aber nur über HTTP.
Nun möchte ich das ganze auf HTTPS umstellen, hierbei habe ich aber Probleme.
Ich habe sämtliche Lösungen im Internet recherchiert, funktioniert hat aber leider keine.
Ein gekauftes Zertifikat, das funktioniert, habe ich auf dem Webserver schon eingebunden.

Kann mir einer weiterhelfen und die Config anpassen, wie sie funktionieren sollte?

Config einer WPF Anwendung zum Verwalten von Datenbankeinträgen (Die gleiche Verbindung soll aber auch von einem Windows Service möglich sein, verbindet gerade auch nur über HTTP):


<?xml version="1.0"?>
<configuration>
  <configSections>
    <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
      <section name="USS_DbManager.Database" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false"/>
      <section name="USS_DbManager.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false"/>
    </sectionGroup>
  </configSections>
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_IDownloadServiceClient" closeTimeout="06:00:00"
          openTimeout="06:00:00" receiveTimeout="06:00:00" sendTimeout="06:00:00"
          allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
          maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"
          textEncoding="utf-8" transferMode="Streamed" useDefaultWebProxy="true"
          messageEncoding="Text">
          <readerQuotas maxDepth="128" maxStringContentLength="2147483647"
            maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None"
              realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
        <binding name="BasicHttpBinding_IDownloadService" />
        <binding name="BasicHttpBinding_IService" maxReceivedMessageSize="2147483647" />
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://localhost:5299/USS" binding="basicHttpBinding"
        bindingConfiguration="BasicHttpBinding_IService" contract="ServiceReference1.IService"
        name="BasicHttpBinding_IService" />
      <endpoint address="http://localhost:5299/USS_Download" binding="basicHttpBinding"
        bindingConfiguration="BasicHttpBinding_IDownloadService" contract="ServiceReference2.IDownloadService"
        name="BasicHttpBinding_IDownloadService" />
    </client>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true">
      <serviceActivations>
        <!--<add factory="System.ServiceModel.Activation.ServiceHostFactory"
               relativeAddress="USS_Library.Service.svc"
               service="USS_Library.IService"/>-->
      </serviceActivations>
    </serviceHostingEnvironment>
  </system.serviceModel>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
  </startup>
</configuration>

Config des WCF Dienstes:


<?xml version="1.0"?>
<configuration>
  <configSections>
    <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
      <section name="USS_Library.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
      <section name="USS_Library.service" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    </sectionGroup>
  </configSections>
  <system.web>
    <compilation debug="true" />
    <httpRuntime maxRequestLength="2097151"/>
    <membership defaultProvider="ClientAuthenticationMembershipProvider">
      <providers>
        <add name="ClientAuthenticationMembershipProvider" type="System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" />
      </providers>
    </membership>
    <roleManager defaultProvider="ClientRoleProvider" enabled="true">
      <providers>
        <add name="ClientRoleProvider" type="System.Web.ClientServices.Providers.ClientRoleProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" cacheTimeout="86400" />
      </providers>
    </roleManager>
  </system.web>
  <system.serviceModel>
    <client>
      <endpoint address="http://localhost:5299/USS/USS_Library.Service.svc"
        binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService"
        contract="ServiceReference.IService" name="BasicHttpBinding_IService" />
      <endpoint address="http://localhost:5299/USS/USS_Library.DownloadService.svc"
        binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IDownloadServiceClient"
        contract="DownloadReference.IDownloadService" name="BasicHttpBinding_IDownloadService" />
    </client>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_IService" maxReceivedMessageSize="2147483647" />
        <binding name="BasicHttpBinding_IDownloadServiceClient" closeTimeout="06:00:00"
          openTimeout="06:00:00" receiveTimeout="06:00:00" sendTimeout="06:00:00"
          allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
          maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"
          textEncoding="utf-8" transferMode="Streamed" useDefaultWebProxy="true"
          messageEncoding="Text">
          <readerQuotas maxDepth="128" maxStringContentLength="2147483647"
            maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None"
              realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
        <binding name="BasicHttpBinding_IDownloadServiceServer" closeTimeout="06:00:00"
          openTimeout="06:00:00" receiveTimeout="06:00:00" sendTimeout="06:00:00"
          maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"
          transferMode="Streamed">
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
            maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
          <security mode="None" />
        </binding>
      </basicHttpBinding>
    </bindings>
    <services>
      <service name="USS_Library.Service" behaviorConfiguration="sb1">
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <endpoint address="" binding="basicHttpBinding" contract="USS_Library.IService" bindingConfiguration="BasicHttpBinding_IService"/>
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:5299/USS" />
          </baseAddresses>
        </host>
      </service>
      <service name="USS_Library.DownloadService" behaviorConfiguration="DownloadServiceBehavior">
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <endpoint address="" binding="basicHttpBinding" contract="USS_Library.IDownloadService" bindingConfiguration="BasicHttpBinding_IDownloadServiceServer" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:5299/USS_Download" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="sb1">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
        <behavior name="DownloadServiceBehavior">
          <serviceMetadata httpGetEnabled="true"/>
          <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
          <serviceDebug includeExceptionDetailInFaults="true"/>
          <serviceThrottling maxConcurrentCalls="500" maxConcurrentSessions="500" maxConcurrentInstances="500"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true">
      <serviceActivations>
        <!--<add factory="System.ServiceModel.Activation.ServiceHostFactory"
               relativeAddress="USS_Library.Service.svc"
               service="USS_Library.IService"/>-->
      </serviceActivations>
    </serviceHostingEnvironment>
  </system.serviceModel>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
  </startup>
</configuration>

Und wie kann ich das local testen ohne den Webserver?

Mir wäre echt geholfen, wenn ich das schnellstmöglich hinbekommen würde.
Danke für die Hilfe.

Gruß xlShortylx

1.696 Beiträge seit 2006
vor 8 Jahren

Ich bin verantwortlich für das, was ich sage, nicht für das, was du verstehst.

**:::

X
xlShortylx Themenstarter:in
8 Beiträge seit 2015
vor 8 Jahren

Hi, ich hatte den Artikel von dir zwar auch schon im Internet gefunden aber habe habe es jetzt nochmal probiert. Und siehe da, ich hatte etwas vergessen abzuändern und nun gehts.

Danke für die Antwort.