Using client certificates for authentication

The client machine has the "TicketSalesClient" certificate in "My" storage of current user and the "TicketSalesServer" certificate in "TrustedPeople" storage of current user. The server machine has "TicketSalesClient" certificate in "TrustedPeople" storage of local machine and the "TicketSalesServer" certificate in "My" storage of local machine.

The service runs under IIS 7. Below is the web.config file:

  <service behaviorConfiguration="secureBehavior" name="InternetRailwayTicketSales.TicketSalesImplementations.TicketSalesService">
    <endpoint address="TicketSalesService" 
              bindingConfiguration="secureHttpBinding" contract="InternetRailwayTicketSales.TicketSalesInterface.ITicketSales" />

    <endpoint address="TicketSalesServiceSecureMex" 
              contract="IMetadataExchange" />

        <add baseAddress="https://localhost:443/TicketSales/" />            

    <binding name="secureHttpBinding">
      <security mode="Transport">
        <transport clientCredentialType="Certificate"/>

    <behavior name="secureBehavior">
      <serviceThrottling maxConcurrentInstances="5000" maxConcurrentSessions="5000" />
      <serviceMetadata httpsGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="True" />
        <serviceCertificate findValue="TicketSalesServer" 
          <authentication certificateValidationMode="PeerTrust"/>

The service in IIS is configured for SSL and certificate requiring.

1)Now when I try to add service reference in the client I receieve: "The HTTP request was forbidden with client authentication scheme 'Anonymous'. The remote server returned an error: (403) Forbidden."

2)If I try to request the metadata endpoint using browser I firstly apply the SSL certificate and then receieve an error that "The credentials do not give the right to view this directory or page." As I understand this is because I can't give the client credentials through the browser.

3)I tried to use svcutil with configuration file which contains client credentials:

        name="https" />
        <binding name="Binding1">
          <security mode="Transport">
            <transport clientCredentialType="Certificate" />
        <behavior name="ClientCertificateBehavior">
            <clientCertificate findValue="TicketSalesClient"
                               x509FindType="FindBySubjectName" />

And then:

svcutil https://veryLongAddress.svc?wsdl /config:svcutilConf.config

And the response is that the "The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel. The remote certificate is invalid according to the validation procedure"

So what am I doing wrong?


Seems like your certificates installation is fine. Can you try as shown below and see the output. Try to browse to the service from IE and you should be able to see the service and its wsdl.

Go to IE and then

Tools --> Internet Options --> Security --> Internet --> Custom Level

Tools --> Internet Options --> Security --> Intranet --> Custom Level

Now scroll down to Misc section to find the option "Dont Prompt for client certificate selection when no certificate is present or only one certificate is present" to Diable.

Now restart IE and browse to the service and IE should ask you to select a client certificate from the personal store and you need to select mvc.localhost.

If TicketSalesClient cert is not visible then your client certificate is not in the appropriate store.

The reason for this is that the file you are using to install the certificates do matter as well as the purpose for which the certificate has been created. You can find the purpose of each certificate when you double click them in the certificate store you have a column that is called Intended Purpose. Make sure its for your client certificate.

Need Your Help

Playing with fonts in Wordpress

php css wordpress layout fonts

Recently installed new wordpress theme. The problem is, there are only following font options to choose.

Android: Why does View background draw in editor but not in app?

java android view

I have an Android project with an xml file representing a row for an Adapter.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.