meir rivkin

meir rivkin

  • NA
  • 1
  • 0

wcf - enable both http and https

May 12 2009 9:19 AM

hi,

i've created webhttp based wcf service.
i'd like to achieve 2 things:
 supprt both http and https, i'd like to give the IT manager the power to enforce the use of ssl by configure the IIS (IIs 7.0 -> SSL settings ->require SSL)
but in terms of my service, i wish to support both:
http://LebronServer/ExternalServices/PlaylistService.svc?GetPlaylist....
and
https://LebronServer/ExternalServices/PlaylistService.svc?GetPlaylist....

so i duplicated the endpoint and binding sections in the web.config to support each of the protocols (http and https).

to prevent from consuming the service, i removed the mex metadata endpoing and removed the serviceMetadata section under serviceBehaviors.

 

<bindings>

<netTcpBinding>

<binding name="netTcpSecurityBindingConfig" closeTimeout="00:30:00" openTimeout="00:30:00" receiveTimeout="00:30:00" sendTimeout="00:30:00" transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions" hostNameComparisonMode="StrongWildcard" listenBacklog="10" maxBufferPoolSize="10485760" maxBufferSize="10485760" maxConnections="10" maxReceivedMessageSize="10485760">

<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />

<reliableSession ordered="true" inactivityTimeout="00:30:00" enabled="false" />

<security mode="Transport">

<transport clientCredentialType="Windows" protectionLevel="None" />

<message clientCredentialType="Windows" />

</security>

</binding>

</netTcpBinding>

<webHttpBinding>

<binding name="webHttpsBindingConfig" closeTimeout="00:20:00" openTimeout="00:20:00" receiveTimeout="00:20:00" sendTimeout="00:20:00" maxBufferSize="4194304" maxReceivedMessageSize="4194304">

<security mode="Transport">

<transport clientCredentialType="Basic" />

</security>

</binding>

<binding name="webHttpBindingConfig" closeTimeout="00:20:00" openTimeout="00:20:00" receiveTimeout="00:20:00" sendTimeout="00:20:00" maxBufferSize="4194304" maxReceivedMessageSize="4194304">

<security mode="TransportCredentialOnly">

<transport clientCredentialType="Basic" />

</security>

</binding>

</webHttpBinding>

</bindings>

<services>

<service behaviorConfiguration="PlaylistServiceBehavior" name="TVeez.BL.Services.Facade.PlaylistService.PlaylistService">

<endpoint address="" behaviorConfiguration="webBehavior" binding="webHttpBinding" bindingConfiguration="webHttpBindingConfig" contract="TVeez.BL.Services.Contracts.PlaylistService.IPlayListService" />

<endpoint address="" behaviorConfiguration="webBehavior" binding="webHttpBinding" bindingConfiguration="webHttpsBindingConfig" contract="TVeez.BL.Services.Contracts.PlaylistService.IPlayListService" />

</service>

</services>

<behaviors>

<endpointBehaviors>

<behavior name="webBehavior">

<webHttp />

</behavior>

</endpointBehaviors>

<serviceBehaviors>

<behavior name="PlaylistServiceBehavior">

<serviceDebug includeExceptionDetailInFaults="true" />

<serviceThrottling maxConcurrentCalls="128" maxConcurrentSessions="128" maxConcurrentInstances="128" />

</behavior>

</serviceBehaviors>

</behaviors>

 
i do have a problem when configure the IIS (7.0) to require SSL (ignore client certificates).
if i check this option i get {"The remote server returned an error: (500) Internal Server Error."}.

any ideas?

Answers (1)