Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

795 lines
30 KiB

  1. <%@ CODEPAGE=65001 'UTF-8%>
  2. <%' certrqbi.asp - (CERT)srv web - (R)e(Q)uest, (B)asic (I)nformation
  3. ' Copyright (C) Microsoft Corporation, 1998 - 1999 %>
  4. <!-- #include FILE=certsbrt.inc -->
  5. <!-- #include FILE=certdat.inc -->
  6. <!-- #include FILE=certrqtp.inc -->
  7. <%
  8. ' Strings To Be Localized
  9. Const L_MoreOptions_Message="Click to show more options."
  10. %>
  11. <HTML>
  12. <Head>
  13. <Meta HTTP-Equiv="Content-Type" Content="text/html; charset=UTF-8">
  14. <Title>Microsoft Certificate Services</Title>
  15. </Head>
  16. <Body BgColor=#FFFFFF Link=#0000FF VLink=#0000FF ALink=#0000FF <%If "IE"=sBrowser Then%> OnLoad="postLoad();" <%End If%>><Font ID=locPageFont Face="Arial">
  17. <Table Border=0 CellSpacing=0 CellPadding=4 Width=100% BgColor=#008080>
  18. <TR>
  19. <TD><Font Color=#FFFFFF><LocID ID=locMSCertSrv><Font Face="Arial" Size=-1><B><I>Microsoft</I></B> Certificate Services &nbsp;--&nbsp; <%=sServerDisplayName%> &nbsp;</Font></LocID></Font></TD>
  20. <TD ID=locHomeAlign Align=Right><A Href="/certsrv"><Font Color=#FFFFFF><LocID ID=locHomeLink><Font Face="Arial" Size=-1><B>Home</B></Font></LocID></Font></A></TD>
  21. </TR>
  22. </Table>
  23. <Form Name=UIForm OnSubmit="goNext();return false;" Action="certlynx.asp" Method=Post>
  24. <Input Type=Hidden Name=SourcePage Value="certrqbi">
  25. <P ID=locPageTitle> <B> <%=rgAvailReqTypes(CInt(Request.QueryString("type")), FIELD_FRIENDLYNAME)%> - Identifying Information </B>
  26. <!-- Green HR --><Table Border=0 CellSpacing=0 CellPadding=0 Width=100%><TR><TD BgColor=#008080><Img Src="certspc.gif" Alt="" Height=2 Width=1></TD></TR></Table>
  27. <%If "IE"=sBrowser Then%>
  28. <Span ID=spnFixTxt Style="display:none">
  29. <Table Border=0 CellSpacing=0 CellPadding=4 Style="Color:#FF0000"><TR><TD><LocID ID=locBadCharError>
  30. <I>Please correct the fields marked in <B>RED</B>.</I>
  31. The name field may not be blank.
  32. The e-mail address may contain the characters A-Z, a-z, 0-9, and some common symbols, but no extended characters.
  33. The country/region field must be a two letter ISO 3166 country/region code.
  34. </LocID></TD></TR></Table>
  35. </Span>
  36. <Span ID=spnErrorTxt Style="display:none">
  37. <Table Border=0 CellSpacing=0 CellPadding=4 Style="Color:#FF0000">
  38. <TR><TD><LocID ID=locErrMsgBasic>
  39. <B>An error occurred</B> while creating the certificate request.
  40. Please verify that you selected the correct CSP, or contact
  41. an administrator for assistance.
  42. </LocID></TD></TR><TR><TD><Span ID=spnErrorDetailsBtn>
  43. <Table Border=0 CellSpacing=0 CellPadding=0>
  44. <TR> <TD Width=20></TD><TD>
  45. <Input ID=locBtnDetails Type=Button Value="Details &gt;&gt;" OnClick="showErrorDetails();blur();">
  46. </TD></TR>
  47. </Table>
  48. </Span></TD></TR><TR><TD><Span ID=spnErrorDetails1 Style="display:none">
  49. <LocID ID=locErrorCause><B>Suggested cause:</B></LocID><BR>
  50. <Span ID=spnErrorMsg></Span>
  51. </Span></TD></TR><TR>
  52. <TD><Span ID=spnErrorDetails2 Style="display:none"><LocID ID=locErrorNumber><Font Size=-2>Error: <Span ID=spnErrorNum></Span></Font></LocID></Span></TD>
  53. </TR>
  54. </Table>
  55. </Span>
  56. <%End If%>
  57. <P>
  58. <Table Border=0 CellSpacing=0 CellPadding=0>
  59. <TR> <!-- establish column widths. -->
  60. <TD Height=4 Width=<%=L_LabelColWidth_Number%>></TD> <!-- label column, top border -->
  61. <TD RowSpan=50 Width=4></TD> <!-- label spacing column -->
  62. <TD></TD> <!-- field column -->
  63. </TR>
  64. <!-- <TR><TD ColSpan=3 Height=15></TD></TR>-->
  65. <%If "StandAlone"=sServerType Then%>
  66. <TR>
  67. <TD ColSpan=3><LocID ID=locInstructions><Font Face="Arial">
  68. To complete your certificate, type the requested information in the following boxes.</Font></LocID></TD>
  69. </TR>
  70. <TR><TD ColSpan=3 Height=4></TD></TR>
  71. <TR>
  72. <TD ID=locNameAlign Align=Right><Span ID=spnNameLabel><LocID ID=locNameLabel><Font Face="Arial" Size=-1>Name:</Font></LocID></Span></TD>
  73. <TD><Input ID=locTbCommonName Type=Text MaxLength=64 Size=42 Name=tbCommonName></TD>
  74. </TR><TR>
  75. <TD ID=locEmailAlign Align=Right><Span ID=spnEmailLabel><LocID ID=locEmailLabel><Font Face="Arial" Size=-1>E-Mail:</Font></LocID></Span></TD>
  76. <TD><Input ID=locTbEmail Type=Text MaxLength=128 Size=42 Name=tbEmail></TD>
  77. </TR><TR>
  78. <TD Height=8></TD> <TD></TD>
  79. </TR><TR>
  80. <TD ID=locCompanyAlign Align=Right><Span ID=spnCompanyLabel><LocID ID=locOrgLabel><Font Face="Arial" Size=-1>Company:</Font></LocID></Span></TD>
  81. <TD><Input ID=locTbOrg Type=Text MaxLength=64 Size=42 Name=tbOrg Value="<%=sDefaultCompany%>"></TD>
  82. </TR><TR>
  83. <TD ID=locDepartmentAlign Align=Right><Span ID=spnDepartmentLabel><LocID ID=locOrgUnitLabel><Font Face="Arial" Size=-1>Department:</Font></LocID></Span></TD>
  84. <TD><Input ID=locTbOrgUnit Type=Text MaxLength=64 Size=42 Name=tbOrgUnit Value="<%=sDefaultOrgUnit%>"></TD>
  85. </TR><TR>
  86. <TD Height=8></TD> <TD></TD>
  87. </TR><TR>
  88. <TD ID=locCityAlign Align=Right><Span ID=spnCityLabel><LocID ID=locLocalityLabel><Font Face="Arial" Size=-1>City:</Font></LocID></Span></TD>
  89. <TD><Input ID=locTbLocality Type=Text MaxLength=128 Size=42 Name=tbLocality Value="<%=sDefaultLocality%>"></TD>
  90. </TR><TR>
  91. <TD ID=locStateAlign Align=Right><Span ID=spnStateLabel><LocID ID=locStateLabel><Font Face="Arial" Size=-1>State:</Font></LocID></Span></TD>
  92. <TD><Input ID=locTbState Type=Text MaxLength=128 Size=42 Name=tbState Value="<%=sDefaultState%>"></TD>
  93. </TR><TR>
  94. <TD ID=locCountryAlign Align=Right><Span ID=spnCountryLabel><LocID ID=locCountryLabel><Font Face="Arial" Size=-1>Country/Region:</Font></LocID></Span></TD>
  95. <TD><Input ID=locTbCountry Type=Text MaxLength=2 Size=2 Name=tbCountry Value="<%=sDefaultCountry%>"></TD>
  96. </TR>
  97. <%Else%>
  98. <TR>
  99. <TD ID=locReadyToGo ColSpan=3><Font Face="Arial">
  100. No further identifying information is required.
  101. <%If "IE"=sBrowser Then%><LocID ID=locReadyToGo2>To complete your certificate, press submit.</LocID><%End If%></Font></TD>
  102. </TR>
  103. <%End If%>
  104. <%If "IE"=sBrowser Then%>
  105. <TR ID=trMoreOptHide><TD Height=12></TD><TD></TD></TR>
  106. <TR ID=trMoreOptHide>
  107. <TD><Font Size=-1><Span ID=spnShowMoreOptions tabindex=0 Style="cursor:hand; color:#0000FF; text-decoration:underline;"
  108. OnContextMenu="return false;"
  109. OnMouseOver="window.status='<%=L_MoreOptions_Message%>'; return true;"
  110. OnMouseOut="window.status=''; return true;"
  111. OnKeyDown="if (13==event.keyCode) {showMoreOptions();return false;} else if (9==event.keyCode) {return true;};return false;"
  112. OnClick="showMoreOptions();return false;">
  113. <LocID ID=locMoreOpt>More Options &gt;&gt;</LocID></Span></Font>
  114. </TD>
  115. <TD></TD>
  116. </TR>
  117. <!-- More options -->
  118. <TR ID=trMoreOptShow Style="display:none">
  119. <TD ID=locMoreOptHead ColSpan=3><Font Size=-1><BR><B>More Options:</B></Font></TD>
  120. </TR>
  121. <TR ID=trMoreOptShow Style="display:none"><TD ColSpan=3 Height=2 BgColor=#008080></TD></TR>
  122. <TR ID=trMoreOptShow Style="display:none"><TD ColSpan=3 Height=3></TD></TR>
  123. <TR ID=trMoreOptShow Style="display:none">
  124. <TD ColSpan=3><Font Face="Arial"><Label For=lbCSPID><LocID ID=locCSPInstr>
  125. Select a Cryptographic Service Provider:</LocID><Label></Font></TD>
  126. </TR>
  127. <TR ID=trMoreOptShow Style="display:none"><TD Height=4></TD> <TD></TD></TR>
  128. <TR ID=trMoreOptShow Style="display:none">
  129. <TD ID=locCSPLabel Align=Right><Font Size=-1>CSP:</Font></TD>
  130. <TD><Select Name=lbCSP ID=lbCSPID>
  131. <Option ID=locLoading>Loading...</Option>
  132. </Select>
  133. </TD>
  134. </TR>
  135. <TR ID=trMoreOptShow Style="display:none"><TD Height=8></TD> <TD></TD></TR>
  136. <TR ID=trMoreOptShow Style="display:none">
  137. <TD></TD>
  138. <TD>
  139. <Table Border=0 CellSpacing=0 CellPadding=0><TR>
  140. <TD><Input Type=Checkbox ID=cbStrongKey Name=cbStrongKey></TD>
  141. <TD><Font Size=-1><Label For=cbStrongKey ID=locStrongKeyLabel>Enable strong private key protection</Label></Font></TD>
  142. </TR></Table>
  143. </TD>
  144. </TR>
  145. <TR ID=trMoreOptShow Style="display:none"><TD Height=8></TD> <TD></TD></TR>
  146. <TR ID=trMoreOptShow Style="display:none">
  147. <TD ID=locRequestFormatLabel Align=Right><LocID ID=locRequestFormat><Font Size=-1>Request Format:</Font></LocID></TD>
  148. <TD>
  149. <Input Type=Radio ID=rbFormatPKCS10 Name=rbRequestFormat Value="0" Checked><Label For=rbFormatPKCS10 ID=locFormatPKCS10Label>CMC</Label>
  150. <LocID ID=locSpc5>&nbsp;&nbsp;&nbsp;<LocID>
  151. <Input Type=Radio ID=rbFormatCMC Name=rbRequestFormat Value="1"><Label For=rbFormatCMC ID=locFormatCMCLabel>PKCS10</Label>
  152. </TD>
  153. </TR>
  154. <TR ID=trMoreOptShow Style="display:none">
  155. <TD ColSpan=3><LocID ID=locAdvancedLink><Font Face="Arial" Size=-1><BR>
  156. If you need to use an advanced option that is not listed here,
  157. <A Href="certrqma.asp">use the Advanced Certificate Request form</A>.</Font></LocID></TD>
  158. </TR>
  159. <!-- end More options -->
  160. <%Else '"NN"=sBrowser%>
  161. </Form>
  162. <Form Name=SubmittedData Action="certfnsh.asp" OnSubmit="return goNext();" Method=Post>
  163. <Input Type=Hidden Name=Mode> <!-- used in request ('newreq'|'chkpnd') -->
  164. <!--<Input Type=Hidden Name=CertRequest>--> <!-- used in request -->
  165. <Input Type=Hidden Name=CertAttrib> <!-- used in request -->
  166. <Input Type=Hidden Name=FriendlyType> <!-- used on pending -->
  167. <Input Type=Hidden Name=ThumbPrint> <!-- used on pending -->
  168. <Input Type=Hidden Name=TargetStoreFlags> <!-- used on install ('0'|CSSLM)-->
  169. <Input Type=Hidden Name=SaveCert> <!-- used on install ('no'|'yes')-->
  170. <TR><TD ColSpan=3 Height=18></TD></TR>
  171. <TR>
  172. <TD ID=locStrengthInst ColSpan=3><Font Face="Arial">
  173. Please select a key strength:</Font></TD>
  174. </TR>
  175. <TR><TD ColSpan=3 Height=3></TD></TR>
  176. <TR>
  177. <TD ID=locStrengthLabel Align=Right><Font Face="Arial" Size=-1>Key Strength:</Font></TD>
  178. <TD><KeyGen Name=CertRequest Challenge="provePequalsNP"></TD>
  179. </TR>
  180. <%End If%>
  181. <TR><TD ColSpan=3><Font Size=-1><BR></Font></TD></TR>
  182. <TR><TD ColSpan=3 Height=2 BgColor=#008080><Img Src="certspc.gif" Alt="" Height=2 Width=1></TD></TR>
  183. <TR><TD ColSpan=3 Height=3></TD></TR>
  184. <TR><TD></TD>
  185. <TD ID=locSubmitAlign Align=Right>
  186. <Input ID=locBtnSubmit Type=Submit Name=btnSubmit Value="Submit &gt;" <%If "IE"=sBrowser Then%> Style="width:.75in"<%End If%>>
  187. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  188. </TD></TR>
  189. <TR><TD ColSpan=3 Height=40></TD></TR>
  190. </Table>
  191. <!-- Green HR --><Table Border=0 CellSpacing=0 CellPadding=0 Width=100%><TR><TD BgColor=#008080><Img Src="certspc.gif" Alt="" Height=2 Width=1></TD></TR></Table>
  192. <!-- White HR --><Table Border=0 CellSpacing=0 CellPadding=0 Width=100%><TR><TD BgColor=#FFFFFF><Img Src="certspc.gif" Alt="" Height=5 Width=1></TD></TR></Table>
  193. </Form>
  194. </Font>
  195. <!-- ############################################################ -->
  196. <!-- End of standard text. Scripts follow -->
  197. <%bIncludeXEnroll=True%>
  198. <%bIncludeGetCspList=True%>
  199. <%bIncludeTemplateCode=True%>
  200. <%bIncludeCheckClientCode=True%>
  201. <!-- #include FILE=certsgcl.inc -->
  202. <%If "IE"=sBrowser Then%>
  203. <!-- IE SPECIFIC: This form we fill in and submit 'by hand'. NN does it differently. -->
  204. <Form Name=SubmittedData Action="certfnsh.asp" Method=Post>
  205. <Input Type=Hidden Name=Mode> <!-- used in request ('newreq'|'chkpnd') -->
  206. <Input Type=Hidden Name=CertRequest> <!-- used in request -->
  207. <Input Type=Hidden Name=CertAttrib> <!-- used in request -->
  208. <Input Type=Hidden Name=FriendlyType> <!-- used on pending -->
  209. <Input Type=Hidden Name=ThumbPrint> <!-- used on pending -->
  210. <Input Type=Hidden Name=TargetStoreFlags> <!-- used on install ('0'|CSSLM)-->
  211. <Input Type=Hidden Name=SaveCert> <!-- used on install ('no'|'yes')-->
  212. </FORM>
  213. <%End If%>
  214. <Script Language="JavaScript">
  215. //================================================================
  216. // PAGE GLOBAL VARIABLES
  217. //----------------------------------------------------------------
  218. // Strings to be localized
  219. var L_StillLoading_ErrorMessage="This page has not finished loading yet. Please wait a few seconds and try again.";
  220. var L_Generating_Message="Generating request...";
  221. <%If "IE"=sBrowser Then%>
  222. ;
  223. var L_CspLoadErrNoneFound_ErrorMessage="An unexpected error occurred while getting the CSP list:\nNo CSPs could be found!";
  224. var L_CspLoadErrUnexpected_ErrorMessage="\"An unexpected error (\"+sErrorNumber+\") occurred while getting the CSP list.\"";
  225. var L_Waiting_Message="Waiting for server response...";
  226. var L_ErrNameUnknown_ErrorMessage="(unknown)";
  227. var L_SugCauseNone_ErrorMessage="No suggestion.";
  228. var L_SugCauseBadCSP_ErrorMessage="The CSP you chose was unable to process the request. Try a different CSP.";
  229. var L_SugCauseKeysetFull_ErrorMessage="The security token does not have storage space available for an additional container.";
  230. var L_SugCauseBadSetting_ErrorMessage="The CSP you chose does not support one or more of the settings you have made. Try using different settings or a different CSP.";
  231. var L_SugCauseBadChar_ErrorMessage="You entered an invalid character. Report a bug, because this should have been caught in validation.";
  232. var L_SugCauseNoProfile_ErrorMessage="The profile for the user is a temporary profile.";
  233. var L_SugCauseCancelled_ErrorMessage="The operation was canceled by the user.";
  234. <%Else%>
  235. ;
  236. var L_BadChars_ErrorMessage="The name field may not be blank. The e-mail address may contain the characters A-Z, a-z, 0-9, and some common symbols, but no extended characters. The country/region field must be a two letter ISO 3166 country/region code.";
  237. <%End If%>
  238. <%If "IE"=sBrowser Then%>
  239. // IE is not ready until XEnroll has been loaded
  240. var g_bOkToSubmit=false;
  241. <%Else%>
  242. // We start with this variable true since it doesn't do anything
  243. // for Netscape anyway.
  244. var g_bOkToSubmit=true;
  245. <%End If%>
  246. var g_bSubmitPending=false;
  247. <%If "IE"=sBrowser Then%>
  248. //================================================================
  249. // INITIALIZATION ROUTINES
  250. //----------------------------------------------------------------
  251. // IE SPECIFIC:
  252. // This contains the functions we want executed immediately after load completes
  253. function postLoad() {
  254. // Load an XEnroll object into the page
  255. loadXEnroll("postLoadPhase2()");
  256. handleCMCFormat();
  257. }
  258. function postLoadPhase2() {
  259. // continued from above
  260. var nResult;
  261. var sCSPList ="<%=rgAvailReqTypes(CInt(Request.QueryString("type")), FIELD_CSPLIST)%>";
  262. <%If "Enterprise"=sServerType Then%>
  263. var sUserAgent=navigator.userAgent;
  264. if (-1 == sUserAgent.indexOf("Windows NT 5.1"))
  265. {
  266. var sCSPList ="<%=rgAvailReqTypes(CInt(Request.QueryString("type")), FIELD_CSPLIST2)%>";
  267. }
  268. <%End If%>
  269. if ("" != sCSPList)
  270. {
  271. // get csp from template
  272. updateCSPListFromStrings(sCSPList);
  273. nResult = 0;
  274. }
  275. else
  276. {
  277. // get the CSP list from local xenroll
  278. nResult=GetCSPList();
  279. }
  280. if (0!=nResult) {
  281. handleLoadError(nResult, L_CspLoadErrNoneFound_ErrorMessage, L_CspLoadErrUnexpected_ErrorMessage);
  282. return;
  283. }
  284. // Now we're ready to go
  285. g_bOkToSubmit=true;
  286. }
  287. //----------------------------------------------------------------
  288. // IE SPECIFIC: handle errors from GetCSPList() and GetTemplateList()
  289. function handleLoadError(nResult, sNoneFound, sUnexpected) {
  290. if (-1==nResult) {
  291. alert(sNoneFound);
  292. } else {
  293. var sErrorNumber="0x"+toHex(nResult);
  294. alert(eval(sUnexpected));
  295. }
  296. disableAllControls();
  297. }
  298. //================================================================
  299. // PAGE MANAGEMENT ROUTINES
  300. //----------------------------------------------------------------
  301. // IE SPECIFIC: morph method for the error details drop-down
  302. function showErrorDetails() {
  303. spnErrorDetailsBtn.style.display='none';
  304. spnErrorDetails1.style.display='';
  305. spnErrorDetails2.style.display='';
  306. }
  307. //----------------------------------------------------------------
  308. // IE SPECIFIC: morph method for the "more options" drop down
  309. function showMoreOptions() {
  310. var nIndex;
  311. for (nIndex=0; nIndex<trMoreOptHide.length; nIndex++) { //>
  312. trMoreOptHide[nIndex].style.display='none';
  313. }
  314. for (nIndex=0; nIndex<trMoreOptShow.length; nIndex++) { //>
  315. trMoreOptShow[nIndex].style.display='';
  316. }
  317. }
  318. //----------------------------------------------------------------
  319. // handle CMC Format
  320. function handleCMCFormat() {
  321. if (!isClientAbleToCreateCMC())
  322. {
  323. //no cmc, disable it, only pkcs10
  324. document.UIForm.rbRequestFormat[0].disabled=true;
  325. document.UIForm.rbRequestFormat[1].disabled=true;
  326. document.UIForm.rbRequestFormat[1].checked=true;
  327. }
  328. }
  329. <%End If%>
  330. //================================================================
  331. // SUBMIT ROUTINES
  332. //----------------------------------------------------------------
  333. // determine what to do when the submit button is pressed
  334. function goNext() {
  335. if (false==g_bOkToSubmit) {
  336. alert(L_StillLoading_ErrorMessage);
  337. return false;
  338. } else if (true==g_bSubmitPending) {
  339. // ignore this, as there is UI already.
  340. return false;
  341. } else {
  342. return SubmitRequest();
  343. }
  344. }
  345. <%If "StandAlone"=sServerType Then%>
  346. //----------------------------------------------------------------
  347. // check for invalid characters
  348. var gc_IA5Chars=" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKMLNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"
  349. function isValidIA5String(sSource) {
  350. var nIndex;
  351. for (nIndex=sSource.length-1; nIndex>=0; nIndex--) {
  352. //if (sSource.charCodeAt(nIndex)>127) { // NOTE: this is better, but not compatible with old browsers.
  353. if (-1==gc_IA5Chars.indexOf(sSource.charAt(nIndex))) {
  354. return false;
  355. }
  356. };
  357. return true;
  358. }
  359. //----------------------------------------------------------------
  360. // check for invalid characters
  361. function isValidCountryField(tbCountry) {
  362. tbCountry.value=tbCountry.value.toUpperCase();
  363. var sSource=tbCountry.value;
  364. var nIndex, ch;
  365. if (0!=sSource.length && 2!=sSource.length) {
  366. return false;
  367. }
  368. for (nIndex=sSource.length-1; nIndex>=0; nIndex--) {
  369. ch=sSource.charAt(nIndex)
  370. if (ch<"A" || ch>"Z") {
  371. return false;
  372. }
  373. };
  374. return true;
  375. }
  376. //----------------------------------------------------------------
  377. // set a label to normal style
  378. function markLabelNormal(spn) {
  379. <%If "IE"=sBrowser Then%>
  380. spn.style.color="#000000";
  381. spn.style.fontWeight='normal';
  382. <%End If%>
  383. }
  384. //----------------------------------------------------------------
  385. // set a label to error state
  386. function markLabelError(spn) {
  387. <%If "IE"=sBrowser Then%>
  388. spn.style.color='#FF0000';
  389. spn.style.fontWeight='bold';
  390. <%End If%>
  391. }
  392. //----------------------------------------------------------------
  393. // check that the form has data in it
  394. function validateRequest() {
  395. <%If "IE"<>sBrowser Then%>
  396. // work around for NN: label marking does nothing
  397. var spnNameLabel, spnEmailLabel, spnCompanyLabel, spnDepartmentLabel, spnCityLabel, spnStateLabel, spnCountryLabel;
  398. <%End If%>
  399. markLabelNormal(spnNameLabel);
  400. markLabelNormal(spnEmailLabel);
  401. markLabelNormal(spnCompanyLabel);
  402. markLabelNormal(spnDepartmentLabel);
  403. markLabelNormal(spnCityLabel);
  404. markLabelNormal(spnStateLabel);
  405. markLabelNormal(spnCountryLabel);
  406. var bOK=true;
  407. var fldFocusMe=null;
  408. // check in 'reverse' order so that focus gets set to last item
  409. // don't set focus immediately because we'd get funny scrolling effects.
  410. if (false==isValidCountryField(document.UIForm.tbCountry)) {
  411. bOK=false;
  412. fldFocusMe=document.UIForm.tbCountry;
  413. markLabelError(spnCountryLabel);
  414. }
  415. // document.UIForm.tbState.value OK
  416. // document.UIForm.tbLocality.value OK
  417. // document.UIForm.tbOrgUnit.value OK
  418. // document.UIForm.tbOrg.value OK
  419. if (false==isValidIA5String(document.UIForm.tbEmail.value)
  420. <%If "1.3.6.1.5.5.7.3.4"=rgAvailReqTypes(CInt(Request.QueryString("type")), FIELD_OID) Then 'e-mail Protection%>
  421. || ""==document.UIForm.tbEmail.value
  422. <%End If%>
  423. ) {
  424. bOK=false;
  425. fldFocusMe=document.UIForm.tbEmail;
  426. markLabelError(spnEmailLabel);
  427. }
  428. if (""==document.UIForm.tbCommonName.value) {
  429. bOK=false;
  430. fldFocusMe=document.UIForm.tbCommonName;
  431. markLabelError(spnNameLabel);
  432. }
  433. if (false==bOK) {
  434. <%If "IE"=sBrowser Then%>
  435. spnFixTxt.style.display='';
  436. window.scrollTo(0,0);
  437. <%Else%>
  438. alert (L_BadChars_ErrorMessage);
  439. <%End If%>
  440. fldFocusMe.focus();
  441. }
  442. return bOK;
  443. }
  444. <%End If '"StandAlone"=sServerType%>
  445. <%If "IE"=sBrowser Then%>
  446. //----------------------------------------------------------------
  447. // IE SPECIFIC:
  448. function SubmitRequest() {
  449. g_bSubmitPending=true;
  450. spnErrorTxt.style.display='none';
  451. spnFixTxt.style.display='none';
  452. <%If "StandAlone"=sServerType Then%>
  453. // check that the form is filled in
  454. if (false==validateRequest()) {
  455. g_bSubmitPending=false;
  456. return;
  457. }
  458. <%End If%>
  459. // show a nice message since request creation can take a while
  460. ShowTransientMessage(L_Generating_Message);
  461. // Make the message show up on the screen,
  462. // then continue with 'SubmitRequest':
  463. // Pause 1 mS before executing phase 2,
  464. // so screen will have time to repaint.
  465. setTimeout("SubmitRequestPhase2();", 10);
  466. }
  467. function SubmitRequestPhase2() {
  468. // continued from above
  469. // some constants defined in wincrypt.h: (line ~234)
  470. var CRYPT_EXPORTABLE=1;
  471. var CRYPT_USER_PROTECTED=2;
  472. var AT_KEYEXCHANGE=1;
  473. var AT_SIGNATURE=2;
  474. var PROV_DSS=3;
  475. var PROV_DSS_DH=13;
  476. var XECR_PKCS10_V2_0=1;
  477. var XECR_CMC=3;
  478. <%If "StandAlone"=sServerType Then%>
  479. // set the identifying info
  480. var sDistinguishedName=""
  481. if (""!=document.UIForm.tbCountry.value) {
  482. sDistinguishedName+="C=\""+document.UIForm.tbCountry.value.replace(/"/g, "\"\"") +"\";";
  483. }
  484. if (""!=document.UIForm.tbState.value) {
  485. sDistinguishedName+="S=\""+document.UIForm.tbState.value.replace(/"/g, "\"\"") +"\";";
  486. }
  487. if (""!=document.UIForm.tbLocality.value) {
  488. sDistinguishedName+="L=\""+document.UIForm.tbLocality.value.replace(/"/g, "\"\"") +"\";";
  489. }
  490. if (""!=document.UIForm.tbOrg.value) {
  491. sDistinguishedName+="O=\""+document.UIForm.tbOrg.value.replace(/"/g, "\"\"") +"\";";
  492. }
  493. if (""!=document.UIForm.tbOrgUnit.value) {
  494. sDistinguishedName+="OU=\""+document.UIForm.tbOrgUnit.value.replace(/"/g, "\"\"") +"\";";
  495. }
  496. if (""!=document.UIForm.tbEmail.value) {
  497. sDistinguishedName+="E=\""+document.UIForm.tbEmail.value.replace(/"/g, "\"\"") +"\";";
  498. }
  499. if (""!=document.UIForm.tbCommonName.value) {
  500. sDistinguishedName+="CN=\""+document.UIForm.tbCommonName.value.replace(/"/g, "\"\"")+"\";";
  501. }
  502. <%Else%>
  503. // the distinguished name is not used for enterprise CAs
  504. var sDistinguishedName="";
  505. <%End If%>
  506. // set defaults for values we need on install
  507. document.SubmittedData.CertAttrib.value="UserAgent:<%=Request.ServerVariables("HTTP_USER_AGENT")%>\r\n";
  508. document.SubmittedData.TargetStoreFlags.value=0; // 0=Use default (=user store)
  509. document.SubmittedData.SaveCert.value="no";
  510. document.SubmittedData.Mode.value="newreq";
  511. document.SubmittedData.FriendlyType.value="<%=rgAvailReqTypes(CInt(Request.QueryString("type")), FIELD_FRIENDLYNAME)%>";
  512. // append the local date to the type
  513. document.SubmittedData.FriendlyType.value+=" ("+(new Date()).toLocaleString()+")";
  514. <%If "StandAlone"=sServerType Then%>
  515. // set the cert type information
  516. var sCertUsage="<%=rgAvailReqTypes(CInt(Request.QueryString("type")), FIELD_OID)%>";
  517. <%Else%>
  518. // set the cert template, we know this is v1 template
  519. var XECT_EXTENSION_V1=1;
  520. XEnroll.addCertTypeToRequestEx(XECT_EXTENSION_V1, "<%=rgAvailReqTypes(CInt(Request.QueryString("type")), FIELD_TEMPLATE)%>", 0, false, 0);
  521. var sCertUsage=""; // ignored
  522. <%End If%>
  523. // set the CSP
  524. var nCSPIndex=document.UIForm.lbCSP.selectedIndex;
  525. XEnroll.ProviderName=document.UIForm.lbCSP.options[nCSPIndex].text;
  526. var nProvType=document.UIForm.lbCSP.options[nCSPIndex].value
  527. XEnroll.ProviderType=nProvType;
  528. // default to exchange keys, unless we're doing DSS which only does sig.
  529. if (PROV_DSS==nProvType || PROV_DSS_DH==nProvType) {
  530. XEnroll.KeySpec=AT_SIGNATURE;
  531. } else {
  532. XEnroll.KeySpec=AT_KEYEXCHANGE;
  533. }
  534. // set 'Strong private key protection'
  535. if (document.UIForm.cbStrongKey.checked) {
  536. XEnroll.GenKeyFlags|=CRYPT_USER_PROTECTED;
  537. }
  538. <% If "Enterprise"=sServerType Then%>
  539. if ("True"=="<%=rgAvailReqTypes(CInt(Request.QueryString("type")), FIELD_EXPORTABLE)%>")
  540. {
  541. XEnroll.GenKeyFlags|=CRYPT_EXPORTABLE;
  542. }
  543. <%End If%>
  544. // set request format
  545. lRequestFlag=XECR_CMC;
  546. if (document.UIForm.rbRequestFormat[1].checked) {
  547. lRequestFlag=XECR_PKCS10_V2_0;
  548. }
  549. // build the certificate request
  550. var nResult=CreateRequest(lRequestFlag, sDistinguishedName, sCertUsage); // ask VB to do it, since it can handle errors
  551. if (0 == nResult)
  552. {
  553. //always get thumbprint in case of pending
  554. document.SubmittedData.ThumbPrint.value=XEnroll.ThumbPrint;
  555. }
  556. // hide the message box
  557. HideTransientMessage();
  558. //see if it was cancelled
  559. if (document.UIForm.cbStrongKey.checked && (0==(0x8010006e^nResult)))
  560. {
  561. //ERROR_CANCELLED, likely from dialog, out
  562. g_bSubmitPending=false;
  563. XEnroll.reset();
  564. return;
  565. }
  566. // deal with an error if there was one
  567. if (0!=nResult) {
  568. handleError(nResult);
  569. g_bSubmitPending=false;
  570. return;
  571. }
  572. // put up a new wait message
  573. ShowTransientMessage(L_Waiting_Message);
  574. // Submit the cert request and move forward in the wizard
  575. document.SubmittedData.submit();
  576. }
  577. //----------------------------------------------------------------
  578. // IE SPECIFIC:
  579. function handleError(nResult) {
  580. var sSugCause=L_SugCauseNone_ErrorMessage;
  581. var sErrorName=L_ErrNameUnknown_ErrorMessage;
  582. // analyze the error - funny use of XOR ('^') because obvious choice '==' doesn't work
  583. if (0==(0x80090008^nResult)) {
  584. sErrorName="NTE_BAD_ALGID";
  585. sSugCause=L_SugCauseBadCSP_ErrorMessage;
  586. } else if (0==(0x80090016^nResult)) {
  587. sErrorName="NTE_BAD_KEYSET";
  588. sSugCause=L_SugCauseBadCSP_ErrorMessage;
  589. } else if (0==(0x80090019^nResult)) {
  590. sErrorName="NTE_KEYSET_NOT_DEF";
  591. sSugCause=L_SugCauseBadCSP_ErrorMessage;
  592. } else if (0==(0x80090020^nResult)) {
  593. sErrorName="NTE_FAIL";
  594. sSugCause=L_SugCauseBadCSP_ErrorMessage;
  595. } else if (0==(0x80090023^nResult)) {
  596. sErrorName="NTE_TOKEN_KEYSET_STORAGE_FULL";
  597. sSugCause=L_SugCauseKeysetFull_ErrorMessage;
  598. } else if (0==(0x80090009^nResult)) {
  599. sErrorName="NTE_BAD_FLAGS";
  600. sSugCause=L_SugCauseBadSetting_ErrorMessage;
  601. } else if (0==(0x80092002^nResult)) {
  602. sErrorName="CRYPT_E_BAD_ENCODE";
  603. //sSugCause="";
  604. } else if (0==(0x80092022^nResult)) {
  605. sErrorName="CRYPT_E_INVALID_IA5_STRING";
  606. sSugCause=L_SugCauseBadChar_ErrorMessage;
  607. } else if (0==(0x80092023^nResult)) {
  608. sErrorName="CRYPT_E_INVALID_X500_STRING";
  609. sSugCause=L_SugCauseBadChar_ErrorMessage;
  610. } else if (0==(0x80090024^nResult)) {
  611. sErrorName = "NTE_TEMPORARY_PROFILE";
  612. sSugCause = L_SugCauseNoProfile_ErrorMessage;
  613. } else if (0==(0x800704C7^nResult)) {
  614. sErrorName = "ERROR_CANCELLED";
  615. sSugCause = L_SugCauseCancelled_ErrorMessage;
  616. } else if (0==(0x8000FFFF^nResult)) {
  617. sErrorName="E_UNEXPECTED";
  618. }
  619. var sErrorNum="0x"+toHex(nResult)+" - "+sErrorName;
  620. // modify the document text and appearance to show the error message
  621. spnErrorNum.innerText=sErrorNum;
  622. spnErrorMsg.innerText=sSugCause;
  623. spnFixTxt.style.display='none';
  624. spnErrorTxt.style.display='';
  625. // back to the top so the messages show
  626. window.scrollTo(0,0);
  627. // reset XEnroll so the user can select a different CSP, etc.
  628. XEnroll.reset();
  629. }
  630. <%Else '"NN"=sBrowser%>
  631. //----------------------------------------------------------------
  632. // NN SPECIFIC:
  633. function SubmitRequest() {
  634. <%If "StandAlone"=sServerType Then%>
  635. // check that the form is filled in
  636. if (false==validateRequest()) {
  637. return false;
  638. }
  639. <%End If%>
  640. ShowTransientMessage(L_Generating_Message);
  641. // set defaults for values we need on install
  642. var sAttrib="challenge: provePequalsNP\r\n";
  643. <%If "StandAlone"=sServerType Then%>
  644. if (""!=document.UIForm.tbCountry.value) {
  645. sAttrib+= "country: "+document.UIForm.tbCountry.value +"\r\n";
  646. }
  647. if (""!=document.UIForm.tbState.value) {
  648. sAttrib+= "state: "+document.UIForm.tbState.value +"\r\n";
  649. }
  650. if (""!=document.UIForm.tbLocality.value) {
  651. sAttrib+= "locality: "+document.UIForm.tbLocality.value +"\r\n";
  652. }
  653. if (""!=document.UIForm.tbOrg.value) {
  654. sAttrib+= "org: "+document.UIForm.tbOrg.value +"\r\n";
  655. }
  656. if (""!=document.UIForm.tbOrgUnit.value) {
  657. sAttrib+= "orgunit: "+document.UIForm.tbOrgUnit.value +"\r\n";
  658. }
  659. if (""!=document.UIForm.tbEmail.value) {
  660. sAttrib+= "email: "+document.UIForm.tbEmail.value +"\r\n";
  661. }
  662. if (""!=document.UIForm.tbCommonName.value) {
  663. sAttrib+="commonname: "+document.UIForm.tbCommonName.value+"\r\n";
  664. }
  665. <%End If%>
  666. <%If "StandAlone"=sServerType Then%>
  667. sAttrib+="CertificateUsage: <%=rgAvailReqTypes(CInt(Request.QueryString("type")), FIELD_OID)%>\r\n";
  668. <%Else%>
  669. sAttrib+="CertificateTemplate: <%=rgAvailReqTypes(CInt(Request.QueryString("type")), FIELD_TEMPLATE)%>\r\n";
  670. <%End If%>
  671. sAttrib+="UserAgentString: <%=Request.ServerVariables("HTTP_USER_AGENT")%>\r\n";
  672. document.SubmittedData.CertAttrib.value=sAttrib;
  673. document.SubmittedData.TargetStoreFlags.value=0; // 0=Use default (=user store), but ignored by Netscape
  674. document.SubmittedData.SaveCert.value="no";
  675. document.SubmittedData.Mode.value="newreq NN";
  676. document.SubmittedData.FriendlyType.value="<%=rgAvailReqTypes(CInt(Request.QueryString("type")), FIELD_FRIENDLYNAME)%>";
  677. // append the local date to the type
  678. document.SubmittedData.FriendlyType.value+=" ("+(new Date()).toLocaleString()+")";
  679. // keygen and submit
  680. return true;
  681. }
  682. <%End If%>
  683. </Script>
  684. <%If "IE"=sBrowser Then%>
  685. <Script Language="VBSCRIPT">
  686. '-----------------------------------------------------------------
  687. ' IE SPECIFIC:
  688. ' call XEnroll to create a request, since javascript has no error handling
  689. Function CreateRequest(lFlags, sDistinguishedName, sCertUsage)
  690. On Error Resume Next
  691. XEnroll.ReuseHardwareKeyIfUnableToGenNew=False
  692. document.SubmittedData.CertRequest.value= _
  693. XEnroll.CreateRequest(lFlags, sDistinguishedName, sCertUsage)
  694. CreateRequest=Err.Number
  695. End Function
  696. </Script>
  697. <%End If%>
  698. </Body>
  699. </HTML>