ClientCertificate

The ClientCertificate collection retrieves the certification fields (specified in the X.509 standard) from a request issued by the Web browser.

If a Web browser uses the SSL3.0/PCT1 protocol (in other words, it uses a URL starting with https:// instead of http://) to connect to a server and the server requests certification, the browser sends the certification fields.

If no certificate is sent, the ClientCertificate collection returns EMPTY.

Before you can use the ClientCertificate collection, you must configure your Web server to request client certificates.

Syntax

Request.ClientCertificate( Key[SubField] )
 

Parameters

Key
Specifies the name of the certification field to retrieve. A client certificate consists of the following fields.
Value Meaning
Certificate A string containing the binary stream of the entire certificate content in ASN.1 format.
Flags A set of flags that provide additional client certificate information. The following flags may be set:

ceCertPresent - A client certificate is present.

ceUnrecognizedIssuer - The last certification in this chain is from an unknown issuer.

Note  To use the preceding flags you must include the client-certificate include file in your ASP page. If you are using VBScript, include cervbs.inc. If you are using JScript, include cerjavas.inc. These files are installed in the \Inetpub\ASPSamp\Samples directory.

Issuer A string that contains a list of subfield values containing information about the issuer of the certificate. If this value is specified without a SubField, the ClientCertificate collection returns a comma-separated list of subfields. For example, C=US, O=Verisign, and so on.
SerialNumber A string that contains the certification serial number as an ASCII representation of hexidecimal bytes separated by hyphens (-). For example, 04-67-F3-02.
Subject A string that contains a list of subfield values that themselves contain information about the subject of the certificate. If this value is specified without a SubField, the ClientCertificate collection returns a comma-separated list of subfields. For example, C=US, O=Msft, and so on.
ValidFrom A date specifying when the certificate becomes valid. This date follows VBScript format and varies with international settings. For example, in the U.S. 9/26/96 11:59:59 pm.
ValidUntil A date specifying when the certificate expires.

SubField
An optional parameter you can use to a retrieve an individual field in either the Subject or Issuer keys. This parameter is added to the Key parameter as a suffix. For example, IssuerO or SubjectCN. The following table lists some common SubField values.
Value Meaning
C Specifies the name of the country of origin.
CN Specifies the common name of the user. (This subfield is only used with the Subject key.)
GN Specifies a given name.
I Specifies a set of initials.
L Specifies a locality.
O Specifies the company or organization name.
OU Specifies the name of the organizational unit.
S Specifies a state or province.
T Specifies the title of the person or organization.

SubField values other than those listed in the preceding table can be identified by their ASN.1 identifier. The format of the ASN.1 identifier is a list of numbers separated by a period (.). For example,: 3.56.7886.34.

Remarks

You can use an iterator to loop through the keys of the ClientCertificate collection. This is demonstrated in the following example.

<%
For Each key in Request.ClientCertificate
  Response.Write( key & ": " & Request.ClientCertificate(key) & "<BR>")
Next
%>
 

Examples

The following example uses the Subject key to test whether a client certificate has been presented.

<%
If Len(Request.ClientCertificate("Subject")) = 0
  Response.Write("No client certificate was presented")
End if
%>
 

The following example retrieves the common name of the company that issued the client certificate.

<%= Request.ClientCertificate("IssuerCN") %>
 

The following example checks the organization name of the subject of the client certification.

<% 
If (Request.ClientCertificate("Subject")="Msft")
  Response.Write("Good Choice!")
End if
%>
 

The following example displays the expiration date of the client certificate.

This certification will expire on 
<%= Request.ClientCertificate("ValidUntil") %>
 

The following example uses the Flags key to test whether the issuer of the certificate is known. The include statement in the first line enables this script to use the named flag ceUnrecognizedIssuer.

<!--#include file="cervbs.inc" -->
<%
If Request.ClientCertificate("Flags") and ceUnrecognizedIssuer then
  Response.Write "Unrecognized issuer"
End If
%>
 

Applies To

Request Object

See Also

Cookies, Form, QueryString, ServerVariables