gencrls.sh 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. #!/bin/bash
  2. # gencrls, crl config already done, see taoCerts.txt for setup
  3. function setup_files() {
  4. #set up the file system for updating the crls
  5. echo "setting up the file system for generating the crls..."
  6. echo ""
  7. touch ./index.txt
  8. touch ./crlnumber
  9. echo "01" >> crlnumber
  10. touch ./blank.index.txt
  11. mkdir demoCA
  12. touch ./demoCA/index.txt
  13. }
  14. function cleanup_files() {
  15. rm blank.index.txt
  16. rm index.*
  17. rm crlnumber*
  18. rm -r demoCA
  19. echo "Removed ../wolfssl.cnf, blank.index.txt, index.*, crlnumber*, demoCA/"
  20. echo ""
  21. exit 0
  22. }
  23. trap cleanup_files EXIT
  24. #setup the files
  25. setup_files
  26. # caCrl
  27. # revoke server-revoked-cert.pem
  28. openssl ca -config ../renewcerts/wolfssl.cnf -revoke ../server-revoked-cert.pem -keyfile ../ca-key.pem -cert ../ca-cert.pem
  29. openssl ca -config ../renewcerts/wolfssl.cnf -gencrl -crldays 1000 -out crl.pem -keyfile ../ca-key.pem -cert ../ca-cert.pem
  30. # metadata
  31. openssl crl -in crl.pem -text > tmp
  32. mv tmp crl.pem
  33. # install (only needed if working outside wolfssl)
  34. #cp crl.pem ~/wolfssl/certs/crl/crl.pem
  35. # caCrl server revoked
  36. openssl ca -config ../renewcerts/wolfssl.cnf -revoke ../server-cert.pem -keyfile ../ca-key.pem -cert ../ca-cert.pem
  37. # caCrl server revoked generation
  38. openssl ca -config ../renewcerts/wolfssl.cnf -gencrl -crldays 1000 -out crl.revoked -keyfile ../ca-key.pem -cert ../ca-cert.pem
  39. # metadata
  40. openssl crl -in crl.revoked -text > tmp
  41. mv tmp crl.revoked
  42. # install (only needed if working outside wolfssl)
  43. #cp crl.revoked ~/wolfssl/certs/crl/crl.revoked
  44. # remove revoked so next time through the normal CA won't have server revoked
  45. cp blank.index.txt demoCA/index.txt
  46. # caEccCrl
  47. openssl ca -config ../renewcerts/wolfssl.cnf -revoke ../server-revoked-cert.pem -keyfile ../ca-ecc-key.pem -cert ../ca-ecc-cert.pem
  48. openssl ca -config ../renewcerts/wolfssl.cnf -gencrl -crldays 1000 -out caEccCrl.pem -keyfile ../ca-ecc-key.pem -cert ../ca-ecc-cert.pem
  49. # metadata
  50. openssl crl -in caEccCrl.pem -text > tmp
  51. mv tmp caEccCrl.pem
  52. # install (only needed if working outside wolfssl)
  53. #cp caEccCrl.pem ~/wolfssl/certs/crl/caEccCrl.pem
  54. # caEcc384Crl
  55. openssl ca -config ../renewcerts/wolfssl.cnf -revoke ../server-revoked-cert.pem -keyfile ../ca-ecc384-key.pem -cert ../ca-ecc384-cert.pem
  56. openssl ca -config ../renewcerts/wolfssl.cnf -gencrl -crldays 1000 -out caEcc384Crl.pem -keyfile ../ca-ecc384-key.pem -cert ../ca-ecc384-cert.pem
  57. # metadata
  58. openssl crl -in caEcc384Crl.pem -text > tmp
  59. mv tmp caEcc384Crl.pem
  60. # install (only needed if working outside wolfssl)
  61. #cp caEcc384Crl.pem ~/wolfssl/certs/crl/caEcc384Crl.pem
  62. # cliCrl
  63. openssl ca -config ../renewcerts/wolfssl.cnf -gencrl -crldays 1000 -out cliCrl.pem -keyfile ../client-key.pem -cert ../client-cert.pem
  64. # metadata
  65. openssl crl -in cliCrl.pem -text > tmp
  66. mv tmp cliCrl.pem
  67. # install (only needed if working outside wolfssl)
  68. #cp cliCrl.pem ~/wolfssl/certs/crl/cliCrl.pem
  69. # eccCliCRL
  70. openssl ca -config ../renewcerts/wolfssl.cnf -gencrl -crldays 1000 -out eccCliCRL.pem -keyfile ../ecc-client-key.pem -cert ../client-ecc-cert.pem
  71. # metadata
  72. openssl crl -in eccCliCRL.pem -text > tmp
  73. mv tmp eccCliCRL.pem
  74. # install (only needed if working outside wolfssl)
  75. #cp eccCliCRL.pem ~/wolfssl/certs/crl/eccCliCRL.pem
  76. # eccSrvCRL
  77. openssl ca -config ../renewcerts/wolfssl.cnf -gencrl -crldays 1000 -out eccSrvCRL.pem -keyfile ../ecc-key.pem -cert ../server-ecc.pem
  78. # metadata
  79. openssl crl -in eccSrvCRL.pem -text > tmp
  80. mv tmp eccSrvCRL.pem
  81. # install (only needed if working outside wolfssl)
  82. #cp eccSrvCRL.pem ~/wolfssl/certs/crl/eccSrvCRL.pem
  83. # caEccCrl
  84. openssl ca -config ../ecc/wolfssl.cnf -gencrl -crldays 1000 -out caEccCrl.pem -keyfile ../ca-ecc-key.pem -cert ../ca-ecc-cert.pem
  85. # ca-ecc384-cert
  86. openssl ca -config ../ecc/wolfssl.cnf -gencrl -crldays 1000 -out caEcc384Crl.pem -keyfile ../ca-ecc384-key.pem -cert ../ca-ecc384-cert.pem
  87. exit 0