Peekyou
Peekyou

Reputation: 471

WCF Streaming with authentication

I have a WCF service which must be secured with Windows and Certificate authentication. I know that wsHttpBinding does no support Streaming but according to msdn it can be done using transport security with a customBinding but I am not able to do it...

<customBinding>
    <binding name="AuthBinding">
      <mtomMessageEncoding maxBufferSize="65535" />
      <windowsStreamSecurity protectionLevel="Sign"/>
      <httpTransport transferMode="Streamed" maxReceivedMessageSize="2147483647" />
    </binding>
</customBinding>

I am going from one exception to another :

The security capabilities of binding 'System.ServiceModel.Channels.CustomBinding' do not match those of the generated runtime object. Most likely this means the binding contains a StreamSecurityBindingElement, but lacks a TransportBindingElement that supports Stream Security

Or

The request message must be protected. This is required by an operation of the contract ('IEntity','WebService.Entity'). The protection must be provided by the binding ('CustomBinding','WebService.Entity')

Upvotes: 3

Views: 2174

Answers (2)

MiguelSlv
MiguelSlv

Reputation: 15123

This works for me:

<basicHttpBinding>
    <binding name="basic"  transferMode="Streamed" messageEncoding="Mtom">
        <security mode="TransportWithMessageCredential">
            <message clientCredentialType="UserName" />
        </security>
    </binding>
</basicHttpBinding>

Upvotes: 0

Pranav Singh
Pranav Singh

Reputation: 20111

Rather than being done in a single step, this is two step process.

  1. Enable Transport Security with Certificate Authentication.

  2. Enable Transport Security with Windows Authentication.

Also I am not sure both works together.

But MSDN Article found seems to direct in a correct direction:

How to: Secure a Service with Windows Credentials with wsHttpBinding

Please refer these links from MSDN for further learning (not much help if you are in hurry to deliver some milestone):

Transport Security with Windows Authentication

Transport Security with Certificate Authentication


Update

You have to use custom binding having Mixed (transport with message credentials) security mode.

Three binding elements relate to message level security, all of which derive from the SecurityBindingElement class.

The three are TransportSecurityBindingElement, SymmetricSecurityBindingElement, and AsymmetricSecurityBindingElement. The TransportSecurityBindingElement is used to provide Mixed mode security. The other two elements are used when the message layer provides security. Additional classes are used when transport level security is provided:

HttpsTransportBindingElement  
SslStreamSecurityBindingElement 
WindowsStreamSecurityBindingElement

You can get help on:

How to: Create a Custom Binding Using the SecurityBindingElement

and

Security Capabilities with Custom Bindings

Upvotes: 1

Related Questions