Search code examples
c#asp.netbrowsersmartcard

Browser not Reading client certificate


I am trying to read a certificate using the following code

if (Page.Request.ClientCertificate.IsPresent)
{
    HttpClientCertificate cs = Request.ClientCertificate;
    string entireSubjectLine = cs.Subject.ToString();

    if (entireSubjectLine != "")
    {
        lblResponse.Text = entireSubjectLine;
    }
    else
    {
        lblResponse.Text = "No Data";
    }
}

This line - if (Page.Request.ClientCertificate.IsPresent) is returning false, means certificate is not being read. How to achieve it?


Solution

  • This is how you configure IIS to accept certificates:

    ssl settigns

    accept client certificates

    This seems to make your site ask for certificates though, even if you use Accept and not Require.

    Not sure if you want that.

    This is for IIS. For IIS Express you can see here: https://improveandrepeat.com/2017/07/how-to-configure-iis-express-to-accept-ssl-client-certificates/