I am trying to set up a demonstration of mutual SSL between a self-service WCF service and a client application (now this is a command line). In the end, I try to find a solution in which I have transport security (rather than message security) between a server that uses a certificate for its incoming connections and several clients, each with separate certificates that I can use to uniquely identify each of customers.
Ive tried a number of different approaches to this, but no one worked (I could not find an exact example of what Ive tried to do). Every time I think that I am approaching, I get an exception in the client when I try to call the service. The most common exception I came across is:
"The HTTP request was forbidden with client authentication scheme 'Anonymous'."
Inner exception: "The remote server returned an error: (403) Forbidden."
Does anyone have any thoughts on what I could have done wrong or perhaps better thought out how to set up shared SSL in the above scenario?
Full disclosure of information - at the moment I am running both the client and the server on the same computer. Not sure if this is important.
The fragments are described below.
The service and client code is relatively trivial, so I'm pretty sure Ive made them work. Application configurations (specifically bindings and behavior) and certificates are “more interesting,” so I'm not so sure about that.
( )
makecert -pe -n "CN=SelfSignedCA" -ss Root -sr LocalMachine -a sha1 -sky signature -r -sv "SelfSignedCA.cer" "SelfSignedCA.pvk"
makecert -pe -n "CN=system" -ss my -sr LocalMachine -a sha1 -sky exchange -eku 1.3.6.1.5.5.7.3.1 -in "SelfSignedCA" -is Root -ir LocalMachine -sp "Microsoft RSA SChannel Cryptographic Provider" -sy 12 Service.cer
makecert -pe -n "CN=client1" -ss my -sr LocalMachine -a sha1 -sky exchange -eku 1.3.6.1.5.5.7.3.1 -in "SelfSignedCA" -is Root -ir LocalMachine -sp "Microsoft RSA SChannel Cryptographic Provider" -sy 12 Client1.cer
( )
netsh http add urlacl url=https:
:
<wsHttpBinding>
<binding name="CustomBinding">
<security mode="Transport">
<transport clientCredentialType="Certificate"/>
</security>
</binding>
</wsHttpBinding>
:
<serviceBehaviors>
<behavior name="">
<serviceAuthorization
serviceAuthorizationManagerType=
"ClientAuthorization.ClientCertificateAuthorizationManager, Simulator.Service.SideA" />
</behavior>
</serviceBehaviors>
Client
:
<wsHttpBinding>
<binding name="CustomBinding">
<security mode="Transport">
<transport clientCredentialType="Certificate"/>
</security>
</binding>
</wsHttpBinding>
<endpointBehaviors>
<behavior name="ChannelManagerBehavior">
<clientCredentials>
<clientCertificate findValue="client1"
storeLocation="LocalMachine"
storeName="My"
x509FindType="FindBySubjectName" />
</clientCredentials>
</behavior>
</endpointBehaviors>
UPDATE
, , ( , ). . - " " "." .
<serviceCredentials>
<userNameAuthentication
userNamePasswordValidationMode="Custom"
customUserNamePasswordValidatorType=
"Service.ClientAuthorization.ClientUserNamePasswordValidatorManager, Service.SideA" />
</serviceCredentials>