rem ---------------------------------------------------------------------------
rem --  Use this batch file to convert certificate generated by verisign 
rem -- 		to the format required by C/SSL.
rem --  Make sure to complete steps 1 - 7 before using this script.
rem --
rem --  Parameters:
rem --     %1 - password phrase (must match the value in mgreq.ini)
rem ---------------------------------------------------------------------------

rem ---------------------------------------------------------------------------
rem --
rem --  Phase 1 - Obtaining the test certificate from VeriSign :
rem --  --------------------------------------------------------
rem -- 
rem --  1. Go to http://www.verisign.com/client/enrollment/index.html .
rem --  2. Press on the green "Enroll now" button of the "Class 1 Digital ID".
rem --  3. Enter a name and a last name. Be sure to enter your correct email.
rem -- 	    "No" for "Include Additional Information?".  "<password>"
rem -- 	    (Important: Case sensitive!!!) for "Enter Challenge
rem --      Phrase:". Select the "I'd like to test drive a 60-day trial Digital ID
rem -- 	    for free." radio button. Leave all other fields
rem --      as is. Press "Accept" and confirm your email. Wait for the email from
rem -- 	    Verisign to arrive.
rem --  4. Copy the digital id pin supplied in the mail from Verisign and go to the
rem --      address supplied also in this mail.
rem --  5. Paste the pin and press "submit".
rem --  6. Press "install".
rem --  7. In the "Explorer", press "Tools"->"Internet Options"->
rem -- 	     "Content"->"Certificates"->"Personal"->Select the certificate you just now
rem --       installed->"Export"->Next->Select "Yes, export the private 
rem --       key"->Next->"Personal information exchange (*.pfx)" ***and*** "Include
rem --       all certificates in the certificate path if possible" ***and*** Enable
rem --       strong protection (Make sure that the two check boxes are
rem --       marked)->Next->"<password>"
rem --       (Important: Case sensitive!!!)" in the "password"
rem --       field and in the "confirm password" field->name the file "a" and Place
rem --       it where you have the new C/SSL version convert.exe->
rem --       Next->Finish->OK.
rem -- 
rem --  Phase 2 - Converting the certificate before activating Magic :
rem --  ---------------------------------------------------------------
rem -- 
rem --  11. Activate this batch file (pass the password as the first and only parameter).
rem --  12. Operate the server and the client as usual.
rem ---------------------------------------------------------------------------

convert -pkcs12 a.pfx "%1" toPEM -pkcs1 0.p1 -certificate 0.crt -certificate 1.crt -certificate 2.crt 
convert -certificate 0.crt -certificate 2.crt -certificate 1.crt -pkcs1 0.p1 toPEM -pkcs12 a.p12 "%1" 
convert -pkcs12 a.p12 "%1" toPEM -certificate 0.crt -certificate 1.crt -certificate caCerts.pem

attrib -r ..\root\VeriSign.pem
move caCerts.pem ..\root\VeriSign.pem
Copy a.p12 ..\personal\verisign\StrongServerRsa.pem
Copy a.p12 ..\personal\verisign\StrongClientRsa.pem

del 0.* 
del 1.* 
del 2.* 
del a.* 
