Creating the Certificate Request

The process of creating a certificate request involves collecting certain information from the requester. Usually, this is done through some sort of user interface (UI), although it could conceivably be taken directly from a database without the need for a UI. The required information is set by the policy of the certifying authority (CA). An example of the required information might be as follows:

Common Name
Unit Name
Company Name
City
State
Country

The following code is a simple example of how to use Visual Basic Script and HTML in a Web page to generate input for the CEC, and then to request a certificate. This example uses the default property values of the CEC object, and expects to find the xenroll.dll in the same directory.

<HTML>
<HEAD>
<TITLE>Enrollment HTML Page</TITLE>

<OBJECT
    classid="clsid:43F8F289-7A20-11D0-8F06-00C04FC295E1"
    CODEBASE="xenroll.dll"
    id=Enroll
    >
</OBJECT>

<SCRIPT LANGUAGE="VBSCRIPT">

    sub CertRequestSub

    '-----------------------------------------------------------------
    ' Create the data string.
    '-----------------------------------------------------------------
    DNName = "CN="  & document.CertRequest.CN.value & _
         ",OU=" & document.CertRequest.OU.value & _
         ",O="  & document.CertRequest.O.value  & _
         ",L="  & document.CertRequest.L.value  & _
         ",S="  & document.CertRequest.S.value  & _
         ",C="  & document.CertRequest.C.value

    '-----------------------------------------------------------------
    ' Create the PKCS10 message and put the keys in HKEY_CURRENT_USER 
    ' on Local Machine.
    '-----------------------------------------------------------------

    document.data.Request.value = _
    Enroll.CreatePKCS10(DNName, "1.3.6.1.4.1.311.2.1.21")

    '-----------------------------------------------------------------
    ' Request the certificate.
    '-----------------------------------------------------------------

    document.data.submit()

    end sub

</SCRIPT>

</HEAD>
<BODY>

<FORM NAME="data" ACTION="scripts/certhtm.dll" METHOD=POST>
    <INPUT TYPE="HIDDEN" NAME="Request">
    <INPUT TYPE="HIDDEN" NAME="Server" VALUE="keithv2\Your Name">
</FORM>

<CENTER>
<BR><BR><BR><FONT SIZE=5 COLOR=Maroon><I><B>
Certificate Enrollment
</B></I></FONT>
<HR COLOR=Maroon WIDTH=75%>
<FORM NAME="CertRequest">
<TABLE>
<CAPTION ALIGN=LEFT VALIGN=TOP> Please Enter: </CAPTION>
<!-- Collect the data. -->
<TR><TD>Your Common Name:<TD><INPUT TYPE="TEXT" SIZE=32 NAME="CN">
<TR><TD>Your Unit Name:<TD><INPUT TYPE="TEXT" SIZE=32 NAME="OU">
<TR><TD>Your Company Name:<TD><INPUT TYPE="TEXT" SIZE=32 NAME="O">
<TR><TD>Your City:<TD><INPUT TYPE="TEXT" SIZE=32 NAME="L">
<TR><TD>Your State:<TD><INPUT TYPE="TEXT" SIZE=32 NAME="S">
<TR><TD>Your Country:<TD><INPUT TYPE="TEXT" SIZE=32 NAME="C">

<!-- Run the CertRequestSub subroutine. -->

<TR><TD ALIGN=center><INPUT TYPE="BUTTON" NAME="Request" value="Request Cert" onClick="CertRequestSub" language="VBScript">

<!-- Clear the input data. -->

<TD ALIGN=center><INPUT TYPE="RESET" NAME="Reset" value="Cancel">
</TABLE> <BR>
</FORM>

<HR COLOR=Maroon WIDTH=75%>
</CENTER>

</BODY>