Source code of Windows XP (NT5)
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.

779 lines
28 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 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. </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 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. </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 ID=locInstructions ColSpan=3><Font Face="Arial">
  68. To complete your certificate, type the requested information in the following boxes.</Font></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 ID=locCSPInstr ColSpan=3><Font Face="Arial">
  125. Select a Cryptographic Service Provider:</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>
  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><Font Size=-1>Request Format:</Font></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 ID=locAdvancedLink ColSpan=3><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></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_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.";
  230. var L_SugCauseBadChar_ErrorMessage="You entered an invalid character. Report a bug, because this should have been caught in validation.";
  231. <%Else%>
  232. ;
  233. 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.";
  234. <%End If%>
  235. <%If "IE"=sBrowser Then%>
  236. // IE is not ready until XEnroll has been loaded
  237. var g_bOkToSubmit=false;
  238. <%Else%>
  239. // We start with this variable true since it doesn't do anything
  240. // for Netscape anyway.
  241. var g_bOkToSubmit=true;
  242. <%End If%>
  243. var g_bSubmitPending=false;
  244. <%If "IE"=sBrowser Then%>
  245. //================================================================
  246. // INITIALIZATION ROUTINES
  247. //----------------------------------------------------------------
  248. // IE SPECIFIC:
  249. // This contains the functions we want executed immediately after load completes
  250. function postLoad() {
  251. // Load an XEnroll object into the page
  252. loadXEnroll("postLoadPhase2()");
  253. handleCMCFormat();
  254. }
  255. function postLoadPhase2() {
  256. // continued from above
  257. var nResult;
  258. var sCSPList ="<%=rgAvailReqTypes(CInt(Request.QueryString("type")), FIELD_CSPLIST)%>";
  259. <%If "Enterprise"=sServerType Then%>
  260. var sUserAgent=navigator.userAgent;
  261. if (-1 == sUserAgent.indexOf("Windows NT 5.1"))
  262. {
  263. var sCSPList ="<%=rgAvailReqTypes(CInt(Request.QueryString("type")), FIELD_CSPLIST2)%>";
  264. }
  265. <%End If%>
  266. if ("" != sCSPList)
  267. {
  268. // get csp from template
  269. updateCSPListFromStrings(sCSPList);
  270. nResult = 0;
  271. }
  272. else
  273. {
  274. // get the CSP list from local xenroll
  275. nResult=GetCSPList();
  276. }
  277. if (0!=nResult) {
  278. handleLoadError(nResult, L_CspLoadErrNoneFound_ErrorMessage, L_CspLoadErrUnexpected_ErrorMessage);
  279. return;
  280. }
  281. // Now we're ready to go
  282. g_bOkToSubmit=true;
  283. }
  284. //----------------------------------------------------------------
  285. // IE SPECIFIC: handle errors from GetCSPList() and GetTemplateList()
  286. function handleLoadError(nResult, sNoneFound, sUnexpected) {
  287. if (-1==nResult) {
  288. alert(sNoneFound);
  289. } else {
  290. var sErrorNumber="0x"+toHex(nResult);
  291. alert(eval(sUnexpected));
  292. }
  293. disableAllControls();
  294. }
  295. //================================================================
  296. // PAGE MANAGEMENT ROUTINES
  297. //----------------------------------------------------------------
  298. // IE SPECIFIC: morph method for the error details drop-down
  299. function showErrorDetails() {
  300. spnErrorDetailsBtn.style.display='none';
  301. spnErrorDetails1.style.display='';
  302. spnErrorDetails2.style.display='';
  303. }
  304. //----------------------------------------------------------------
  305. // IE SPECIFIC: morph method for the "more options" drop down
  306. function showMoreOptions() {
  307. var nIndex;
  308. for (nIndex=0; nIndex<trMoreOptHide.length; nIndex++) { //>
  309. trMoreOptHide[nIndex].style.display='none';
  310. }
  311. for (nIndex=0; nIndex<trMoreOptShow.length; nIndex++) { //>
  312. trMoreOptShow[nIndex].style.display='';
  313. }
  314. }
  315. //----------------------------------------------------------------
  316. // handle CMC Format
  317. function handleCMCFormat() {
  318. if (!isClientAbleToCreateCMC())
  319. {
  320. //no cmc, disable it, only pkcs10
  321. document.UIForm.rbRequestFormat[0].disabled=true;
  322. document.UIForm.rbRequestFormat[1].disabled=true;
  323. document.UIForm.rbRequestFormat[1].checked=true;
  324. }
  325. }
  326. <%End If%>
  327. //================================================================
  328. // SUBMIT ROUTINES
  329. //----------------------------------------------------------------
  330. // determine what to do when the submit button is pressed
  331. function goNext() {
  332. if (false==g_bOkToSubmit) {
  333. alert(L_StillLoading_ErrorMessage);
  334. return false;
  335. } else if (true==g_bSubmitPending) {
  336. // ignore this, as there is UI already.
  337. return false;
  338. } else {
  339. return SubmitRequest();
  340. }
  341. }
  342. <%If "StandAlone"=sServerType Then%>
  343. //----------------------------------------------------------------
  344. // check for invalid characters
  345. var gc_IA5Chars=" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKMLNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"
  346. function isValidIA5String(sSource) {
  347. var nIndex;
  348. for (nIndex=sSource.length-1; nIndex>=0; nIndex--) {
  349. //if (sSource.charCodeAt(nIndex)>127) { // NOTE: this is better, but not compatible with old browsers.
  350. if (-1==gc_IA5Chars.indexOf(sSource.charAt(nIndex))) {
  351. return false;
  352. }
  353. };
  354. return true;
  355. }
  356. //----------------------------------------------------------------
  357. // check for invalid characters
  358. function isValidCountryField(tbCountry) {
  359. tbCountry.value=tbCountry.value.toUpperCase();
  360. var sSource=tbCountry.value;
  361. var nIndex, ch;
  362. if (0!=sSource.length && 2!=sSource.length) {
  363. return false;
  364. }
  365. for (nIndex=sSource.length-1; nIndex>=0; nIndex--) {
  366. ch=sSource.charAt(nIndex)
  367. if (ch<"A" || ch>"Z") {
  368. return false;
  369. }
  370. };
  371. return true;
  372. }
  373. //----------------------------------------------------------------
  374. // set a label to normal style
  375. function markLabelNormal(spn) {
  376. <%If "IE"=sBrowser Then%>
  377. spn.style.color="#000000";
  378. spn.style.fontWeight='normal';
  379. <%End If%>
  380. }
  381. //----------------------------------------------------------------
  382. // set a label to error state
  383. function markLabelError(spn) {
  384. <%If "IE"=sBrowser Then%>
  385. spn.style.color='#FF0000';
  386. spn.style.fontWeight='bold';
  387. <%End If%>
  388. }
  389. //----------------------------------------------------------------
  390. // check that the form has data in it
  391. function validateRequest() {
  392. <%If "IE"<>sBrowser Then%>
  393. // work around for NN: label marking does nothing
  394. var spnNameLabel, spnEmailLabel, spnCompanyLabel, spnDepartmentLabel, spnCityLabel, spnStateLabel, spnCountryLabel;
  395. <%End If%>
  396. markLabelNormal(spnNameLabel);
  397. markLabelNormal(spnEmailLabel);
  398. markLabelNormal(spnCompanyLabel);
  399. markLabelNormal(spnDepartmentLabel);
  400. markLabelNormal(spnCityLabel);
  401. markLabelNormal(spnStateLabel);
  402. markLabelNormal(spnCountryLabel);
  403. var bOK=true;
  404. var fldFocusMe=null;
  405. // check in 'reverse' order so that focus gets set to last item
  406. // don't set focus immediately because we'd get funny scrolling effects.
  407. if (false==isValidCountryField(document.UIForm.tbCountry)) {
  408. bOK=false;
  409. fldFocusMe=document.UIForm.tbCountry;
  410. markLabelError(spnCountryLabel);
  411. }
  412. // document.UIForm.tbState.value OK
  413. // document.UIForm.tbLocality.value OK
  414. // document.UIForm.tbOrgUnit.value OK
  415. // document.UIForm.tbOrg.value OK
  416. if (false==isValidIA5String(document.UIForm.tbEmail.value)
  417. <%If "1.3.6.1.5.5.7.3.4"=rgAvailReqTypes(CInt(Request.QueryString("type")), FIELD_OID) Then 'e-mail Protection%>
  418. || ""==document.UIForm.tbEmail.value
  419. <%End If%>
  420. ) {
  421. bOK=false;
  422. fldFocusMe=document.UIForm.tbEmail;
  423. markLabelError(spnEmailLabel);
  424. }
  425. if (""==document.UIForm.tbCommonName.value) {
  426. bOK=false;
  427. fldFocusMe=document.UIForm.tbCommonName;
  428. markLabelError(spnNameLabel);
  429. }
  430. if (false==bOK) {
  431. <%If "IE"=sBrowser Then%>
  432. spnFixTxt.style.display='';
  433. window.scrollTo(0,0);
  434. <%Else%>
  435. alert (L_BadChars_ErrorMessage);
  436. <%End If%>
  437. fldFocusMe.focus();
  438. }
  439. return bOK;
  440. }
  441. <%End If '"StandAlone"=sServerType%>
  442. <%If "IE"=sBrowser Then%>
  443. //----------------------------------------------------------------
  444. // IE SPECIFIC:
  445. function SubmitRequest() {
  446. g_bSubmitPending=true;
  447. spnErrorTxt.style.display='none';
  448. spnFixTxt.style.display='none';
  449. <%If "StandAlone"=sServerType Then%>
  450. // check that the form is filled in
  451. if (false==validateRequest()) {
  452. g_bSubmitPending=false;
  453. return;
  454. }
  455. <%End If%>
  456. // show a nice message since request creation can take a while
  457. ShowTransientMessage(L_Generating_Message);
  458. // Make the message show up on the screen,
  459. // then continue with 'SubmitRequest':
  460. // Pause 1 mS before executing phase 2,
  461. // so screen will have time to repaint.
  462. setTimeout("SubmitRequestPhase2();", 10);
  463. }
  464. function SubmitRequestPhase2() {
  465. // continued from above
  466. // some constants defined in wincrypt.h: (line ~234)
  467. var CRYPT_EXPORTABLE=1;
  468. var CRYPT_USER_PROTECTED=2;
  469. var AT_KEYEXCHANGE=1;
  470. var AT_SIGNATURE=2;
  471. var PROV_DSS=3;
  472. var PROV_DSS_DH=13;
  473. var XECR_PKCS10_V2_0=1;
  474. var XECR_CMC=3;
  475. <%If "StandAlone"=sServerType Then%>
  476. // set the identifying info
  477. var sDistinguishedName=""
  478. if (""!=document.UIForm.tbCountry.value) {
  479. sDistinguishedName+="C=\""+document.UIForm.tbCountry.value.replace(/"/g, "\"\"") +"\";";
  480. }
  481. if (""!=document.UIForm.tbState.value) {
  482. sDistinguishedName+="S=\""+document.UIForm.tbState.value.replace(/"/g, "\"\"") +"\";";
  483. }
  484. if (""!=document.UIForm.tbLocality.value) {
  485. sDistinguishedName+="L=\""+document.UIForm.tbLocality.value.replace(/"/g, "\"\"") +"\";";
  486. }
  487. if (""!=document.UIForm.tbOrg.value) {
  488. sDistinguishedName+="O=\""+document.UIForm.tbOrg.value.replace(/"/g, "\"\"") +"\";";
  489. }
  490. if (""!=document.UIForm.tbOrgUnit.value) {
  491. sDistinguishedName+="OU=\""+document.UIForm.tbOrgUnit.value.replace(/"/g, "\"\"") +"\";";
  492. }
  493. if (""!=document.UIForm.tbEmail.value) {
  494. sDistinguishedName+="E=\""+document.UIForm.tbEmail.value.replace(/"/g, "\"\"") +"\";";
  495. }
  496. if (""!=document.UIForm.tbCommonName.value) {
  497. sDistinguishedName+="CN=\""+document.UIForm.tbCommonName.value.replace(/"/g, "\"\"")+"\";";
  498. }
  499. <%Else%>
  500. // the distinguished name is not used for enterprise CAs
  501. var sDistinguishedName="";
  502. <%End If%>
  503. // set defaults for values we need on install
  504. document.SubmittedData.CertAttrib.value="UserAgent:<%=Request.ServerVariables("HTTP_USER_AGENT")%>\r\n";
  505. document.SubmittedData.TargetStoreFlags.value=0; // 0=Use default (=user store)
  506. document.SubmittedData.SaveCert.value="no";
  507. document.SubmittedData.Mode.value="newreq";
  508. document.SubmittedData.FriendlyType.value="<%=rgAvailReqTypes(CInt(Request.QueryString("type")), FIELD_FRIENDLYNAME)%>";
  509. // append the local date to the type
  510. document.SubmittedData.FriendlyType.value+=" ("+(new Date()).toLocaleString()+")";
  511. <%If "StandAlone"=sServerType Then%>
  512. // set the cert type information
  513. var sCertUsage="<%=rgAvailReqTypes(CInt(Request.QueryString("type")), FIELD_OID)%>";
  514. <%Else%>
  515. // set the cert template, we know this is v1 template
  516. var XECT_EXTENSION_V1=1;
  517. XEnroll.addCertTypeToRequestEx(XECT_EXTENSION_V1, "<%=rgAvailReqTypes(CInt(Request.QueryString("type")), FIELD_TEMPLATE)%>", 0, false, 0);
  518. var sCertUsage=""; // ignored
  519. <%End If%>
  520. // set the CSP
  521. var nCSPIndex=document.UIForm.lbCSP.selectedIndex;
  522. XEnroll.ProviderName=document.UIForm.lbCSP.options[nCSPIndex].text;
  523. var nProvType=document.UIForm.lbCSP.options[nCSPIndex].value
  524. XEnroll.ProviderType=nProvType;
  525. // default to exchange keys, unless we're doing DSS which only does sig.
  526. if (PROV_DSS==nProvType || PROV_DSS_DH==nProvType) {
  527. XEnroll.KeySpec=AT_SIGNATURE;
  528. } else {
  529. XEnroll.KeySpec=AT_KEYEXCHANGE;
  530. }
  531. // set 'Strong private key protection'
  532. if (document.UIForm.cbStrongKey.checked) {
  533. XEnroll.GenKeyFlags|=CRYPT_USER_PROTECTED;
  534. }
  535. // set request format
  536. lRequestFlag=XECR_CMC;
  537. if (document.UIForm.rbRequestFormat[1].checked) {
  538. lRequestFlag=XECR_PKCS10_V2_0;
  539. }
  540. //regardless
  541. XEnroll.EnableSMIMECapabilities=true
  542. // build the certificate request
  543. var nResult=CreateRequest(lRequestFlag, sDistinguishedName, sCertUsage); // ask VB to do it, since it can handle errors
  544. if (0 == nResult)
  545. {
  546. //always get thumbprint in case of pending
  547. document.SubmittedData.ThumbPrint.value=XEnroll.ThumbPrint;
  548. }
  549. // hide the message box
  550. HideTransientMessage();
  551. //see if it was cancelled
  552. if (document.UIForm.cbStrongKey.checked && -2147023673==nResult)
  553. {
  554. //ERROR_CANCELLED, likely from dialog, out
  555. g_bSubmitPending=false;
  556. XEnroll.reset();
  557. return;
  558. }
  559. // deal with an error if there was one
  560. if (0!=nResult) {
  561. handleError(nResult);
  562. g_bSubmitPending=false;
  563. return;
  564. }
  565. // put up a new wait message
  566. ShowTransientMessage(L_Waiting_Message);
  567. // Submit the cert request and move forward in the wizard
  568. document.SubmittedData.submit();
  569. }
  570. //----------------------------------------------------------------
  571. // IE SPECIFIC:
  572. function handleError(nResult) {
  573. var sSugCause=L_SugCauseNone_ErrorMessage;
  574. var sErrorName=L_ErrNameUnknown_ErrorMessage;
  575. // analyze the error - funny use of XOR ('^') because obvious choice '==' doesn't work
  576. if (0==(0x80090008^nResult)) {
  577. sErrorName="NTE_BAD_ALGID";
  578. sSugCause=L_SugCauseBadCSP_ErrorMessage;
  579. } else if (0==(0x80090016^nResult)) {
  580. sErrorName="NTE_BAD_KEYSET";
  581. sSugCause=L_SugCauseBadCSP_ErrorMessage;
  582. } else if (0==(0x80090019^nResult)) {
  583. sErrorName="NTE_KEYSET_NOT_DEF";
  584. sSugCause=L_SugCauseBadCSP_ErrorMessage;
  585. } else if (0==(0x80090020^nResult)) {
  586. sErrorName="NTE_FAIL";
  587. sSugCause=L_SugCauseBadCSP_ErrorMessage;
  588. } else if (0==(0x80090009^nResult)) {
  589. sErrorName="NTE_BAD_FLAGS";
  590. sSugCause=L_SugCauseBadSetting_ErrorMessage;
  591. } else if (0==(0x80092002^nResult)) {
  592. sErrorName="CRYPT_E_BAD_ENCODE";
  593. //sSugCause="";
  594. } else if (0==(0x80092022^nResult)) {
  595. sErrorName="CRYPT_E_INVALID_IA5_STRING";
  596. sSugCause=L_SugCauseBadChar_ErrorMessage;
  597. } else if (0==(0x80092023^nResult)) {
  598. sErrorName="CRYPT_E_INVALID_X500_STRING";
  599. sSugCause=L_SugCauseBadChar_ErrorMessage;
  600. } else if (0==(0x8000FFFF^nResult)) {
  601. sErrorName="E_UNEXPECTED";
  602. }
  603. var sErrorNum="0x"+toHex(nResult)+" - "+sErrorName;
  604. // modify the document text and appearance to show the error message
  605. spnErrorNum.innerText=sErrorNum;
  606. spnErrorMsg.innerText=sSugCause;
  607. spnFixTxt.style.display='none';
  608. spnErrorTxt.style.display='';
  609. // back to the top so the messages show
  610. window.scrollTo(0,0);
  611. // reset XEnroll so the user can select a different CSP, etc.
  612. XEnroll.reset();
  613. }
  614. <%Else '"NN"=sBrowser%>
  615. //----------------------------------------------------------------
  616. // NN SPECIFIC:
  617. function SubmitRequest() {
  618. <%If "StandAlone"=sServerType Then%>
  619. // check that the form is filled in
  620. if (false==validateRequest()) {
  621. return false;
  622. }
  623. <%End If%>
  624. ShowTransientMessage(L_Generating_Message);
  625. // set defaults for values we need on install
  626. var sAttrib="challenge: provePequalsNP\r\n";
  627. <%If "StandAlone"=sServerType Then%>
  628. if (""!=document.UIForm.tbCountry.value) {
  629. sAttrib+= "country: "+document.UIForm.tbCountry.value +"\r\n";
  630. }
  631. if (""!=document.UIForm.tbState.value) {
  632. sAttrib+= "state: "+document.UIForm.tbState.value +"\r\n";
  633. }
  634. if (""!=document.UIForm.tbLocality.value) {
  635. sAttrib+= "locality: "+document.UIForm.tbLocality.value +"\r\n";
  636. }
  637. if (""!=document.UIForm.tbOrg.value) {
  638. sAttrib+= "org: "+document.UIForm.tbOrg.value +"\r\n";
  639. }
  640. if (""!=document.UIForm.tbOrgUnit.value) {
  641. sAttrib+= "orgunit: "+document.UIForm.tbOrgUnit.value +"\r\n";
  642. }
  643. if (""!=document.UIForm.tbEmail.value) {
  644. sAttrib+= "email: "+document.UIForm.tbEmail.value +"\r\n";
  645. }
  646. if (""!=document.UIForm.tbCommonName.value) {
  647. sAttrib+="commonname: "+document.UIForm.tbCommonName.value+"\r\n";
  648. }
  649. <%End If%>
  650. <%If "StandAlone"=sServerType Then%>
  651. sAttrib+="CertificateUsage: <%=rgAvailReqTypes(CInt(Request.QueryString("type")), FIELD_OID)%>\r\n";
  652. <%Else%>
  653. sAttrib+="CertificateTemplate: <%=rgAvailReqTypes(CInt(Request.QueryString("type")), FIELD_TEMPLATE)%>\r\n";
  654. <%End If%>
  655. sAttrib+="UserAgentString: <%=Request.ServerVariables("HTTP_USER_AGENT")%>\r\n";
  656. document.SubmittedData.CertAttrib.value=sAttrib;
  657. document.SubmittedData.TargetStoreFlags.value=0; // 0=Use default (=user store), but ignored by Netscape
  658. document.SubmittedData.SaveCert.value="no";
  659. document.SubmittedData.Mode.value="newreq NN";
  660. document.SubmittedData.FriendlyType.value="<%=rgAvailReqTypes(CInt(Request.QueryString("type")), FIELD_FRIENDLYNAME)%>";
  661. // append the local date to the type
  662. document.SubmittedData.FriendlyType.value+=" ("+(new Date()).toLocaleString()+")";
  663. // keygen and submit
  664. return true;
  665. }
  666. <%End If%>
  667. </Script>
  668. <%If "IE"=sBrowser Then%>
  669. <Script Language="VBSCRIPT">
  670. '-----------------------------------------------------------------
  671. ' IE SPECIFIC:
  672. ' call XEnroll to create a request, since javascript has no error handling
  673. Function CreateRequest(lFlags, sDistinguishedName, sCertUsage)
  674. On Error Resume Next
  675. document.SubmittedData.CertRequest.value= _
  676. XEnroll.CreateRequest(lFlags, sDistinguishedName, sCertUsage)
  677. CreateRequest=Err.Number
  678. End Function
  679. </Script>
  680. <%End If%>
  681. </Body>
  682. </HTML>