views:

172

answers:

1

I especially need to get client's certificate used to call service's method. This is to react differently for different clients.

A: 

In your operation code, you can examine things like:

OperationContext.Current

or

ServiceSecurityContext.Current

but I'm not sure if you can access the actual client certificate from those.

The ServiceSecurityContext.Current.PrimaryIdentity will contain an IIdentity for the current caller - if it's NULL, then you're dealing with an anonymous call. Otherwise, the PrimaryIdentity will be one of several possible identity types, depending on how the calling user was authenticated - it could be a Windows identity, or something else - depending on your scenario.

See this blog post for a few more tidbits of information on X.509 and WCF.

marc_s