HTML的需要嵌入
IE微软的Object
<OBJECT
classid="clsid:127698e4-e730-4e5c-a2b1-21490a70c8a1"
CODEBASE="../xenroll.dll"
id=Enroll
>
</OBJECT>
CHROME
<KEYGEN TYPE="hidden" NAME="KeyAndChallenge" VALUE="">
Sub CertRequestSub
Dim theForm
Set theForm = document.forms(0)
DN = ""
'校验“国家”字段
If theForm.Country.value <> Empty then
If Len(theForm.Country.value) = 2 then
DN = DN & "C=" & theForm.Country.value
Else
result = MsgBox("You must use the two character country code")
Exit Sub
End If
Else
result = MsgBox("You must supply a two character country code")
Exit Sub
End If
'校验“省”字段
If theForm.State.value <> Empty then
If Len(theForm.State.Value) > 2 then
DN = DN & ";S=" & theForm.State.value
Else
result = MsgBox("The State must be greater than 2 characters")
Exit Sub
End If
Else
result = MsgBox("You must supply a state name")
Exit Sub
End if
'校验“城市”字段
If theForm.Locality.value <> Empty then
DN = DN & ";L=" & theForm.Locality.value
End If
'校验“公司”字段
If theForm.Org.value <> Empty then
DN = DN & ";O=" & theForm.Org.value
Else
result = MsgBox("You must supply an Org name")
Exit sub
End If
If theForm.OrgUnit.value <> Empty then
DN = DN & ";OU=" & theForm.OrgUnit.value
End If
'校验“名字”字段
If theForm.CommonName.value <> Empty then
DN = DN & ";CN=" & theForm.CommonName.value
Else
result = MsgBox("You must supply a Common Name")
Exit sub
End If
'校验“Email”字段
If ((theForm.DNEMail.value <> Empty) AND (InStr(theForm.DNEMail.value, "@") <> 0)) then
DN = DN & ";E=" & theForm.DNEMail.value
Else
result = MsgBox("You must supply an E-Mail address component")
Exit Sub
End If
If theForm.KeyExportable.checked Then
theForm.Enroll.GenKeyFlags = 1
Else
theForm.Enroll.GenKeyFlags = 0
End If
If theForm.IEKeyLength.value = "512" Then
theForm.Enroll.GenKeyFlags = CLng(theForm.Enroll.GenKeyFlags) + CLng("33554432")
ElseIf theForm.IEKeyLength.value = "1024" Then
theForm.Enroll.GenKeyFlags = CLng(theForm.Enroll.GenKeyFlags) + CLng("67108864")
ElseIf theForm.IEKeyLength.value = "2048" Then
theForm.Enroll.GenKeyFlags = CLng(theForm.Enroll.GenKeyFlags) + CLng("134217728")
Else
result = MsgBox("Unexpected key-length: " & request.IEKeyLength.value)
Exit Sub
End If
dim x
for x = 0 to theForm.Elements.Length-1
if theForm.Elements(x).Name = "HashType" then
if theForm.Elements(x).Checked then
value = theForm.Elements(x).Value
Exit For
End If
End If
Next
theForm.Enroll.HashAlgorithm = value
theForm.Enroll.KeySpec = 1
theForm.Certificate.value = theForm.Enroll.CreatePKCS10(DN, "1.3.6.1.5.5.7.3.2")
theError = Err.Number
if (theForm.Certificate.value = Empty OR theError <> 0) Then
sz = "The error '" & theError & "' occurred." & chr(13) & chr(10) & _
"Your credentials could not be generated."
result = MsgBox(sz, 0, "Credentials Enrollment")
Exit Sub
end if
theForm.Submit
Exit Sub
End Sub