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.

108 lines
3.3 KiB

  1. <%@ CODEPAGE=65001 'UTF-8%>
  2. <%' certnew.cer - (CERT)srv web - return a (NEW) certificate
  3. ' Copyright (C) Microsoft Corporation, 1998 - 1999 %>
  4. <!-- #include FILE=certdat.inc -->
  5. <!-- #include FILE=certsrck.inc -->
  6. <% ' ########## BEGIN SERVER SIDE EXECUTION ##########
  7. 'Process a Certificate Request
  8. Dim nDisposition, nResult, sCert, sErrMsg, nEncoding
  9. On Error Resume Next
  10. ' from \nt\public\sdk\inc\certcli.h
  11. Const CR_OUT_BASE64HEADER=&H00000000
  12. Const CR_OUT_BASE64=&H00000001
  13. Const CR_OUT_BINARY=&H00000002
  14. Const CR_OUT_CHAIN=&H00000100
  15. 'Disposition code ref: \nt\public\sdk\inc\certcli.h
  16. Const CR_DISP_INCOMPLETE =0
  17. Const CR_DISP_ERROR =1
  18. Const CR_DISP_DENIED =2
  19. Const CR_DISP_ISSUED =3
  20. Const CR_DISP_ISSUED_OUT_OF_BAND=4
  21. Const CR_DISP_UNDER_SUBMISSION =5
  22. Const CR_DISP_REVOKED =6
  23. Const no_disp=-1
  24. Const CR_PROP_CASIGCERT=12
  25. Const PROPTYPE_BINARY=3
  26. 'Stop 'debugging breakpoint
  27. ' determine the requested encoding
  28. If "bin"=Request.QueryString("Enc") Then
  29. nEncoding=CR_OUT_BINARY
  30. Else '"b64"=Request.QueryString("Enc")
  31. nEncoding=CR_OUT_BASE64HEADER
  32. End If
  33. ' create the object to do the request
  34. Set Session("ICertRequest")=Server.CreateObject("CertificateAuthority.Request")
  35. Set ICertRequest=Session("ICertRequest")
  36. nDisposition=no_disp
  37. Err.Clear 'make sure we catch the HRESULT and not some earlier error
  38. If "CACert"=Request.QueryString("ReqID") Then
  39. ' get the CA cert
  40. sCert=ICertRequest.GetCAProperty(sServerConfig, CR_PROP_CASIGCERT, Request.QueryString("Renewal"), PROPTYPE_BINARY, nEncoding)
  41. nResult=Err.Number
  42. sErrMsg=Err.Description
  43. If 0<>nResult Then
  44. 'internal redirect - transfer control to error page
  45. Session("nResult")=nResult
  46. Session("sErrMsg")=sErrMsg
  47. Server.Transfer("certrser.asp")
  48. End If
  49. Else
  50. ' Fetch the user's cert
  51. nDisposition=ICertRequest.RetrievePending(Request.QueryString("ReqID"), sServerConfig)
  52. nResult=Err.number
  53. sErrMsg=Err.Description
  54. If nDisposition=CR_DISP_ISSUED Then
  55. ' Remove this request from the user's cookie
  56. RemoveReq(Request.QueryString("ReqID"))
  57. sCert=ICertRequest.GetCertificate(nEncoding)
  58. Else
  59. 'internal redirect - transfer control to error page
  60. Session("nDisposition")=nDisposition
  61. Session("nResult")=nResult
  62. Session("sErrMsg")=sErrMsg
  63. Server.Transfer("certrser.asp")
  64. End If
  65. End If
  66. ' Netscape automagically installs anything that is "x-x509-***-cert",
  67. ' so pick MIME type depending upon what we want the browser to do.
  68. ' (IE treats all types the same)
  69. If "inst"=Request.QueryString("Mode") Then
  70. ' We want Netscape to install
  71. If "CACert"=Request.QueryString("ReqID") Then
  72. ' Netscape installs this type and does not expect to have a private key
  73. Response.ContentType="application/x-x509-ca-cert"
  74. Else
  75. ' Netscape installs this type and expects to have a private key
  76. Response.ContentType="application/x-x509-user-cert"
  77. End If
  78. Else
  79. ' We don't wan't Netscape to install
  80. Response.ContentType="application/pkix-cert" ' Netscape does not install this type
  81. End If
  82. ' send the cert to the client
  83. Response.Clear 'guarantee no extraneous bytes
  84. If CR_OUT_BINARY=nEncoding Then
  85. Response.BinaryWrite(sCert)
  86. Else
  87. Response.Write(sCert)
  88. End If
  89. ' ########## END SERVER SIDE EXECUTION ##########
  90. %>