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.

341 lines
14 KiB

  1. <%@ CODEPAGE=65001 'UTF-8%>
  2. <%' certrsis.asp - (CERT)srv web - (R)e(S)ult: (IS)sued
  3. ' Copyright (C) Microsoft Corporation, 1998 - 1999 %>
  4. <!-- #include FILE=certsbrt.inc -->
  5. <!-- #include FILE=certdat.inc -->
  6. <!-- #include FILE=certsrck.inc -->
  7. <% ' came from certfnsh.asp
  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 FR_PROP_FULLRESPONSE =&H00000001
  14. Const PROPTYPE_BINARY =&H00000003
  15. ' Strings To Be Localized
  16. Const L_InstallCert_Message="Install certificate"
  17. Const L_DownloadCert_Message="Download certificate"
  18. Const L_DownloadChain_Message="Download certificate chain"
  19. Set ICertRequest=Session("ICertRequest")
  20. sMode=Request.Form("Mode")
  21. If "IE"=sBrowser And "no"=Request.Form("SaveCert") Then
  22. ' get the cert chain and save in on this page so the client can install it
  23. Public sPKCS7
  24. Dim sCertificate
  25. sCertificate=ICertRequest.GetFullResponseProperty(FR_PROP_FULLRESPONSE, 0, PROPTYPE_BINARY, CR_OUT_BASE64)
  26. sPKCS7=FormatBigString(sCertificate, " sPKCS7=sPKCS7 & ")
  27. End If
  28. '-----------------------------------------------------------------
  29. ' Format the big string as a concatenated VB string, breaking at the embedded newlines
  30. Function FormatBigString(sSource, sLinePrefix)
  31. Dim sResult, bCharsLeft, nStartChar, nStopChar, chQuote
  32. sResult=""
  33. chQuote=chr(34)
  34. bCharsLeft=True
  35. nStopChar=1
  36. While (bCharsLeft)
  37. nStartChar=nStopChar
  38. nStopChar=InStr(nStopChar, sSource, vbNewLine)
  39. If (nStopChar>0) Then
  40. sResult=sResult & sLinePrefix & chQuote & Mid(sSource, nStartChar, nStopChar-nStartChar) & chQuote & " & vbNewLine"
  41. If (nStopChar>=Len(sSource)-Len(vbNewLine)) Then
  42. bCharsLeft=False
  43. End If
  44. Else
  45. bCharsLeft=False
  46. End if
  47. sResult=sResult & vbNewLine
  48. nStopChar=nStopChar+Len(vbNewLine)
  49. Wend
  50. FormatBigString=sResult
  51. End Function
  52. %>
  53. <HTML>
  54. <Head>
  55. <Meta HTTP-Equiv="Content-Type" Content="text/html; charset=UTF-8">
  56. <Title>Microsoft Certificate Services</Title>
  57. </Head>
  58. <Body BgColor=#FFFFFF Link=#0000FF VLink=#0000FF ALink=#0000FF <%If "IE"=sBrowser Then%> OnLoad="postLoad();" <%End If%>><Font ID=locPageFont Face="Arial">
  59. <Table Border=0 CellSpacing=0 CellPadding=4 Width=100% BgColor=#008080>
  60. <TR>
  61. <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>
  62. <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>
  63. </TR>
  64. </Table>
  65. <P ID=locPageTitle> <B> Certificate Issued </B>
  66. <!-- 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>
  67. <P ID=locInfo> The certificate you requested was issued to you.</P>
  68. <P><Form Name=UIForm>
  69. <Table Border=0 CellSpacing=0 CellPadding=0>
  70. <%If "Text"<>sBrowser And "no"<>Request.Form("SaveCert") Then%>
  71. <TR><TD></TD>
  72. <TD></TD>
  73. <TD></TD>
  74. <TD><Font ID=locEncFont Face="Arial">
  75. <Input Type=Radio ID=rbDerEnc Name=rbEncoding Checked><Label For=rbDerEnc ID=locDerEnc0>DER encoded</Label>
  76. <LocID ID=locSep0>&nbsp;or&nbsp;</LocID>
  77. <Input Type=Radio ID=rbB64Enc Name=rbEncoding><Label For=rbB64Enc ID=locB64Enc0>Base 64 encoded</Label>
  78. </Font>
  79. </TD>
  80. </TR>
  81. <TR><TD ColSpan=4 Height=4></TD></TR>
  82. <%End If%>
  83. <TR>
  84. <TD><Img Src="certspc.gif" Alt="" Height=1 Width=40></TD>
  85. <TD><Img Src="certcert.gif" Alt="" Width=32 Height=24></TD>
  86. <TD><Img Src="certspc.gif" Alt="" Height=1 Width=5></TD>
  87. <%If "IE"=sBrowser And "no"=Request.Form("SaveCert") Then%>
  88. <TD><Font ID=locInstCert1Font Face="Arial"><Span tabindex=0 ID=spnInstall
  89. Style="cursor:hand; color:#0000FF; text-decoration:underline;"
  90. OnContextMenu="return false;"
  91. OnMouseOver="window.status='<%=L_InstallCert_Message%>';return true;"
  92. OnMouseOut="window.status='';return true;"
  93. OnKeyDown="if (13==event.keyCode) {Install();return false;} else if (9==event.keyCode) {return true;};return false;"
  94. OnClick="Install();return false;"><LocID ID=locInstallCert1>Install this certificate</LocID></Span>
  95. <Span ID=spnAlreadyInstalled Style="display:none"><LocID ID=locAlreadyInstalledCert>(You have already installed this certificate)</LocID></Span></Font></TD>
  96. <%ElseIf "NN"=sBrowser And "no"=Request.Form("SaveCert") Then%>
  97. <TD><Font ID=locInstCert2Font Face="Arial"><A Href="certnew.cer?ReqID=<%=ICertRequest.GetRequestId()%>&amp;Mode=inst&amp;Enc=b64" OnMouseOver="window.status='<%=L_InstallCert_Message%>';return true;" OnMouseOut="window.status='';return true;"><LocID ID=locInstallCert2>Install this certificate</LocID></A></Font></TD>
  98. <%ElseIf "Text"=sBrowser Then%>
  99. <TD><Font ID=locDwnld1Font Face="Arial">
  100. <LocID ID=locDownloadCert1>Download certificate: </LocID><A Href="certnew.cer?ReqID=<%=ICertRequest.GetRequestId()%>&amp;Enc=bin"><LocID ID=locDerEnc1>DER Encoded</LocID></A><LocID ID=locSep1> or </LocID><A Href="certnew.cer?ReqID=<%=ICertRequest.GetRequestId()%>&amp;Enc=b64"><LocID ID=locB64Enc1>Base 64 encoded</LocID></A><BR>
  101. <LocID ID=locDownloadCertChain1>Download certificate chain: </LocID><A Href="certnew.p7b?ReqID=<%=ICertRequest.GetRequestId()%>&amp;Enc=bin"><LocID ID=locDerEnc2>DER Encoded</LocID></A><LocID ID=locSep2> or </LocID><A Href="certnew.p7b?ReqID=<%=ICertRequest.GetRequestId()%>&amp;Enc=b64"><LocID ID=locB64Enc2>Base 64 encoded</LocID></A>
  102. </Font></TD>
  103. <%ElseIf "IE"=sBrowser Then%>
  104. <TD><Font ID=locDwnld2Font Face="Arial">
  105. <Span tabindex=0 Style="cursor:hand; color:#0000FF; text-decoration:underline;"
  106. OnContextMenu="return false;"
  107. OnMouseOver="window.status='<%=L_DownloadCert_Message%>'; return true;"
  108. OnMouseOut="window.status=''; return true;"
  109. OnKeyDown="if (13==event.keyCode) {handleGetCert();return false;} else if (9==event.keyCode) {return true;};return false;"
  110. OnClick="handleGetCert();return false;">
  111. <LocID ID=locDownloadCert2>Download certificate</LocID></Span>
  112. <BR>
  113. <Span tabindex=0 Style="cursor:hand; color:#0000FF; text-decoration:underline;"
  114. OnContextMenu="return false;"
  115. OnMouseOver="window.status='<%=L_DownloadChain_Message%>'; return true;"
  116. OnMouseOut="window.status=''; return true;"
  117. OnKeyDown="if (13==event.keyCode) {handleGetChain();return false;} else if (9==event.keyCode) {return true;};return false;"
  118. OnClick="handleGetChain();return false;">
  119. <LocID ID=locDownloadCertChain2>Download certificate chain</LocID></Span>
  120. </Font></TD>
  121. <%Else%>
  122. <TD><Font ID=locDwnld3Font Face="Arial">
  123. <A Href="#"
  124. OnMouseOver="window.status='<%=L_DownloadCert_Message%>'; return true;"
  125. OnMouseOut="window.status=''; return true;"
  126. OnClick="handleGetCert();return false;">
  127. <LocID ID=locDownloadCert3>Download certificate</LocID></A>
  128. <BR>
  129. <A Href="#"
  130. OnMouseOver="window.status='<%=L_DownloadChain_Message%>'; return true;"
  131. OnMouseOut="window.status=''; return true;"
  132. OnClick="handleGetChain();return false;">
  133. <LocID ID=locDownloadCertChain3>Download certificate chain</LocID></A>
  134. </Font></TD>
  135. <%End If%>
  136. </TR>
  137. </Table>
  138. </Form></P>
  139. <%If "IE"=sBrowser And "no"=Request.Form("SaveCert") And "chkpnd"=Request.Form("Mode")Then%>
  140. <!-- This option is shown if install fails -->
  141. <Span ID=spnRmpn Style="display:none">
  142. <Form Action="certrmpn.asp" Method=Post>
  143. <Input Type=Hidden Name=Action Value="rmpn">
  144. <Input Type=Hidden Name=ReqID Value="<%=ICertRequest.GetRequestId()%>">
  145. <P><Input ID=locBtnRemove Type=Submit Value="Remove"> - Remove this request from your list of pending requests.
  146. </Form>
  147. </Span>
  148. <%End If%>
  149. <!-- 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>
  150. <!-- 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>
  151. </Font>
  152. <!-- ############################################################ -->
  153. <!-- End of standard text. Scripts follow -->
  154. <%bIncludeXEnroll=True%>
  155. <%bIncludeGetCspList=False%>
  156. <!-- #include FILE=certsgcl.inc -->
  157. <%If "IE"=sBrowser And "no"=Request.Form("SaveCert") Then%>
  158. <!-- This form passes data to certrmpn.asp -->
  159. <Span Style="display:none">
  160. <Form Name=SubmittedData Action="certrmpn.asp" Method=Post>
  161. <Input Type=Hidden Name=Action Value="inst">
  162. <Input Type=Hidden Name=ReqID Value="<%=ICertRequest.GetRequestId()%>">
  163. </Form>
  164. <!-- This form is used to try to prevent installing twice -->
  165. <Form Name=State><Input Type=Hidden Name=AlreadyInstalled Value=""></Form>
  166. </Span>
  167. <Script Language="JavaScript">
  168. //================================================================
  169. // PAGE GLOBAL VARIABLES
  170. //----------------------------------------------------------------
  171. // Strings To Be Localized
  172. var L_StillLoading_ErrorMessage="This page has not finished loading yet. Please wait a few seconds and try again.";
  173. var L_NoPrivKey_ErrorMessage="The certificate has probably been installed already.\n\n(Unable to install the certificate: The private key\ncorresponding with this certificate could not be found.)";
  174. var L_CannotAddRoot_ErrorMessage="The certificate has been installed.\nHowever you cannot add a root certificate into your local store.\nThis may be because of the domain group policy.\n\nPlease contact the CA administrators if you see any chain\nverification failure on the certificate.";
  175. var L_RootIsNotAdded_ErrorMessage="The certificate has been installed.\nHowever the root certificate is not installed.\nYou can go to the home page to download the CA root certificate.";
  176. var L_UnknownInstallFailure_ErrorMessage="\"Unable to install the certificate:\\n\\Error: \"+sErrorNumber";
  177. // IE is not ready until XEnroll has been loaded
  178. var g_bOkToInstall=false;
  179. //================================================================
  180. // INITIALIZATION ROUTINES
  181. //----------------------------------------------------------------
  182. // This contains the functions we want executed immediately after load completes
  183. function postLoad() {
  184. // Load an XEnroll object into the page
  185. loadXEnroll("postLoadPhase2()");
  186. }
  187. function postLoadPhase2() {
  188. // continued from above
  189. // Now we're ready to go
  190. g_bOkToInstall=true;
  191. // if the user installed the cert then pressed back,
  192. // we'll try to keep them from getting confused by preventing
  193. // them from trying to install again and getting an error.
  194. if (""!=document.State.AlreadyInstalled.value) {
  195. spnAlreadyInstalled.style.display="";
  196. spnInstall.style.display="none";
  197. }
  198. }
  199. //----------------------------------------------------------------
  200. function markInstalled() {
  201. document.State.AlreadyInstalled.value="Y";
  202. }
  203. //================================================================
  204. // INSTALL ROUTINES
  205. //----------------------------------------------------------------
  206. // perform substitution on the error string, because VBScript cannot
  207. function evalErrorMessage(sErrorNumber) {
  208. return eval(L_UnknownInstallFailure_ErrorMessage);
  209. }
  210. </Script>
  211. <Script Language="VBScript">
  212. Public sPKCS7
  213. sPKCS7=""
  214. <%=sPKCS7%>
  215. </Script>
  216. <Script Language="VBScript">
  217. '-----------------------------------------------------------------
  218. ' Install the certificate
  219. Sub Install()
  220. Dim sMessage
  221. On Error Resume Next
  222. If False=g_bOkToInstall Then
  223. Alert L_StillLoading_ErrorMessage
  224. Exit Sub
  225. End If
  226. <%If Request.Form("TargetStoreFlags") > 0 Then%>
  227. XEnroll.MyStoreFlags=<%=Request.Form("TargetStoreFlags")%>
  228. XEnroll.RequestStoreFlags=<%=Request.Form("TargetStoreFlags")%>
  229. XEnroll.RootStoreFlags=<%=Request.Form("TargetStoreFlags")%>
  230. XEnroll.CAStoreFlags=<%=Request.Form("TargetStoreFlags")%>
  231. <%End If%>
  232. XEnroll.SPCFileName=""
  233. XEnroll.acceptResponse(sPKCS7)
  234. If 0=Err.Number Or &H80095001=Err.Number Or &H800704c7=Err.Number Then
  235. If &H80095001=Err.Number Then
  236. 'inform user about root cert install failure
  237. Alert L_CannotAddRoot_ErrorMessage
  238. ElseIf &H800704c7=Err.Number Then
  239. Alert L_RootIsNotAdded_ErrorMessage
  240. End If
  241. ' Certificate has been successfully installed. Go to 'success' page
  242. markInstalled
  243. document.SubmittedData.submit
  244. Else
  245. If Err.Number=&H80092004 Then 'CRYPT_E_NOT_FOUND
  246. ' the private key was not found - most likely this is an attempt to reinstall
  247. sMessage=L_NoPrivKey_ErrorMessage
  248. Else
  249. ' unknown error
  250. sMessage=evalErrorMessage("0x" & Hex(Err.Number))
  251. End If
  252. Alert sMessage
  253. <%If "chkpnd"=Request.Form("Mode") Then%>
  254. ' give the user the option to remove this broken cert from their list
  255. spnRmpn.style.display=""
  256. <%End If%>
  257. End If
  258. End Sub
  259. </Script>
  260. <%ElseIf "Text"<>sBrowser Then%>
  261. <Script Language="JavaScript">
  262. //================================================================
  263. // INITIALIZATION ROUTINES
  264. //----------------------------------------------------------------
  265. // This contains the functions we want executed immediately after load completes
  266. function postLoad() {
  267. // do nothing
  268. }
  269. //================================================================
  270. // LINK HANDLERS
  271. //----------------------------------------------------------------
  272. // Get the requested cert
  273. function handleGetCert() {
  274. location="certnew.cer?ReqID=<%=ICertRequest.GetRequestId()%>&"+getEncoding();
  275. }
  276. //----------------------------------------------------------------
  277. // Get the requested certificate chain
  278. function handleGetChain() {
  279. location="certnew.p7b?ReqID=<%=ICertRequest.GetRequestId()%>&"+getEncoding();
  280. }
  281. //----------------------------------------------------------------
  282. // return the ecoding parameter based upon the radio button
  283. function getEncoding() {
  284. if (true==document.UIForm.rbEncoding[0].checked) {
  285. return "Enc=bin";
  286. } else {
  287. return "Enc=b64";
  288. }
  289. }
  290. </Script>
  291. <%Else '"IE"<>sBrowser%>
  292. <!-- No Scripts -->
  293. <%End If%>
  294. </Body>
  295. </HTML>
  296. <%Session.Abandon()%>