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.

569 lines
22 KiB

  1. <%@ CODEPAGE=65001 'UTF-8%>
  2. <%' certcarc.asp - (CERT)srv web - install (CA) (R)oot (C)ertificate
  3. ' Copyright (C) Microsoft Corporation, 1998 - 1999 %>
  4. <!-- #include FILE=certsbrt.inc -->
  5. <!-- #include FILE=certdat.inc -->
  6. <%
  7. On Error Resume Next
  8. ' from \nt\public\sdk\inc\certcli.h
  9. Const CR_OUT_BASE64HEADER=&H00000000
  10. Const CR_OUT_BASE64 =&H00000001
  11. Const CR_OUT_BINARY =&H00000002
  12. Const CR_OUT_CHAIN =&H00000100
  13. Const CATYPE_ENTERPRISE_ROOTCA=0
  14. Const CATYPE_ENTERPRISE_SUBCA=1
  15. Const CATYPE_STANDALONE_ROOTCA=3
  16. Const CATYPE_STANDALONE_SUBCA=4
  17. Const CATYPE_UNKNOWN_CA=5
  18. ' from \nt\private\ca\include\certlib.h
  19. Const GETCERT_CAEXCHCERT=True
  20. Const GETCERT_CASIGCERT=False
  21. Const CR_GEMT_HRESULT_STRING =&H00000001
  22. Const CR_PROP_CASIGCERTCOUNT=11
  23. Const CR_PROP_CASIGCERTCHAIN=13
  24. Const CR_PROP_CACERTSTATE=19
  25. Const CR_PROP_CRLSTATE=20
  26. Const PROPTYPE_LONG=1
  27. Const PROPTYPE_BINARY=3
  28. Const CRL_AVAILABLE=3 ' == CR_DISP_ISSUED
  29. Const CERT_VALID=3 ' == CR_DISP_ISSUED
  30. ' Strings To Be Localized
  31. Const L_InstallThisCACert_Message="Install this CA certificate"
  32. Const L_InstallThisCACertChain_Message="Install this CA certificate chain"
  33. Const L_InstallCACert_Message="Install CA certificate"
  34. Const L_DownloadCert_Message="Download CA certificate"
  35. Const L_DownloadChain_Message="Download CA certificate chain"
  36. Const L_DownloadBaseCrl_Message="Download latest base CRL"
  37. Const L_DownloadDeltaCrl_Message="Download latest delta CRL"
  38. Dim sCaInfo, rgCaInfo, nRenewals, rgCrlState, rgCertState, bFailed, nError
  39. Set ICertRequest=Server.CreateObject("CertificateAuthority.Request")
  40. ' get the number of renewals
  41. bFailed=False
  42. nRenewals=ICertRequest.GetCAProperty(sServerConfig, CR_PROP_CASIGCERTCOUNT, 0, PROPTYPE_LONG, CR_OUT_BINARY)
  43. If 0=Err.Number Then
  44. nRenewals=nRenewals-1
  45. ' get the key-reused state of the CRLs and the validity of the CA Certs
  46. ReDim rgCrlState(nRenewals) ' 0 based size
  47. ReDim rgCertState(nRenewals) ' 0 based size
  48. For nIndex=0 To nRenewals
  49. rgCrlState(nIndex)=ICertRequest.GetCAProperty(sServerConfig, CR_PROP_CRLSTATE, nIndex, PROPTYPE_LONG, CR_OUT_BINARY)
  50. rgCertState(nIndex)=ICertRequest.GetCAProperty(sServerConfig, CR_PROP_CACERTSTATE, nIndex, PROPTYPE_LONG, CR_OUT_BINARY)
  51. Next
  52. ' get the cert chain and save in on this page so the client can install it
  53. If "IE"=sBrowser Then
  54. Public sPKCS7
  55. Dim sCertificate
  56. sCertificate=ICertRequest.GetCACertificate(GETCERT_CASIGCERT, sServerConfig, CR_OUT_BASE64_HEADER Or CR_OUT_CHAIN)
  57. sPKCS7=FormatBigString(sCertificate, " sPKCS7=sPKCS7 & ")
  58. End If
  59. End If
  60. If Err.Number<>0 Then
  61. ' CA may be down.
  62. bFailed=True
  63. nError=Err.Number
  64. End If
  65. '-----------------------------------------------------------------
  66. ' Format the big string as a concatenated VB string, breaking at the embedded newlines
  67. Function FormatBigString(sSource, sLinePrefix)
  68. Dim sResult, bCharsLeft, nStartChar, nStopChar, chQuote
  69. sResult=""
  70. chQuote=chr(34)
  71. bCharsLeft=True
  72. nStopChar=1
  73. While (bCharsLeft)
  74. nStartChar=nStopChar
  75. nStopChar=InStr(nStopChar, sSource, vbNewLine)
  76. If (nStopChar>0) Then
  77. sResult=sResult & sLinePrefix & chQuote & Mid(sSource, nStartChar, nStopChar-nStartChar) & chQuote & " & vbNewLine"
  78. If (nStopChar>=Len(sSource)-Len(vbNewLine)) Then
  79. bCharsLeft=False
  80. End If
  81. Else
  82. bCharsLeft=False
  83. End if
  84. sResult=sResult & vbNewLine
  85. nStopChar=nStopChar+Len(vbNewLine)
  86. Wend
  87. FormatBigString=sResult
  88. End Function
  89. '-----------------------------------------------------------------
  90. ' Walk through the CRL validity list and return the nearest valid CRL
  91. Function GetGoodCrlIndex(nIndex)
  92. Dim nSource
  93. nSource=nRenewals-nIndex
  94. While (nSource>0 And CRL_AVAILABLE<>CInt(rgCrlState(nSource)))
  95. nSource=nSource-1
  96. Wend
  97. GetGoodCrlIndex=nSource
  98. End Function
  99. %>
  100. <HTML>
  101. <Head>
  102. <Meta HTTP-Equiv="Content-Type" Content="text/html; charset=UTF-8">
  103. <Title>Microsoft Certificate Services</Title>
  104. </Head>
  105. <Body BgColor=#FFFFFF Link=#0000FF VLink=#0000FF ALink=#0000FF><Font ID=locPageFont Face="Arial">
  106. <Table Border=0 CellSpacing=0 CellPadding=4 Width=100% BgColor=#008080>
  107. <TR>
  108. <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>
  109. <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>
  110. </TR>
  111. </Table>
  112. <%If True=bFailed Then %>
  113. <P ID=locPageTitle1><Font Color=#FF0000><B>Error</B></Font>
  114. <!-- 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>
  115. <P ID=locErrorMsg> An unexpected error has occurred:
  116. <%If nError=&H800706BA Or nError=&H80070005 Then%>
  117. <LocID ID=locSvcNotStarted>The Certification Authority Service has not been started.</LocID>
  118. <%Else%>
  119. <%=ICertRequest.GetErrorMessageText(nError, CR_GEMT_HRESULT_STRING)%>
  120. <%End If%>
  121. <%Else 'True<>bFailed%>
  122. <Form Name=UIForm>
  123. <P ID=locPageTitle2> <B> Download a CA Certificate, Certificate Chain, or CRL</B>
  124. <!-- 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>
  125. <P>
  126. <%If "IE"=sBrowser Then%>
  127. <LocID ID=locInstallIE>
  128. To trust certificates issued from this certification authority,
  129. <Span tabindex=0 Style="cursor:hand; color:#0000FF; text-decoration:underline;"
  130. OnContextMenu="return false;"
  131. OnMouseOver="window.status='<%=L_InstallThisCACertChain_Message%>';return true;"
  132. OnMouseOut="window.status='';return true;"
  133. OnKeyDown="if (13==event.keyCode) {preInstall();return false;} else if (9==event.keyCode) {return true;};return false;"
  134. OnClick="preInstall();return false;"
  135. >install this CA certificate chain</Span>.
  136. </LocID>
  137. <%ElseIf "NN"=sBrowser Then%>
  138. <LocID ID=locInstallNN>
  139. To trust certificates issued from this certification authority,
  140. <A Href="certnew.cer?ReqID=CACert&amp;Renewal=<%=nRenewals%>&amp;Mode=inst&amp;Enc=b64"
  141. OnMouseOver="window.status='<%=L_InstallThisCACert_Message%>';return true;"
  142. OnMouseOut="window.status='';return true;"
  143. >install this CA certificate</A>.
  144. </LocID>
  145. <%Else%>
  146. <LocID ID=locInstallTxt>
  147. To trust certificates issued from this certification authority, install this CA certificate chain.
  148. </LocID>
  149. <%End If%>
  150. <P>
  151. <LocID ID=locPrompt>To download a CA certificate, certificate chain, or CRL, select the certificate and encoding method.</B></LocID>
  152. <%If "Text"<>sBrowser Then%>
  153. <Table Border=0 CellSpacing=0 CellPadding=0>
  154. <TR> <!--establish column widths. -->
  155. <TD><Img Src="certspc.gif" Alt="" Height=1 Width=<%=L_LabelColWidth_Number%>></TD> <!-- label column, top border -->
  156. <TD RowSpan=59><Img Src="certspc.gif" Alt="" Height=1 Width=4></TD> <!-- label spacing column -->
  157. <TD></TD> <!-- field column -->
  158. </TR>
  159. <TR>
  160. <TD ID=locCaCertHead ColSpan=3><Font Face="Arial" Size=-1><BR><B>CA certificate:</B></Font></TD>
  161. </TR>
  162. <TR><TD ColSpan=3 BgColor=#008080><Img Src="certspc.gif" Alt="" Height=2 Width=1></TD></TR>
  163. <TR><TD ColSpan=3><Img Src="certspc.gif" Alt="" Height=6 Width=1></TD></TR>
  164. <TR>
  165. <TD Align=Right VAlign=Top ID=locCaCertLabel></TD>
  166. <TD><Select Name=lbCaInstance Size=4>
  167. <Option Value="0" Selected><LocID ID=locCurCertEntry>Current</LocID> <%If 0<>nRenewals Then%><LocID ID=locCaNameRen1>[<%=sServerDisplayName%>(<%=nRenewals%>)]</LocID><%Else%><LocID ID=locCaNameNoRen1>[<%=sServerDisplayName%>]</LocID><%End If%>
  168. <%For nIndex=1 To nRenewals%>
  169. <%If CERT_VALID=CInt(rgCertState(nRenewals-nIndex)) Then%>
  170. <Option Value="<%=nIndex%>"><LocID ID=locPrevCertEntry>Previous</LocID> <%If nIndex<>nRenewals Then%><LocID ID=locCaNameRen2>[<%=sServerDisplayName%>(<%=nRenewals-nIndex%>)]</LocID><%Else%><LocID ID=locCaNameNoRen2>[<%=sServerDisplayName%>]</LocID><%End If%>
  171. <%End If%>
  172. <%Next%>
  173. </Select>
  174. </TD>
  175. </TR>
  176. <TR><TD ColSpan=3><Img Src="certspc.gif" Alt="" Height=4 Width=1></TD></TR>
  177. <TR>
  178. <TD ID=locEncodingHead ColSpan=3><Font Face="Arial" Size=-1><BR><B>Encoding method:</B></Font></TD>
  179. </TR>
  180. <TR><TD ColSpan=3 BgColor=#008080><Img Src="certspc.gif" Alt="" Height=2 Width=1></TD></TR>
  181. <TR><TD ColSpan=3><Img Src="certspc.gif" Alt="" Height=6 Width=1></TD></TR>
  182. <TR><TD></TD>
  183. <TD><Font ID=locEncDerFont Face="Arial">
  184. <Input Type=Radio ID=rbDerEnc Name=rbEncoding Checked><Label For=rbDerEnc ID=locDerEnc0>DER</Label>
  185. </Font>
  186. </TD>
  187. </TR>
  188. <TR><TD></TD>
  189. <TD><Font ID=locEncB64Font Face="Arial">
  190. <Input Type=Radio ID=rbB64Enc Name=rbEncoding><Label For=rbB64Enc ID=locB64Enc0>Base 64</Label>
  191. </Font>
  192. </TD>
  193. </TR>
  194. <TR><TD ColSpan=3><Img Src="certspc.gif" Alt="" Height=6 Width=1></TD></TR>
  195. </Table>
  196. <%If "IE"=sBrowser Then%>
  197. <Table CellSpacing=0 CellPadding=0>
  198. <TR><TD></TD>
  199. <TD><Font ID=locDlCaCFont Face="Arial">
  200. <Span tabindex=0 Style="cursor:hand; color:#0000FF; text-decoration:underline;"
  201. OnContextMenu="return false;"
  202. OnMouseOver="window.status='<%=L_DownloadCert_Message%>'; return true;"
  203. OnMouseOut="window.status=''; return true;"
  204. OnKeyDown="if (13==event.keyCode) {handleGetCert();return false;} else if (9==event.keyCode) {return true;};return false;"
  205. OnClick="handleGetCert();return false;">
  206. <LocID ID=locDownloadCert>Download CA certificate</LocID></Span></Font>
  207. </TD>
  208. </TR>
  209. <TR><TD ColSpan=3 Height=3></TD></TR>
  210. <TR><TD></TD>
  211. <TD><Font ID=locDlCaCpFont Face="Arial">
  212. <Span tabindex=0 Style="cursor:hand; color:#0000FF; text-decoration:underline;"
  213. OnContextMenu="return false;"
  214. OnMouseOver="window.status='<%=L_DownloadChain_Message%>'; return true;"
  215. OnMouseOut="window.status=''; return true;"
  216. OnKeyDown="if (13==event.keyCode) {handleGetChain();return false;} else if (9==event.keyCode) {return true;};return false;"
  217. OnClick="handleGetChain();return false;">
  218. <LocID ID=locDownloadCertChain>Download CA certificate chain</LocID></Span></Font>
  219. </TD>
  220. </TR>
  221. <TR><TD ColSpan=3 Height=3></TD></TR>
  222. <TR><TD></TD>
  223. <TD><Font ID=locDlBaseCrlFont Face="Arial">
  224. <Span tabindex=0 Style="cursor:hand; color:#0000FF; text-decoration:underline;"
  225. OnContextMenu="return false;"
  226. OnMouseOver="window.status='<%=L_DownloadBaseCrl_Message%>'; return true;"
  227. OnMouseOut="window.status=''; return true;"
  228. OnKeyDown="if (13==event.keyCode) {handleGetBaseCrl();return false;} else if (9==event.keyCode) {return true;};return false;"
  229. OnClick="handleGetBaseCrl();return false;">
  230. <LocID ID=locDownloadBaseCRL>Download latest base CRL</LocID></Span></Font>
  231. </TD>
  232. </TR>
  233. <TR><TD ColSpan=3 Height=3></TD></TR>
  234. <TR><TD></TD>
  235. <TD><Font ID=locDlDeltaCrlFont Face="Arial">
  236. <Span tabindex=0 Style="cursor:hand; color:#0000FF; text-decoration:underline;"
  237. OnContextMenu="return false;"
  238. OnMouseOver="window.status='<%=L_DownloadDeltaCrl_Message%>'; return true;"
  239. OnMouseOut="window.status=''; return true;"
  240. OnKeyDown="if (13==event.keyCode) {handleGetDeltaCrl();return false;} else if (9==event.keyCode) {return true;};return false;"
  241. OnClick="handleGetDeltaCrl();return false;">
  242. <LocID ID=locDownloadDeltaCRL>Download latest delta CRL</LocID></Span></Font>
  243. </TD>
  244. </TR>
  245. </Table>
  246. <%Else '"NN"=sBrowser%>
  247. <Table CellSpacing=0 CellPadding=0>
  248. <TR><TD></TD>
  249. <TD><Font ID=locInstCaCFont Face="Arial">
  250. <A Href="#"
  251. OnContextMenu="return false;"
  252. OnMouseOver="window.status='<%=L_InstallCACert_Message%>'; return true;"
  253. OnMouseOut="window.status=''; return true;"
  254. OnClick="handleInstCert();return false;">
  255. <LocID ID=locInstallCert>Install CA certificate</LocID></A></Font>
  256. </TD>
  257. </TR>
  258. <TR><TD ColSpan=3 Height=3></TD></TR>
  259. <TR><TD></TD>
  260. <TD><Font ID=locDlCaCFont2 Face="Arial">
  261. <A Href="#"
  262. OnContextMenu="return false;"
  263. OnMouseOver="window.status='<%=L_DownloadCert_Message%>'; return true;"
  264. OnMouseOut="window.status=''; return true;"
  265. OnClick="handleGetCert();return false;">
  266. <LocID ID=locDownloadCert2>Download CA certificate</LocID></A></Font>
  267. </TD>
  268. </TR>
  269. <TR><TD ColSpan=3 Height=3></TD></TR>
  270. <TR><TD></TD>
  271. <TD><Font ID=locDlCaCpFont2 Face="Arial">
  272. <A Href="#"
  273. OnContextMenu="return false;"
  274. OnMouseOver="window.status='<%=L_DownloadChain_Message%>'; return true;"
  275. OnMouseOut="window.status=''; return true;"
  276. OnClick="handleGetChain();return false;">
  277. <LocID ID=locDownloadCertChain2>Download CA certificate chain</LocID></A></Font>
  278. </TD>
  279. </TR>
  280. <TR><TD ColSpan=3 Height=3></TD></TR>
  281. <TR><TD></TD>
  282. <TD><Font ID=locDlBaseCrlFont2 Face="Arial">
  283. <A Href="#"
  284. OnContextMenu="return false;"
  285. OnMouseOver="window.status='<%=L_DownloadBaseCrl_Message%>'; return true;"
  286. OnMouseOut="window.status=''; return true;"
  287. OnClick="handleGetBaseCrl();return false;">
  288. <LocID ID=locDownloadBaseCRL2>Download latest base CRL</LocID></A></Font>
  289. </TD>
  290. </TR>
  291. <TR><TD ColSpan=3 Height=3></TD></TR>
  292. <TR><TD></TD>
  293. <TD><Font ID=locDlDeltaCrlFont2 Face="Arial">
  294. <A Href="#"
  295. OnContextMenu="return false;"
  296. OnMouseOver="window.status='<%=L_DownloadDeltaCrl_Message%>'; return true;"
  297. OnMouseOut="window.status=''; return true;"
  298. OnClick="handleGetDeltaCrl();return false;">
  299. <LocID ID=locDownloadDeltaCRL2>Download latest delta CRL</LocID></A></Font>
  300. </TD>
  301. </TR>
  302. </Table>
  303. <%End If%>
  304. <%Else '"Text"=sBrowser%>
  305. <!-- Text only: enumerate everything! -->
  306. <DL>
  307. <%For nIndex=0 To nRenewals%>
  308. <%If CERT_VALID=CInt(rgCertState(nRenewals-nIndex)) Then%>
  309. <DT><LocID ID=locCaCertHead3>CA Certificate: <%If 0=nIndex Then%><LocID ID=locCurCertEntry3>Current</LocID><%Else%><LocID ID=locPrevCertEntry3>Previous</LocID><%End If%><%If nIndex<>nRenewals Then%> <LocID ID=locCaNameRen3>[<%=sServerDisplayName%>(<%=nRenewals-nIndex%>)]</LocID><%Else%> <LocID ID=locCaNameNoRen3>[<%=sServerDisplayName%>]</LocID><%End If%>
  310. <DD><LocID ID=locDownloadCert3>Download CA certificate with the following encoding method: </LocID>
  311. <DD><LocID ID=locSep5>&nbsp;&nbsp;&nbsp;&nbsp;</LocID><A Href="certnew.cer?ReqID=CACert&amp;Renewal=<%=nRenewals-nIndex%>&amp;Enc=bin"><LocID ID=locDerEnc1>DER</LocID></A><LocID ID=locSep1> </LocID><A Href="certnew.cer?ReqID=CACert&amp;Renewal=<%=nRenewals-nIndex%>&amp;Enc=b64"><LocID ID=locB64Enc1>Base&nbsp;64</LocID></A><BR>
  312. <LocID ID=locDownloadCertChain3>Download CA certificate chain with the following encoding method: </LocID>
  313. <DD><LocID ID=locSep6>&nbsp;&nbsp;&nbsp;&nbsp;</LocID><A Href="certnew.p7b?ReqID=CACert&amp;Renewal=<%=nRenewals-nIndex%>&amp;Enc=bin"><LocID ID=locDerEnc2>DER</LocID></A><LocID ID=locSep2> </LocID><A Href="certnew.p7b?ReqID=CACert&amp;Renewal=<%=nRenewals-nIndex%>&amp;Enc=b64"><LocID ID=locB64Enc2>Base&nbsp;64</LocID></A><BR>
  314. <LocID ID=locDownloadBaseCRL3>Download latest base CRL with the following encoding method: </LocID>
  315. <DD><LocID ID=locSep7>&nbsp;&nbsp;&nbsp;&nbsp;</LocID><A Href="certcrl.crl?Type=base&amp;Renewal=<%=GetGoodCrlIndex(nIndex)%>&amp;Enc=bin"><LocID ID=locDerEnc3>DER</LocID></A><LocID ID=locSep3> </LocID><A Href="certcrl.crl?Type=base&amp;Renewal=<%=GetGoodCrlIndex(nIndex)%>&amp;Enc=b64"><LocID ID=locB64Enc3>Base&nbsp;64</LocID></A><BR>
  316. <LocID ID=locDownloadDeltaCRL3>Download latest delta CRL with the following encoding method: </LocID>
  317. <DD><LocID ID=locSep8>&nbsp;&nbsp;&nbsp;&nbsp;</LocID><A Href="certcrl.crl?Type=delta&amp;Renewal=<%=GetGoodCrlIndex(nIndex)%>&amp;Enc=bin"><LocID ID=locDerEnc4>DER</LocID></A><LocID ID=locSep4> </LocID><A Href="certcrl.crl?Type=delta&amp;Renewal=<%=GetGoodCrlIndex(nIndex)%>&amp;Enc=b64"><LocID ID=locB64Enc4>Base&nbsp;64</LocID></A><BR>
  318. <BR>
  319. <%End If%>
  320. <%Next%>
  321. </DL>
  322. <%End If%>
  323. <BR>
  324. <!-- 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>
  325. <!-- 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>
  326. </Form>
  327. </Font>
  328. <!-- ############################################################ -->
  329. <!-- End of standard text. Scripts follow -->
  330. <%bIncludeXEnroll=True%>
  331. <%bIncludeGetCspList=False%>
  332. <!-- #include FILE=certsgcl.inc -->
  333. <%If "IE"=sBrowser Then%>
  334. <!-- This form passes data to certrmpn.asp -->
  335. <Span Style="display:none">
  336. <Form Name=SubmittedData Action="certrmpn.asp" Method=Post>
  337. <Input Type=Hidden Name=Action Value="instCA">
  338. <Input Type=Hidden Name=ActionErr Value="OK">
  339. <Input Type=Hidden Name=CertInstalled Value="NO">
  340. </Form>
  341. </Span>
  342. <%End If%>
  343. <Script Language="JavaScript">
  344. //================================================================
  345. // PAGE GLOBAL VARIABLES
  346. // constants
  347. var CRL_AVAILABLE=3; // == CR_DISP_ISSUED
  348. // CA state information
  349. var nRenewals=<%=nRenewals%>;
  350. var rgCrlState=new Array(
  351. <%For nIndex=0 To nRenewals%>
  352. <%=rgCrlState(nIndex)%><%If nIndex<>nRenewals Then%>,<%End If%>
  353. <%Next%>
  354. );
  355. <%If "IE"=sBrowser Then%>
  356. ;
  357. // Strings To Be Localized
  358. var L_UnknownInstallFailure_ErrorMessage="\"Unable to install the CA certificate:\\n\\nError: \"+sErrorNumber";
  359. // Cannot install a cert until XEnroll has been loaded
  360. var g_bXEnrollLoaded=false;
  361. // Prevent attempts to install cert while first install is going
  362. var g_bInstallingCert=false;
  363. <%End If%>
  364. //================================================================
  365. // LINK HANDLERS
  366. //----------------------------------------------------------------
  367. // Get the requested cert
  368. function handleGetCert() {
  369. location="certnew.cer?ReqID=CACert&Renewal="+getChosenRenewal()+"&"+getEncoding();
  370. }
  371. //----------------------------------------------------------------
  372. // Install the requested cert
  373. function handleInstCert() {
  374. location="certnew.cer?ReqID=CACert&Renewal="+getChosenRenewal()+"&Mode=inst&Enc=b64";
  375. }
  376. //----------------------------------------------------------------
  377. // Get the requested certificate chain
  378. function handleGetChain() {
  379. location="certnew.p7b?ReqID=CACert&Renewal="+getChosenRenewal()+"&"+getEncoding();
  380. }
  381. //----------------------------------------------------------------
  382. // Get the nearest valid Base CRL
  383. function handleGetBaseCrl() {
  384. var nSource=getChosenRenewal();
  385. while (nSource>0 && CRL_AVAILABLE!=rgCrlState[nSource]) {
  386. nSource--;
  387. }
  388. location="certcrl.crl?Type=base&Renewal="+nSource+"&"+getEncoding();
  389. }
  390. //----------------------------------------------------------------
  391. // Get the nearest valid Delta CRL
  392. function handleGetDeltaCrl() {
  393. var nSource=getChosenRenewal();
  394. while (nSource>0 && CRL_AVAILABLE!=rgCrlState[nSource]) {
  395. nSource--;
  396. }
  397. location="certcrl.crl?Type=delta&Renewal="+nSource+"&"+getEncoding();
  398. }
  399. //----------------------------------------------------------------
  400. // Return the renewal # of the currently chosen cert
  401. function getChosenRenewal() {
  402. return nRenewals-document.UIForm.lbCaInstance[document.UIForm.lbCaInstance.selectedIndex].value;
  403. }
  404. //----------------------------------------------------------------
  405. // Return the ecoding parameter based upon the radio button
  406. function getEncoding() {
  407. if (true==document.UIForm.rbEncoding[0].checked) {
  408. return "Enc=bin";
  409. } else {
  410. return "Enc=b64";
  411. }
  412. }
  413. <%If "IE"=sBrowser Then%>
  414. //================================================================
  415. // INSTALL ROUTINES
  416. //----------------------------------------------------------------
  417. // IE SPECIFIC:
  418. // Make sure XEnroll is ready before installing the cert
  419. function preInstall() {
  420. // prevent double clicking and race conditions
  421. if (true==g_bInstallingCert) {
  422. return;
  423. }
  424. g_bInstallingCert=true;
  425. if (false==g_bXEnrollLoaded) {
  426. // XEnroll has never been loaded, so we need to do that first.
  427. // set our special failure handler
  428. g_fnOnLoadFail=handleLoadFail;
  429. // Load an XEnroll object into the page
  430. loadXEnroll("preInstallPhase2()");
  431. } else {
  432. // XEnroll is already loaded, so just install the cert
  433. Install();
  434. }
  435. }
  436. function preInstallPhase2() {
  437. // continued from above
  438. // Now XEnroll is loaded and we're ready to go.
  439. g_bXEnrollLoaded=true;
  440. // install the cert
  441. Install();
  442. }
  443. //----------------------------------------------------------------
  444. // IE SPECIFIC:
  445. // what to to if XEnroll fails to load. In this case, not much.
  446. function handleLoadFail() {
  447. // We are done trying to install a cert, so the user can try again.
  448. // Note that we also *don't* disable controls, since there are no
  449. // controls related to installing a cert (just a link)
  450. g_bInstallingCert=false;
  451. }
  452. //----------------------------------------------------------------
  453. // IE SPECIFIC:
  454. // perform substitution on the error string, because VBScript cannot
  455. function evalErrorMessage(sErrorNumber) {
  456. return eval(L_UnknownInstallFailure_ErrorMessage);
  457. }
  458. <%End If '"IE"=sBrowser%>
  459. </Script>
  460. <%If "IE"=sBrowser Then%>
  461. <Script Language="VBScript">
  462. '-----------------------------------------------------------------
  463. ' IE SPECIFIC:
  464. ' The current CA Certificate
  465. Public sPKCS7
  466. sPKCS7=""
  467. <%=sPKCS7%>
  468. '-----------------------------------------------------------------
  469. ' IE SPECIFIC:
  470. ' Install the certificate
  471. Sub Install()
  472. Dim sMessage
  473. Dim CertInstalled
  474. On Error Resume Next
  475. CertInstalled = XEnroll.InstallPKCS7Ex(sPKCS7)
  476. If 0=Err.Number Then
  477. ' Certificate has been successfully installed. Go to 'success' page
  478. document.SubmittedData.submit
  479. ElseIf -2147023673 = Err.Number Then
  480. ' if HRESULT_FROM_WIN32(ERROR_CANCELLED), set extra msg
  481. document.SubmittedData.ActionErr.Value = "Cancel"
  482. If 0 <> CertInstalled Then
  483. document.SubmittedData.CertInstalled = "YES"
  484. End If
  485. document.SubmittedData.submit
  486. Else
  487. ' unknown error
  488. sMessage=evalErrorMessage("0x" & Hex(Err.Number))
  489. Alert sMessage
  490. End If
  491. g_bInstallingCert=False
  492. End Sub
  493. </Script>
  494. <%End If '"IE"=sBrowser%>
  495. <%End If 'bFailed%>
  496. </Body>
  497. </HTML>