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.

97 lines
2.7 KiB

  1. <%@ CODEPAGE=65001 'UTF-8%>
  2. <%' certnew.p7b - (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_CASIGCERTCHAIN=13
  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_CASIGCERTCHAIN, 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. ' retrieve the certificate
  58. sCert=ICertRequest.GetCertificate(nEncoding Or CR_OUT_CHAIN)
  59. Else
  60. 'internal redirect - transfer control to error page
  61. Session("nDisposition")=nDisposition
  62. Session("nResult")=nResult
  63. Session("sErrMsg")=sErrMsg
  64. Server.Transfer("certrser.asp")
  65. End If
  66. End If
  67. ' Tell the client we are sending a cert chain
  68. Response.ContentType="application/x-pkcs7-certificates"
  69. ' send the cert chain to the client
  70. Response.Clear 'guarantee no extraneous bytes
  71. If CR_OUT_BINARY=nEncoding Then
  72. Response.BinaryWrite(sCert)
  73. Else
  74. Response.Write(sCert)
  75. End If
  76. ' ########## END SERVER SIDE EXECUTION ##########
  77. %>