I have a WCF service (.NET 4) hosted in IIS (7.5 on Windows Server 2008 R2). Our customer (for whom we are building the service) requires that all clients of the service be authenticated using certificates from Verisign. That is, the client purchases a certificate from Verisign and provides us with the public key. The service should only accept requests that can be validated using one of the public keys that we have received from the clients.
The problem that I am having is that IIS seems to require that Anonymous authentication be enabled. If it isn't, a "Security settings for this service require 'Anonymous' Authentication but it is not enabled for the IIS application that hosts this service." error is raised. However, if I enable anonymous authentication, any call to the service that provides any certificate is allowed. We need to restrict it to only allow calls that provide specific certificates (i.e. ones for which we have been supplied the public key).
In IIS we require SSL and client certificates (under SSL Settings), and (under Authentication) all authentication is disabled (except for anonymous).
The web.config is:
<system.web>
<compilation debug="false" targetFramework="4.0" />
<authentication mode="Windows" />
<authorization>
<deny users="?" />
<allow users="*" />
</authorization>
<customErrors mode="Off" />
<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID" />
<identity impersonate="false" />
</system.web>
<system.serviceModel>
<services>
<service behaviorConfiguration="XXXServiceBehavior" name="XXXService.NewService">
<endpoint address=""
binding="wsHttpBinding"
bindingConfiguration="XXXServiceBinding"
contract="XXXService.INewService"
bindingNamespace="http://XXXX.com.au/XXXService/NewService">
</endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="XXXXServiceBehavior">
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceCredentials>
<clientCertificate>
<authentication certificateValidationMode="PeerTrust" mapClientCertificateToWindowsAccount="true" />
</clientCertificate>
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<wsHttpBinding>
<binding name="XXXServiceBinding" maxReceivedMessageSize="1000000" maxBufferPoolSize="1000000">
<readerQuotas maxStringContentLength="1000000" />
<security mode="Transport">
<transport clientCredentialType="Certificate" />
</security>
</binding>
</wsHttpBinding>
</bindings>
</system.serviceModel>
If anyone is able to get this sort of scenario working, could you please let me know what settings you are using in IIS and in your configuration?
PrincipalPermissionAttribute
to demand either Windows auth or membership of a particular group? – anton.burgerserviceAuthorization
and specifying Windows groups to yourserviceBehavior
help? – anton.burger<serviceAuthorization principalPermissionMode="UseWindowsGroups" />
in the configuration. Although it turns out that what I was really looking for all along was to useTransportWithMessageCredential
, but I'll post the details as an Answer. – MarkShep