views:

50

answers:

1

I have a WebForms app on IIS7 with clients authenticating via certificates. Is there a way to read from client certificate (one on the server or the one that client supplies) to find out when it will expire? How can this be done?

I want to prevent user from seeing 403 when it expires and give them the new certificate on time.

I understand that this is something that certificate server should be doing but seriously, how many of works with certificate server attached to web server...

+1  A: 

You can do so via the Request.ClientCertificate, which is an object of type HttpClientCertificate. Check out the VALIDFROM and VALIDUNTIL fields.

    Dim sbCert as new StringBuilder()
    Dim cert As HttpClientCertificate = Request.ClientCertificate
    If cert.IsPresent Then
        For Each strKey As String in cert
            sbCert.Append(strKey & " = " & cert(strKey) & "<br />") 
        Next
    Else
    sb.Append("Client certificate not present")
    End If
    Response.Write(sbCert.ToString())
Rodrigo Hahn