1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
|
<!-- --- BEGIN COPYRIGHT BLOCK ---
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Copyright (C) 2007 Red Hat, Inc.
All rights reserved.
--- END COPYRIGHT BLOCK --- -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<OBJECT
classid="clsid:127698e4-e730-4e5c-a2b1-21490a70c8a1"
CODEBASE="/ee/xenroll.dll"
id="Enroll">
</OBJECT>
<OBJECT id='g_objClassFactory' CLASSID='clsid:884e2049-217d-11da-b2a4-000e7bbb2b09'>
</OBJECT>
<title>User Certificate Request</title>
<link rel="shortcut icon" href="/ra/admin/console/img/favicon.ico" />
<link rel="stylesheet" href="/css/pki-base.css" type="text/css" />
<META http-equiv=Content-Type content="text/html; charset=UTF-8">
</head>
<body bgcolor="#FFFFFF" link="#666699" vlink="#666699" alink="#333366">
#include ( "header.vm" )
<div id="mainNavOuter">
<div id="mainNav">
<div id="mainNavInner">
</div><!-- end mainNavInner -->
</div><!-- end mainNav -->
</div><!-- end mainNavOuter -->
<div id="bar">
<div id="systembar">
<div id="systembarinner">
<div>
-
</div>
</div>
</div>
</div>
<SCRIPT LANGUAGE="JavaScript">
function encode_utf8( s )
{
return unescape( encodeURIComponent( s ) );
}
function decode_utf8( s )
{
return decodeURIComponent( escape( s ) );
}
function validate()
{
var x = document.enrollment.uid.value;
if (x == '') {
alert("uid is empty");
return false;
}
var e = document.enrollment.email.value;
if (e == '') {
alert("email is empty");
return false;
}
var cn = document.enrollment.cn.value;
if (cn == '') {
alert("Full name is empty");
return false;
}
var dn = encode_utf8("uid="+x+",e="+e+",cn="+cn);
with (document.forms[0]) {
crmfObject = crypto.generateCRMFRequest(
dn,
"regToken", "authenticator",
null,
"setCRMFRequest();",
1024, null, "rsa-dual-use");
return false;
}
}
function setCRMFRequest()
{
with (document.forms[0]) {
csr.value = crmfObject.request;
submit();
}
}
</SCRIPT>
<font size="+1" face="PrimaSans BT, Verdana, Arial, Helvetica, sans-serif">
<a href="/ee/index.cgi">RA Services</a> :
<a href="/ee/user/index.cgi">User Enrollment</a><br />
User Interface
</font><br>
<p>
This form is for user to request for an end-user certificate.
<p>
<script language=javascript>
<!--
if (navigator.appName == "Microsoft Internet Explorer") {
document.writeln('<form name="enrollment" method=post action="submit.cgi">');
} else {
document.writeln('<form name="enrollment" onSubmit="return validate();" method=post action="submit.cgi">');
}
-->
</script>
<SCRIPT LANGUAGE=VBS>
<!--
'Get OS Version, works for Vista and below only
Function GetOSVersion
dim agent
dim result
dim pos
agent = Navigator.appVersion
pos = InStr(agent,"NT 6.")
If pos > 0 Then
GetOSVersion = 6 ' Vista
Exit Function
End If
pos = InStr(agent,"NT 5.")
If pos > 0 Then
GetOSVersion = 5 ' XP etc
Exit Function
End If
' Default
GetOSVersion = 5
End Function
Sub Send_OnClick
Dim TheForm
Dim szName
Dim options
Dim osVersion
Dim result
Set TheForm = Document.enrollment
osVersion = GetOSVersion()
If osVersion <> 6 Then 'Not Vista
' Contruct the X500 distinguished name
szName = "0.9.2342.19200300.100.1.1=" & TheForm.uid.Value & ",E=" & TheForm.email.Value & ",CN=" & TheForm.cn.Value
On Error Resume Next
Enroll.HashAlgorithm = "MD5"
Enroll.KeySpec = 1
' Pick the provider that is selected
set options = TheForm.all.cryptprovider.options
index = options.selectedIndex
Enroll.providerType = options(index).value
Enroll.providerName = options(index).text
' adding 2 to "GenKeyFlags" will enable the 'High Security'
' (USER_PROTECTED) mode, which means IE will pop up a dialog
' asking what level of protection you would like to give
' the key - this varies from 'none' to 'confirm password
' every time the key is used'
Enroll.GenKeyFlags = 1 ' key PKCS12-exportable
szCertReq = Enroll.createPKCS10(szName, "1.3.6.1.5.5.7.3.2")
theError = Err.Number
On Error Goto 0
'
' If the user has cancelled things the we simply ignore whatever
' they were doing ... need to think what should be done here
'
If (szCertReq = Empty AND theError = 0) Then
Exit Sub
End If
If (szCertReq = Empty OR theError <> 0) Then
'
' There was an error in the key pair generation. The error value
' is found in the variable 'theError' which we snarfed above before
' we did the 'On Error Goto 0' which cleared it again.
'
sz = "The error '" & Hex(theError) & "' occurred." & chr(13) & chr(10) & "Your credentials could not be generated."
result = MsgBox(sz, 0, "Credentials Enrollment")
Exit Sub
End If
TheForm.csr.Value = szCertReq
' TheForm.Submit
Else 'Vista
Dim enrollment
Dim privateKey
Dim request
Dim csr
Dim objDN
'certUsage is "1.3.6.1.5.5.7.3.2"
On Error Resume Next
'CreateObject("X509Enrollment.CX509EnrollmentWebClassFactory")
If IsObject(g_objClassFactory) = False Then
result = MsgBox("Can't create Factory Object " & " Error: " & Err.number & " :" & Err.description,0,"")
Exit Sub
End If
Set enrollment = g_objClassFactory.CreateObject("X509Enrollment.CX509Enrollment")
If IsObject(enrollment) = False Then
result = MsgBox("Can't create enroll Object! " & " Error: " & Err.number & " :" & Err.description,"")
Exit Sub
End If
Set privateKey = g_objClassFactory.CreateObject("X509Enrollment.CX509PrivateKey")
If IsObject(privateKey) = False Then
result = MsgBox("Can't create Key Object! " & " Error: " & Err.number & " :" & Err.description,0,"")
Exit Sub
End If
Set request = g_objClassFactory.CreateObject("X509Enrollment.CX509CertificateRequestPkcs10")
If IsObject(request) = False Then
result = MsgBox("Can't create Request Object. ! " & " Error: " & Err.number & " :" & Err.description,0,"")
Exit Sub
End If
privateKey.KeySpec= "1"
' Pick the provider that is selected
set options = TheForm.all.cryptprovider.options
index = options.selectedIndex
privateKey.ProviderType= index
privateKey.ProviderName = options(index).text
szName = "0.9.2342.19200300.100.1.1=" & TheForm.uid.Value & ",E=" & TheForm.email.Value & ",CN=" & TheForm.cn.Value
Set objDN = g_objClassFactory.CreateObject("X509Enrollment.CX500DistinguishedName")
If IsObject(objDN) = False Then
result = MsgBox("Can't create DN Object. ! " & " Error: " & Err.number & " :" & Err.description,0,"")
Exit Sub
End If
objDN.Encode szName,0
request.InitializeFromPrivateKey 1,privateKey,""
request.Subject = objDN
enrollment.InitializeFromRequest(request)
csr=enrollment.CreateRequest(1)
If len(csr) = 0 Then
result = MsgBox("Error Creating Request! "& " Error: " & Err.number & " :" & Err.description,0,"")
Exit Sub
End If
TheForm.csr.Value = csr
End If
Exit Sub
End Sub
-->
</SCRIPT>
<center>
<table border="0" cellspacing="1" cellpadding="1">
<tr>
<td>UID:</td>
<td><input type=text name=uid value=""></td>
</tr>
<tr>
<td>Full Name:</td>
<td><input type=text name=cn value=""></td>
</tr>
<tr>
<td>Site ID:</td>
<td><input type=text name=site_id value=""></td>
</tr>
<tr>
<td>Your Email:</td>
<td><input type=text name=email value=""></td>
</tr>
<tr>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<script language=javascript>
<!--
if (navigator.appName == "Microsoft Internet Explorer") {
document.writeln('<SELECT NAME=\"cryptprovider\"></SELECT>');
}
-->
</script>
<tr>
<td>
<script language=javascript>
<!--
if (navigator.appName == "Microsoft Internet Explorer") {
document.writeln('<input type=hidden name=csr_type value="pkcs10">');
document.writeln('<input type=submit Name=Send value="Submit">');
} else {
document.writeln('<input type=hidden name=csr_type value="crmf">');
document.writeln('<input type=submit name=Submit value="Submit">');
}
-->
</script>
</td>
<td></td>
</tr>
</table>
</center>
<input type=hidden name="csr" value="">
<SCRIPT LANGUAGE=VBS>
<!--
FindProviders
Function FindProviders
Dim i, j
Dim providers()
i = 0
j = 1
Dim el
Dim temp
Dim first
Dim TheForm
Set TheForm = document.enrollment
On Error Resume Next
first = 0
Dim osVersion
Dim result
osVersion = GetOSVersion()
If osVersion <> 6 Then 'Not Vista
Do While True
temp = ""
Enroll.providerType = j
temp = Enroll.enumProviders(i,0)
If Len(temp) = 0 Then
If j < 1 Then
j = j + 1
i = 0
Else
Exit Do
End If
Else
set el = document.createElement("OPTION")
el.text = temp
el.value = j
If temp = "Microsoft Base Cryptographic Provider v1.0" Then
first = i
End If
TheForm.cryptprovider.add(el)
If first = 0 Then
first = 1
TheForm.cryptprovider.selectedIndex = 0
Else
TheForm.cryptprovider.selectedIndex = first
End If
i = i + 1
End If
Loop
Else 'Vista
Dim csps
Set csps = g_objClassFactory.CreateObject("X509Enrollment.CCspInformations")
If IsObject(csps) = False Then
result = MsgBox("Can't create CSP List Object! " & " Error: " & Err.number & " :" & Err.description,0,"")
Exit Function
End If
csps.AddAvailableCsps()
'result = MsgBox(csps.Count,0,"Number of CSPS")
Dim curName
Dim csp
Dim selected
selected = 0
For i = 0 to csps.Count-1
curName = csps.ItemByIndex(i).Name
If len(curName) > 0 Then
Set csp = document.createElement("OPTION")
csp.text = curName
csp.value = 1
TheForm.cryptprovider.add(csp)
If curName = "Microsoft Base Cryptographic Provider v1.0" Then
selected = i
End If
'result = MsgBox(curName,0,"")
End If
Next
TheForm.cryptprovider.selectedIndex = selected
End If
End Function
-->
</SCRIPT>
</form>
#include ( "footer.vm" )
</body>
</html>
|