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

346 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. var L_Cancelled_ErrorMessage="The operation was canceled by the user.";
  178. // IE is not ready until XEnroll has been loaded
  179. var g_bOkToInstall=false;
  180. //================================================================
  181. // INITIALIZATION ROUTINES
  182. //----------------------------------------------------------------
  183. // This contains the functions we want executed immediately after load completes
  184. function postLoad() {
  185. // Load an XEnroll object into the page
  186. loadXEnroll("postLoadPhase2()");
  187. }
  188. function postLoadPhase2() {
  189. // continued from above
  190. // Now we're ready to go
  191. g_bOkToInstall=true;
  192. // if the user installed the cert then pressed back,
  193. // we'll try to keep them from getting confused by preventing
  194. // them from trying to install again and getting an error.
  195. if (""!=document.State.AlreadyInstalled.value) {
  196. spnAlreadyInstalled.style.display="";
  197. spnInstall.style.display="none";
  198. }
  199. }
  200. //----------------------------------------------------------------
  201. function markInstalled() {
  202. document.State.AlreadyInstalled.value="Y";
  203. }
  204. //================================================================
  205. // INSTALL ROUTINES
  206. //----------------------------------------------------------------
  207. // perform substitution on the error string, because VBScript cannot
  208. function evalErrorMessage(sErrorNumber) {
  209. return eval(L_UnknownInstallFailure_ErrorMessage);
  210. }
  211. </Script>
  212. <Script Language="VBScript">
  213. Public sPKCS7
  214. sPKCS7=""
  215. <%=sPKCS7%>
  216. </Script>
  217. <Script Language="VBScript">
  218. '-----------------------------------------------------------------
  219. ' Install the certificate
  220. Sub Install()
  221. Dim sMessage
  222. On Error Resume Next
  223. If False=g_bOkToInstall Then
  224. Alert L_StillLoading_ErrorMessage
  225. Exit Sub
  226. End If
  227. <%If Request.Form("TargetStoreFlags") > 0 Then%>
  228. XEnroll.MyStoreFlags=<%=Server.HTMLEncode(Request.Form("TargetStoreFlags"))%>
  229. XEnroll.RequestStoreFlags=<%=Server.HTMLEncode(Request.Form("TargetStoreFlags"))%>
  230. XEnroll.RootStoreFlags=<%=Server.HTMLEncode(Request.Form("TargetStoreFlags"))%>
  231. XEnroll.CAStoreFlags=<%=Server.HTMLEncode(Request.Form("TargetStoreFlags"))%>
  232. <%End If%>
  233. XEnroll.SPCFileName=""
  234. XEnroll.acceptResponse(sPKCS7)
  235. If 0=Err.Number Or &H80095001=Err.Number Then
  236. If &H80095001=Err.Number Then
  237. 'inform user about root cert install failure
  238. Alert L_CannotAddRoot_ErrorMessage
  239. End If
  240. ' Certificate has been successfully installed. Go to 'success' page
  241. markInstalled
  242. document.SubmittedData.submit
  243. Else
  244. If Err.Number=&H80092004 Then 'CRYPT_E_NOT_FOUND
  245. ' the private key was not found - most likely this is an attempt to reinstall
  246. sMessage=L_NoPrivKey_ErrorMessage
  247. ElseIf Err.Number=&H800704C7 Then 'ERROR_CANCELLED
  248. ' The operation was canceled by the user.
  249. sMessage=L_Cancelled_ErrorMessage
  250. Else
  251. ' unknown error
  252. sMessage=evalErrorMessage("0x" & Hex(Err.Number))
  253. End If
  254. 'don't popup if cancel, downlevel OS such as NT4 returns H80070002 in case of dlg cancel
  255. If &H800704c7<>Err.Number And &H8010006e<>Err.Number And &H80070002<>Err.Number Then
  256. Alert sMessage
  257. End If
  258. <%If "chkpnd"=Request.Form("Mode") Then%>
  259. ' give the user the option to remove this broken cert from their list
  260. spnRmpn.style.display=""
  261. <%End If%>
  262. End If
  263. End Sub
  264. </Script>
  265. <%ElseIf "Text"<>sBrowser Then%>
  266. <Script Language="JavaScript">
  267. //================================================================
  268. // INITIALIZATION ROUTINES
  269. //----------------------------------------------------------------
  270. // This contains the functions we want executed immediately after load completes
  271. function postLoad() {
  272. // do nothing
  273. }
  274. //================================================================
  275. // LINK HANDLERS
  276. //----------------------------------------------------------------
  277. // Get the requested cert
  278. function handleGetCert() {
  279. location="certnew.cer?ReqID=<%=ICertRequest.GetRequestId()%>&"+getEncoding();
  280. }
  281. //----------------------------------------------------------------
  282. // Get the requested certificate chain
  283. function handleGetChain() {
  284. location="certnew.p7b?ReqID=<%=ICertRequest.GetRequestId()%>&"+getEncoding();
  285. }
  286. //----------------------------------------------------------------
  287. // return the ecoding parameter based upon the radio button
  288. function getEncoding() {
  289. if (true==document.UIForm.rbEncoding[0].checked) {
  290. return "Enc=bin";
  291. } else {
  292. return "Enc=b64";
  293. }
  294. }
  295. </Script>
  296. <%Else '"IE"<>sBrowser%>
  297. <!-- No Scripts -->
  298. <%End If%>
  299. </Body>
  300. </HTML>
  301. <%Session.Abandon()%>