<html>
  <head>
    <title tal:content="template/title">The title</title>
  </head>


<SCRIPT LANGUAGE=VBSCRIPT>
<!--
   Dim useold
   useold=false   

   Function GetProviderList()

   Dim CspList, cspIndex, ProviderName
   On Error Resume Next

   count = 0
   base = -1
   enhanced = 0
   CspList = ""
   ProviderName = ""

   For ProvType = 0 to 13
      cspIndex = 0
      newencoder.ProviderType = ProvType
      ProviderName = newencoder.enumProviders(cspIndex,0)

      while ProviderName <> ""
         Set oOption = document.createElement("OPTION")
         oOption.text = ProviderName
         oOption.value = ProvType
         Document.CertReqForm.CspProvider.add(oOption)
         if ProviderName = "Microsoft Base Cryptographic Provider v1.0" Then
            base = count
         end if
         if ProviderName = "Microsoft Enhanced Cryptographic Provider v1.0" Then
            enhanced = count
         end if
         cspIndex = cspIndex +1
         ProviderName = ""
         ProviderName = newencoder.enumProviders(cspIndex,0)
         count = count + 1
      wend
   Next
   If base = -1 Then
     useold=true
     Document.CertReqForm.classid.value="clsid:43F8F289-7A20-11D0-8F06-00C04FC295E1"
     count = 0
     enhanced = 0
     basename = ""
     enhancedname = ""
     CspList = ""
     ProviderName = ""

     For ProvType = 0 to 13
         cspIndex = 0
         oldencoder.ProviderType = ProvType
         ProviderName = oldencoder.enumProviders(cspIndex,0)

        while ProviderName <> ""
           Set oOption = document.createElement("OPTION")
           oOption.text = ProviderName
           oOption.value = ProvType
           Document.CertReqForm.CspProvider.add(oOption)
           if ProviderName = "Microsoft Base Cryptographic Provider v1.0" Then
            base = count
           end if
           if ProviderName = "Microsoft Enhanced Cryptographic Provider v1.0" Then
            enhanced = count
           end if
           cspIndex = cspIndex +1
           ProviderName = ""
           ProviderName = oldencoder.enumProviders(cspIndex,0)
           count = count + 1
        wend
     Next
   End If 
   Document.CertReqForm.CspProvider.selectedIndex = base
   if enhanced then
      Document.CertReqForm.CspProvider.selectedIndex = enhanced
   end if
   End Function

   Function NewCSR(szName,keyflags)
      NewCSR = ""
      ' szName          = "CN=6AEK347fw8vWE424"
       newencoder.reset  
       newencoder.HashAlgorithm = "MD5"
       err.clear
       On Error Resume Next
       set options = document.all.CspProvider.options
       index = options.selectedIndex
       newencoder.providerName = options(index).text
       tmpProviderType = options(index).value
       newencoder.providerType = tmpProviderType
       if Document.CertReqForm.enchancedeid.checked then      
         newencoder.ContainerName = "\Prime EID IP1 (basic PIN)\E"
       end if
       newencoder.KeySpec = 2
       if tmpProviderType < 2 Then
          newencoder.KeySpec = 1
       end if
       
       keysize = document.CertReqForm.keysize.value
       keymask = keysize * 65536
       
       newencoder.GenKeyFlags = (keymask + 1) OR keyflags
 
       NewCSR = newencoder.createPKCS10(szName, "")
       if len(NewCSR)<>0 then Exit Function
       newencoder.GenKeyFlags = keymask OR keyflags
       NewCSR = newencoder.createPKCS10(szName, "")
       if len(NewCSR)<>0 then Exit Function
       if newencoder.providerName = "Microsoft Enhanced Cryptographic Provider v1.0" Then
          if MsgBox("1024-bit key generation failed. Would you like to try 512 instead?", vbOkCancel)=vbOk Then
             newencoder.providerName = "Microsoft Base Cryptographic Provider v1.0"
          else
             Exit Function
          end if
       end if
       newencoder.GenKeyFlags = 1 OR keyflags
       NewCSR = newencoder.createPKCS10(szName, "")
       if len(NewCSR)<>0 then Exit Function
       newencoder.GenKeyFlags = keyflags
       NewCSR = newencoder.createPKCS10(szName, "")
       if len(NewCSR)<>0 then Exit Function
       newencoder.GenKeyFlags = 0
       NewCSR = newencoder.createPKCS10(szName, "")
    End Function

   Function OldCSR(szName,keyflags)
      OldCSR = ""
      ' szName          = "CN=6AEK347fw8vWE424"
       oldencoder.reset
       oldencoder.HashAlgorithm = "MD5"
       err.clear
       On Error Resume Next
       set options = document.all.CspProvider.options
       index = options.selectedIndex
       oldencoder.providerName = options(index).text
       tmpProviderType = options(index).value
       oldencoder.providerType = tmpProviderType
       if Document.CertReqForm.enchancedeid.checked then         
         oldencoder.ContainerName = "\Prime EID IP1 (basic PIN)\E"
       end if
       oldencoder.KeySpec = 2
       if tmpProviderType < 2 Then
          oldencoder.KeySpec = 1
       end if
       
       keysize = document.CertReqForm.keysize.value
       keymask = keysize * 65536
       
       oldencoder.GenKeyFlags = (keymask + 1) OR keyflags
       OldCSR = oldencoder.createPKCS10(szName, "")
       if len(OldCSR)<>0 then Exit Function
       oldencoder.GenKeyFlags = keymask OR keyflags
       OldCSR = oldencoder.createPKCS10(szName, "")
       if len(OldCSR)<>0 then Exit Function
       if oldencoder.providerName = "Microsoft Enhanced Cryptographic Provider v1.0" Then
          if MsgBox("1024-bit key generation failed. Would you like to try 512 instead?", vbOkCancel)=vbOk Then
             oldencoder.providerName = "Microsoft Base Cryptographic Provider v1.0"
          else
             Exit Function
          end if
       end if
       oldencoder.GenKeyFlags = 1 OR keyflags
       OldCSR = oldencoder.createPKCS10(szName, "")
       if len(OldCSR)<>0 then Exit Function
       oldencoder.GenKeyFlags = keyflags
       OldCSR = oldencoder.createPKCS10(szName, "")
       if len(OldCSR)<>0 then Exit Function
       oldencoder.GenKeyFlags = 0
       OldCSR = oldencoder.createPKCS10(szName, "")
    End Function

    Sub GenReq_OnClick
       Dim TheForm
       Dim szName

       Set TheForm = Document.CertReqForm
       err.clear

       szName = ""

       If Len(TheForm.countryName.value) <> 0 Then
         szName = szName + "C=" + TheForm.countryName.value + ","
       End If
       If Len(TheForm.stateOrProvinceName.value) <> 0 Then
         szName = szName + "S=" + TheForm.stateOrProvinceName.value + ","
       End If
       If Len(TheForm.localityName.value) <> 0 Then
         szName = szName + "L=" + TheForm.localityName.value + ","
       End If
       If Len(TheForm.organizationName.value) <> 0 Then
         szName = szName + "O=" + TheForm.organizationName.value + ","
       End If
       If Len(TheForm.organizationalUnitName.value) <> 0 Then
         szName = szName + "OU=" + TheForm.organizationalUnitName.value + ","
       End If
       If Len(TheForm.commonName.value) <> 0 Then
         szName = szName + "CN=" + TheForm.commonName.value + ","
       End If
       If Len(TheForm.emailAddress.value) <> 0 Then
         szName = szName + "E=" + TheForm.emailAddress.value + ","
       End If
       If Len(szName) <> 0 Then
         szName = Mid(szName,1,Len(szName)-1)
       End If
       
       
       If useold Then
         result = OldCSR(szName,2)
       Else
         result = NewCSR(szName,2)
       End If
       if len(result)=0 Then
          result = MsgBox("Unable to generate PKCS#10 certificate request.", 0, "Alert")
          Exit Sub
       end if
       TheForm.pkcs10.Value = result
       TheForm.Submit
       Exit Sub
    End Sub
-->      
</SCRIPT>



  <body onLoad="GetProviderList()" tal:define="DateTime python:modules['DateTime'].DateTime;Find python:modules['string'].find;IF python:lambda a,b,c:(a and [b] or [c])[0];ToInt python:modules['string'].atoi;Join python:modules['string'].join">
  
  <link href="styles.css" rel="stylesheet" type="text/css">

    <div metal:use-macro="container/index_html/macros/top" tal:omit-tag="" id="logo-sep">TOP</div>
    <!-- ###### NAVIGATION BAR ##### -->
    <div id="navigation-bar" metal:use-macro="container/index_html/macros/navigation">NAV BAR</div>
    <!-- ###### END NAVIGATION BAR ##### -->

    <!-- ###### MAIN CONTENT ##### -->
    <div id="main-content">
<form name="CertReqForm" action="manage_addCertificateRequest" method="post"><table class="table-group">
<INPUT TYPE="hidden" NAME="pkcs10" VALUE="">

  <tr>
    <td colspan="2" class="table-group-title">Client request for internet explorer</td>
  </tr>
  <tr tal:condition="python: len(template.policies) > 0 and len(template.policies[0]) > 0">
    <td class="table-group-row">Policy:</td>
    <td class="table-group-row"><select id="policy" name="policy">
          <span tal:omit-tag="" tal:repeat="policy python:template.policies"><option tal:define="values python:policy.split('|')" value="item" tal:attributes="value python:values[1]" tal:content="python:values[0]">item</option></span>
        </select>
	</td>
  </tr>
  <tr>
    <td style="vertical-align:top;" class="table-group-row">Keygen:</td>
    <td style="vertical-align:top;" class="table-group-row"><select name="keysize"><option value="512">512</option>
      <option value="1024" SELECTED>1024</option>
      <option value="2048">2048</option></select></td>
  </tr>
  <tr>
    <td style="vertical-align:top;" class="table-group-row">CSP:</td>
    <td style="vertical-align:top;" class="table-group-row">Choose the CSP from the list below if necessary. The default value is recommended in most cases.<br>If the drop-down list is empty, refer to the <a href="http://support.microsoft.com/default.aspx?scid=kb;EN-US;323172" target="_blank">Microsoft support issue Q323172.</a><br><br>
        <SELECT NAME="CspProvider"></SELECT></td>
  </tr>

  <tr>
    <td style="vertical-align:top;" class="table-group-row">&nbsp;</td>
    <td class="table-group-row"><INPUT TYPE="checkbox" NAME="enchancedeid" VALUE="false">Check if you are adding a certificate to an Enhanced eID card
    </td>
  </tr>
  <tr>
    <td class="table-group-row">country ISO code:</td>
    <td class="table-group-row">
      <input id="countryName" name="countryName"   maxlength="2" size="2" value="">
    </td>
  </tr>
  <tr>
    <td class="table-group-row">State/Province Name:</td>
    <td class="table-group-row">
      <input id="stateOrProvinceName" name="stateOrProvinceName"   maxlength="40" size="40" value="">
    </td>
  </tr>
  <tr>
    <td class="table-group-row">Location:</td>
    <td class="table-group-row">
      <input id="localityName" name="localityName" maxlength="40" size="40" value="">
    </td>
  </tr>
  <tr>
    <td class="table-group-row">Organization:</td>
    <td class="table-group-row">
      <input id="organizationName" name="organizationName" maxlength="40" size="40" value="">
    </td>
  </tr>
  <tr>
    <td class="table-group-row">Organizational Unit Name:</td>
    <td class="table-group-row">
      <input id="organizationalUnitName" name="organizationalUnitName" size="40" maxlength="40" >
    </td>
  </tr>
  <tr>
    <td class="table-group-row">Common Name:</td>
    <td class="table-group-row">
      <input id="commonName" name="commonName"   maxlength="64" size="40" value="">
    </td>
  </tr>

  <tr>
    <td class="table-group-row">Email Address:</td>
    <td class="table-group-row">
      <input id="emailAddress" name="emailAddress"   maxlength="64" size="40" value="">
    </td>
  </tr>

  <tr>
    <td colspan="2" class="table-group-row" align="center">	<input type="button" name="GenReq" value="submit">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input TYPE="reset" VALUE="Reset"></td>
  </tr>
</table>


</form>
    
	</div>
    <!-- ###### END MAIN CONTENT ##### -->

    <!-- ###### FOOTER ##### -->
    <p metal:use-macro="container/index_html/macros/footer" id="footer-bar" align="right">
      The  eye <img src="logo.gif" width="34" height="18">
    </p>
    <!-- ###### END FOOTER ##### -->



</body>
<object
   classid="clsid:127698e4-e730-4e5c-a2b1-21490a70c8a1"
   id="newencoder">
 </object>

<object
   classid="clsid:43F8F289-7A20-11D0-8F06-00C04FC295E1"
   id="oldencoder">
 </object>
</html>

