home *** CD-ROM | disk | FTP | other *** search
/ Chip 2000 July / Chip_2000-07_cd.bin / servis / SPNT / sp6x86.exe / ceaccept.asp < prev    next >
Encoding:
Text File  |  1999-12-15  |  8.3 KB  |  278 lines

  1. <%Response.Expires=0%>
  2. <HTML>
  3. <HEAD>
  4. <TITLE>Web Server Enrollment Page</TITLE>
  5. <META HTTP-EQUIV="Cache-Control" CONTENT="no cache">
  6. <META HTTP-EQUIV="Pragma" CONTENT="no cache">
  7. <META HTTP-EQUIV="Expires" CONTENT="0">
  8.  
  9.  
  10. <% 
  11.     ''Process a Certificate Request
  12.     
  13.     On Error Resume Next
  14.     
  15.     Dim Certificate, DispositionCode, LastStatus,ConfigString, PKCS10         
  16.     Dim SubmitFlag, GetCertFlag, Attributes, ControlType
  17.  
  18.     set ICertRequest = Server.CreateObject("CertificateAuthority.Request")
  19.     set ICertConfig     = Server.CreateObject("CertificateAuthority.Config") 
  20.  
  21.     ConfigString = ICertConfig.GetConfig(0)
  22.     PKCS10         = Request.Form("CertRequest")
  23.     SubmitFlag   = Request.Form("SubmitFlag")
  24.     GetCertFlag  = Request.Form("GetCertFlag")
  25.     Attributes   = Request.Form("CertAttrib")
  26.     ControlType  = Request.Form("ControlType")
  27.        
  28.     if PKCS10 <> "" then
  29.           DispositionCode = ICertRequest.Submit(SubmitFlag, PKCS10, Attributes, ConfigString)
  30.       LastStatus = 0
  31.       LastStatus = ICertRequest.GetLastStatus()
  32.       Certificate = ICertRequest.GetCertificate(GetCertFlag)
  33.       Session("CertStore") = Certificate
  34.         end if                   
  35. %>
  36.  
  37.    <% if PKCS10 = "" then %>
  38.      <SCRIPT LANGUAGE="VBSCRIPT">
  39.           msg = "You have submitted an empty string which indicates that an error"
  40.       msg = msg & " has ocured on your machine.  Please verify that the data"
  41.       msg = msg & " you have submitted is vaild and that a PKCS10 is being"
  42.           msg = msg & " correctly generated by your machine."
  43.           err = MsgBox(msg, 16, "CERTIFICATE SERVER")
  44.           window.navigate ("ceenroll.asp")
  45.      </SCRIPT>
  46.     <% end if %>        
  47.  
  48. <% if ControlType = "" then %>
  49.     <SCRIPT LANGUAGE="JAVASCRIPT">
  50.      function Download() {
  51.         window.location = "newcert.cer";    
  52.     }
  53.     </SCRIPT>
  54.  
  55. <% else
  56.  
  57.      ''Format the Certificate
  58.  
  59.      FormatedCert = ""
  60.      qc = chr(34)
  61.      CharsLeft = True
  62.      OutP = 1
  63.  
  64.      while(CharsLeft)
  65.     BeginLine = OutP
  66.     OutP = InStr(OutP, Certificate, vbNewLine)
  67.  
  68.     if (OutP > 0) then
  69.        FormatedCert = FormatedCert & "szPKCS7 = szPKCS7 & " & qc & _
  70.        Mid(Certificate, BeginLine, OutP-BeginLine) & qc 
  71.  
  72.            if (OutP >= (len(Certificate) - len(vcNewLine))) then 
  73.          CharsLeft = False
  74.        end if
  75.     
  76.     else
  77.       CharsLeft = False
  78.     end if
  79.       FormatedCert = FormatedCert & vbNewLine
  80.       OutP = OutP + len(vbNewLine)
  81.      wend
  82.  
  83. end if %>
  84.      
  85.   
  86. <% if ControlType = "XENROLL" or ControlType = "CERTENR3" then %>     
  87.  
  88.     <% if ControlType = "XENROLL" then %>
  89.       <OBJECT
  90.        classid="clsid:43F8F289-7A20-11D0-8F06-00C04FC295E1"
  91.        CODEBASE="/CertControl/xenroll.cab#Version=5,131,2090,1"
  92.        id=IControl
  93.       >
  94.       </OBJECT>   
  95.     <% else %>
  96.       <OBJECT
  97.         classid="clsid:33BEC9E0-F78F-11cf-B782-00C04FD7BF43"
  98.         CODEBASE="/CertControl/x86/certenr3.dll#Version=4.70.1143"
  99.         id=IControl
  100.       >
  101.       </OBJECT>
  102.     <% end if %>  
  103.  
  104.    <SCRIPT LANGUAGE="VBSCRIPT">
  105.    sub Download() 
  106.  
  107.     Dim result, Message
  108.         
  109.         On Error Resume Next
  110.         
  111.     szPKCS7 = ""
  112.         <%=FormatedCert%>
  113.       
  114.    <% if ControlType = "XENROLL" then %> 
  115.         if ("<%=Request.Form("WriteCertToCSP") %>" = "WriteCertToCSP") then  
  116.       IControl.WriteCertToCSP = TRUE
  117.         end if
  118.        
  119.     if "<%=Request.Form("CertUsage")%>" = "1.3.6.1.5.5.7.3.8" or _
  120.            "<%=Request.Form("CertUsage")%>" = "1.3.6.1.5.5.7.3.3" then
  121.        SPCFile = InputBox("Save the SPC file as:", "XENROLL") 
  122.            IControl.SPCFileName = SPCFile       
  123.        elseif "<%=Request.Form("SaveCert")%>" = "SaveCertificate"  then
  124.        SPCFile = InputBox("Save the Certificate as:", "XENROLL") 
  125.            IControl.SPCFileName = SPCFile
  126.        end if 
  127.  
  128.         IControl.AcceptPKCS7(szPKCS7)
  129.    <% else %>
  130.         szSessionID = "<%=Request.Form("PassThru") %>"
  131.         Result = IControl.AcceptCredentials(szSessionID, szPKCS7, 0, FALSE)
  132.    <% end if %>
  133.         If err.Number = 0 Then
  134.    <% if ControlType = "XENROLL" then %>
  135.           Message = "Your new certificate has been successfully installed! " & vbcrlf & vbcrlf
  136.           Message = Message & " If you are using IE3.02 or IE4.0 Preview 2 and you" & vbcrlf
  137.           Message = Message & " have not already installed this Certificate Authority's" & vbcrlf
  138.           Message = Message & " Root Certificate, you must do so from the" & vbcrlf
  139.           Message = Message & " 'Install Certificate Authority Certificates'" & vbcrlf
  140.           Message = Message & " page."
  141.           result = MsgBox (Message, 64, "Certificate Server")
  142.       window.location = "default.htm"
  143.    <% else %>
  144.           Message = "Your new certificate has been successfully installed."
  145.           result = MsgBox (Message, 0, "Certificate Server")
  146.       window.location = "default.htm"
  147.    <% end if %>    
  148.         Else
  149.           Message = "Unable to install the certificate:" & vbcrlf & vbcrlf 
  150.           Message = Message & "Please verify that your CSP supports any settings you have made " 
  151.           Message = Message & "and that your input is valid." & vbcrlf & vbcrlf 
  152.           Message = Message & "Error: " & Hex(err)
  153.       result = MsgBox (Message, 48, "<%=ControlType%>")  
  154.           window.location = "ceenroll.asp"
  155.     End If    
  156.    end sub 
  157.    </SCRIPT>
  158.  
  159. <% end if %>
  160.  
  161.  
  162. <Body Background="csback.gif">
  163. <BODY BGCOLOR=#FFFFFF>
  164. <B><A HREF="../default.htm">HOME</A></B>
  165. <HR>
  166.  
  167. <UL><IMG SRC="cslogo.gif" ALIGN="MIDDLE" border=0 alt="Product Logo"></UL>
  168.  
  169. <Center>
  170.     
  171. <%  if DispositionCode = 3 then %>
  172.  
  173.       <H1>Certificate Download</H1>
  174.       <B>
  175.       <FONT SIZE=5>
  176.       <BR>Your request has been successfully processed!
  177.       </FONT>
  178.       <FONT SIZE=4>  
  179.       <BR><BR><BR><BR><BR>Please click the Download button to obtain your new certificate.
  180.       <BR><BR>
  181.       </FONT>
  182.       <FORM>
  183.          <INPUT TYPE=BUTTON VALUE="Download" NAME="Certificate" OnClick="Download()">    
  184.       </FORM>
  185.       <BR><BR><BR><BR><BR>
  186.  
  187. <%  else %>
  188.  
  189.        <H1>Error!!!</H1>
  190.        <B>
  191.        <FONT SIZE=5>
  192.       
  193.        Certificate Server is unable to process your request.
  194.        </FONT>
  195.        <BR><BR><BR>
  196.        <FONT SIZE=4>
  197.        <I>
  198.        Last Status Error Code = <%=HEX(LastStatus)%>
  199.        </I>
  200.        </FONT>   
  201.         
  202.       <BR><BR>
  203.  
  204.       <% if LastStatus = 1722 then %>
  205.         <FONT SIZE=4>
  206.           This error can occur if the Certificate Authority Service<BR>
  207.           has not been started.<BR>
  208.         </FONT>
  209.         <BR><BR>  
  210.     <FONT SIZE=5>
  211.           Please contact your Certificate Authority for assistance.
  212.         </FONT> 
  213.       <% elseif LastStatus = -2146893811 then %>
  214.         <FONT SIZE=4>
  215.           This error may indicate a problem with the Certificate Authority key.<BR>
  216.           The key was not found and the certificate was not issued.<BR>
  217.         </FONT>
  218.         <BR><BR>
  219.     <FONT SIZE=5>
  220.           Please contact your Certificate Authority for assistance.
  221.         </FONT>
  222.       <% elseif LastStatus = 87 then %>
  223.         <FONT SIZE=4>
  224.           This error indicates that "Invalid Data" was submitted to Certificate Server.<BR>
  225.           This can occur if A) You are submitting a request that is not formated correctly<BR>
  226.           or B) The the Certificate Authority used a network share or relative path to point<BR>
  227.           to the "Shared Directory" when configuring Certificate Server.                
  228.         </FONT>
  229.         <BR><BR>
  230.     <FONT SIZE=5>
  231.           Please contact your Certificate Authority for assistance.
  232.         </FONT>
  233.       <% elseif LastStatus = -2147024883 then %>
  234.         <FONT SIZE=4>
  235.           This error may indicate that the encoded length of your request is 7F.<BR>
  236.           Please reapply for this certificate and changing the "length" of the data<BR>
  237.           you entered for Common Name, Department...  
  238.         </FONT>
  239.         <BR><BR><BR>
  240.     <FONT SIZE=5>
  241.           If this doesn't work, please contact your Certificate Authority.
  242.         </FONT>
  243.       <% else %>
  244.         <FONT SIZE=5>
  245.           <BR><BR>
  246.           Please verify that you are submitting a valid request or contact 
  247.       <BR>your Certificate Authority for assistance.
  248.         </FONT> 
  249.       <% end if %>
  250.       </B>    
  251.       <BR><BR><BR><BR> 
  252.  
  253.  
  254. <%  end if %>
  255.  
  256. </CENTER>
  257.  
  258. <!--FOOTER START-->
  259. <HR>
  260. <HR>
  261. <FORM>
  262. <i>© 1997 by Microsoft Corporation. All rights reserved.</i>
  263. </FORM>
  264. <!--FOOTER END-->
  265.     
  266.  
  267. </BODY>
  268. </HTML>
  269.  
  270.  
  271.  
  272.     
  273.         
  274.     
  275.         
  276.  
  277.         
  278.