2
0

testss.bat 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. @echo off
  2. rem set ssleay=..\out\ssleay
  3. set ssleay=%1
  4. set reqcmd=%ssleay% req
  5. set x509cmd=%ssleay% x509
  6. set verifycmd=%ssleay% verify
  7. set CAkey=keyCA.ss
  8. set CAcert=certCA.ss
  9. set CAserial=certCA.srl
  10. set CAreq=reqCA.ss
  11. set CAconf=..\test\CAss.cnf
  12. set CAreq2=req2CA.ss
  13. set Uconf=..\test\Uss.cnf
  14. set Ukey=keyU.ss
  15. set Ureq=reqU.ss
  16. set Ucert=certU.ss
  17. echo make a certificate request using 'req'
  18. %reqcmd% -config %CAconf% -out %CAreq% -keyout %CAkey% -new
  19. if errorlevel 1 goto e_req
  20. echo convert the certificate request into a self signed certificate using 'x509'
  21. %x509cmd% -CAcreateserial -in %CAreq% -days 30 -req -out %CAcert% -signkey %CAkey% >err.ss
  22. if errorlevel 1 goto e_x509
  23. echo --
  24. echo convert a certificate into a certificate request using 'x509'
  25. %x509cmd% -in %CAcert% -x509toreq -signkey %CAkey% -out %CAreq2% >err.ss
  26. if errorlevel 1 goto e_x509_2
  27. %reqcmd% -verify -in %CAreq% -noout
  28. if errorlevel 1 goto e_vrfy_1
  29. %reqcmd% -verify -in %CAreq2% -noout
  30. if errorlevel 1 goto e_vrfy_2
  31. %verifycmd% -CAfile %CAcert% %CAcert%
  32. if errorlevel 1 goto e_vrfy_3
  33. echo --
  34. echo make another certificate request using 'req'
  35. %reqcmd% -config %Uconf% -out %Ureq% -keyout %Ukey% -new >err.ss
  36. if errorlevel 1 goto e_req_gen
  37. echo --
  38. echo sign certificate request with the just created CA via 'x509'
  39. %x509cmd% -CAcreateserial -in %Ureq% -days 30 -req -out %Ucert% -CA %CAcert% -CAkey %CAkey% -CAserial %CAserial%
  40. if errorlevel 1 goto e_x_sign
  41. %verifycmd% -CAfile %CAcert% %Ucert%
  42. echo --
  43. echo Certificate details
  44. %x509cmd% -subject -issuer -startdate -enddate -noout -in %Ucert%
  45. echo Everything appeared to work
  46. echo --
  47. echo The generated CA certificate is %CAcert%
  48. echo The generated CA private key is %CAkey%
  49. echo The current CA signing serial number is in %CAserial%
  50. echo The generated user certificate is %Ucert%
  51. echo The generated user private key is %Ukey%
  52. echo --
  53. del err.ss
  54. goto end
  55. :e_req
  56. echo error using 'req' to generate a certificate request
  57. goto end
  58. :e_x509
  59. echo error using 'x509' to self sign a certificate request
  60. goto end
  61. :e_x509_2
  62. echo error using 'x509' convert a certificate to a certificate request
  63. goto end
  64. :e_vrfy_1
  65. echo first generated request is invalid
  66. goto end
  67. :e_vrfy_2
  68. echo second generated request is invalid
  69. goto end
  70. :e_vrfy_3
  71. echo first generated cert is invalid
  72. goto end
  73. :e_req_gen
  74. echo error using 'req' to generate a certificate request
  75. goto end
  76. :e_x_sign
  77. echo error using 'x509' to sign a certificate request
  78. goto end
  79. :end