Leaked source code of windows server 2003

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