c# - IIS hosted WCF with SSL security -"The HTTP request was forbidden with client authentication scheme 'Anonymous'" error -
i trying host wcf on iis using transport security. found tutorial , follow instructions : http://robbincremers.me/2011/12/27/wcf-transport-security-and-client-certificate-authentication-with-self-signed-certificates/. getting "the http request forbidden client authentication scheme 'anonymous'". how can handle it?
what did far is:
i created self-signed root authority certificate explained here.
makecert -n "cn=tempca" -r -sv tempca.pvk tempca.cer
created new server certificate signed root authority certificate
makecert -sk signedbyca -iv tempca.pvk -n "cn=localhost" -ic tempca.cer localhost.cer -sr localmachine -ss my
created new client certificate signed root authority certificate
makecert -sk signedbyca -iv tempca.pvk -n "cn=clientcert" -ic tempca.cer clientcert.cer -sr localmachine -ss my
added ca trusted root certificate
added these certificates personal --> certificates
added client certificate trusted people
everything looks ok
created simple wcf application. added iis
adjust security settings
this service web.config file
> <?xml version="1.0"?> <configuration> <system.web> > <compilation debug="true" targetframework="4.5" /> > <httpruntime targetframework="4.5"/> </system.web> <system.servicemodel> > <bindings> > <basichttpbinding> > <binding name="employeebindingconfig"> > <security mode="transport"> > <transport clientcredentialtype="certificate" /> > </security> > </binding> > </basichttpbinding> > </bindings> > <behaviors> > <servicebehaviors> > <behavior name="employeeservicebehavior"> > <servicemetadata httpsgetenabled="true"/> > <servicedebug includeexceptiondetailinfaults="true"/> > <servicecredentials> > <clientcertificate> > <authentication certificatevalidationmode="peerorchaintrust" > trustedstorelocation="localmachine" /> > </clientcertificate> > </servicecredentials> > </behavior> > </servicebehaviors> > </behaviors> > <services> > <service > behaviorconfiguration="employeeservicebehavior" > name="wcf.tutorial.transportsecurity.servicenew.employeeservice"> > <host> > <baseaddresses> > <add baseaddress="https://localhost/wcf.tutorial.transportsecurity.servicenew"/> > </baseaddresses> > </host> > <endpoint address="employeeservice" > binding="basichttpbinding" > bindingconfiguration="employeebindingconfig" > contract="wcf.tutorial.transportsecurity.servicenew.iemployeeservice" > /> > <endpoint > address="mex" > binding="mexhttpsbinding" > contract="imetadataexchange" /> > </service> > </services> </system.servicemodel> <system.webserver> > <modules runallmanagedmodulesforallrequests="true"/> </system.webserver> </configuration>
- this client app.config
> <?xml version="1.0" encoding="utf-8" ?> > <configuration> > <startup> > <supportedruntime version="v4.0" sku=".netframework,version=v4.5" /> > </startup> > <system.servicemodel> > <behaviors> > <endpointbehaviors> > <behavior name="employeeendpointbehaviour"> > <clientcredentials> > <clientcertificate storelocation="localmachine" storename="my" x509findtype="findbysubjectname" findvalue="omer-hp"/> > </clientcredentials> > </behavior> > </endpointbehaviors> > </behaviors> > <bindings> > <basichttpbinding> > <binding name="employeebindingconfig"> > <security mode="transport"> > <transport clientcredentialtype="certificate" /> > </security> > </binding> > </basichttpbinding> > </bindings> > <client> > <endpoint address="https://localhost/wcf.tutorial.transportsecurity.servicenew/employeeservice.svc" > binding="basichttpbinding" bindingconfiguration="employeebindingconfig" > contract="wcf.tutorial.transportsecurity.servicenew.iemployeeservice" > name="serviceendpoint" > behaviorconfiguration="employeeendpointbehaviour"/> > </client> > </system.servicemodel> > </configuration>
- this client code , error
my question how can pass error? need help.
at least issue has been found. when looked inside windows event log saw error
when asking client authentication, server sends list of trusted certificate authorities client. client uses list choose client certificate trusted server. currently, server trusts many certificate authorities list has grown long. list has been truncated. administrator of machine should review certificate authorities trusted client authentication , remove not need trusted.
i backed certificates , deleted them. after operation program works.
Comments
Post a Comment