Client Certificate Examples

This example consists of two files - ClientCertificate.xls and cc.asp. The latter has to be installed on an SSL-secured branch of a Web site that requires client certificates (see instructions on how to set up). The XLS file contains the code to tear the cc.asp file using a client certificate installed for the current interactive user (see instructions).

The Excel Code

' Christoph Wille 07/13/1999,
Option Explicit

' change the sample URL here...
Const strTestCCSecuredURL = ""

Sub TestSSL()
    Dim xObj As Object, strResult As String, bErrors As Boolean
    ' create the object
    Set xObj = CreateObject("SOFTWING.ASPtear")
    On Error Resume Next
    xObj.TrustUnknownCA = True
    ' you can force an invalid CN error by changing the "strTestCCSecuredURL" to the IP address
    ' of (as the certificate was issued for the name and not the IP address). Please
    ' note that there is no cc.asp on the server - you can test only for certificate
    ' validity there
    xObj.IgnoreInvalidCN = True
    ' this is a new flag for AspTear 1.2 - it allows us to ignore invalid
    ' server certificate dates (cert's that are no longer valid - useful for test certificates)
    xObj.IgnoreInvalidCertDate = True
    ' tell the object to send the first certificate it finds for the current user account
    xObj.SendClientCertificate = True
    strResult = xObj.Retrieve(strTestCCSecuredURL, Request_GET, "", "", "")
    bErrors = HandleError()
    If Not bErrors Then
        MsgBox "SSL document was retrieved successfully!"
        Debug.Print strResult
    End If
End Sub

Helper Files


' Written by Christoph Wille, 13.07.99

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

For Each key in Request.ClientCertificate
   Response.Write( key & ": " & Request.ClientCertificate(key) & vbCRLF)