Configuración de seguridad de nivel de transporte en el servicio WCF webHttp
Pregunta
Estoy tratando de establecer la seguridad de nivel de transporte en un servicio WCF vinculante webHttp mi configuración actual se parece a esto
<system.serviceModel>
<client>
<endpoint binding="webHttpBinding" bindingConfiguration="webHttp"
contract="PrimeStreamInfoServices.IService1" name="Client" />
</client>
<bindings>
<webHttpBinding>
<binding name="webHttp" maxBufferPoolSize="1500000" maxReceivedMessageSize="1500000" maxBufferSize="1500000">
<security mode="Transport">
<transport clientCredentialType="None"
proxyCredentialType="None"
realm="string" />
</security>
</binding>
</webHttpBinding>
</bindings>
<services>
<service name="PrimeStreamInfoServices.Service1" behaviorConfiguration="PrimeStreamInfoServices.Service1Behavior">
<!-- Service Endpoints -->
<endpoint address="" binding="webHttpBinding" bindingConfiguration="webHttp" contract="PrimeStreamInfoServices.IService1">
<!--
Upon deployment, the following identity element should be removed or replaced to reflect the
identity under which the deployed service runs. If removed, WCF will infer an appropriate identity
automatically.
-->
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="PrimeStreamInfoServices.Service1Behavior">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- 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="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<diagnostics>
<messageLogging logMalformedMessages="true" logMessagesAtServiceLevel="true"
logMessagesAtTransportLevel="true" />
</diagnostics>
Sin embargo, cuando corro mi servicio me sale una excepción: No se pudo encontrar una dirección base que coincide con https esquema para el punto final con WebHttpBinding vinculante. esquemas de dirección de base son registrados [http].
Yo sé im falta algo, y yo he estado intentando varias cosas que no puedo entenderlo, alguien tiene alguna información sobre lo que tengo que hacer?
Solución
Sí - cambiar a HTTPS, con un certificado adecuado. seguridad en el transporte, en el caso de HTTP es proporcionada por un canal SSL. No se puede tener WS * la seguridad del transporte, la llanura HTTPS
Otros consejos
No haga caso de mi respuesta anterior, estaba pensando wsHttpBinding no webHttpBinding.
Es la dirección que se utiliza para llamar al servicio que debe comenzar con https.
Se puede tratar de añadir una dirección base (dentro del elemento <host>
de su configuración de servicio) que es https? ¿Desea agregar a una (o varias) dirección base (s) en el código?
<service name="PrimeStreamInfoServices.Service1"
behaviorConfiguration="PrimeStreamInfoServices.Service1Behavior">
<host>
<baseAddresses>
<add baseAddress="https://localhost:8080/YourService.svc" />
</baseAddresses>
</host>
<!-- Service Endpoints -->
<endpoint ......
</service>
No es 100% seguro si funciona con el webHttpBinding, pero darle una oportunidad!
Marc
Recuerde que además de la correcta configuración de WCF, también es necesario para configurar la propiedad de IIS para habilitar SSL en el mismo (incluyendo el establecimiento de certificado X.509 correcta para SSL). El docs tienen alguna información decente sobre cómo hacerlo.