[This is preliminary documentation and subject to change]

### ClientCertificate

The ClientCertificate collection holds fields of keys and values from a security certificate that the client browser passes to the Web server. These fields are specified in the X.509 version 3 standard for public key certificates. Because X.509 is not an official standard, you may notice differences among certificates obtained from certificate authorities. See World Wide Web Consortium Web site for an article titled X509 Certificate.

In order to populate the fields of the ClientCertificate collection, both the Web server and the client browser must support the SSL3.0/PCT1.0 protocol. The Web site must have SSL enabled and request client certificates. Once SSL is enabled, the URL of the Web site will start with "https://" instead of "http://". The client browser must be capable of sending a certificate. If no certificate is sent, the ClientCertificate collection returns EMPTY.

To configure your Web server to request client certificates, see Setting Up SSL on Your Server.

To read the values in each field of the ClientCertificate collection, pass in a key name and optional subfield name.

###### 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. This is useful to discover if special SubFields are present that are not listed below.
  Flags | A set of flags that provide additional client certificate information. If Flags is set to 1, a client certificate is present. If Flags is set to 2, the last certificate in this chain is from an unknown issuer.
  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 hexadecimal bytes separated by hyphens (-). For example, 04-67-F3-02.
  Subject | A string that contains a list of subfield values. The subfield values 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. The year value is displayed as a four-digit number.
  ValidUntil | A date specifying when the certificate expires. The year value is displayed as a four-digit number.

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/region 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 Object Identifier (OID). The format of the OID is a list of numbers separated by a period (.). A list of OIDs for your certificate can be obtained from the authority that issued your certificate.

###### Example

You can iterate through the keys of the ClientCertificate collection. This is demonstrated in the following example.

    <%
      For Each strKey in Request.ClientCertificate
        Response.Write strkey & " = " & Request.ClientCertificate(strkey) & "<BR>"
      Next
    %>

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

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

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.
    <%
      Const ceCertPresent = 1
      Const ceUnrecognizedIssuer = 2
      If Request.ClientCertificate("Flags") = ceUnrecognizedIssuer Then
        Response.Write "Unrecognized issuer"
      End If
    %>

The following example displays all the fields of a client certificate.

    Issuer: <%=Request.ClientCertificate("Issuer")%><br>
    Subject: <%=Request.ClientCertificate("Subject")%><br>

    <% cer=Request.ClientCertificate("Certificate") %>
    Certificate Raw Data: <%=cer%><br>
    Certificate length: <%=len(cer)%><br>
    Certificate Hex Data:
    <% For x=1 To 100 %>
      <%=hex(asc(mid(cer,x,1)))%>&nbsp;
    <% Next %>

###### Applies To

Request Object

###### See Also

Cookies, Form, QueryString, ServerVariables, Security and Cryptography

© 1997-2001 Microsoft Corporation. All rights reserved.