assemble-chains.sh 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. #!/bin/bash
  2. #
  3. # assemble-chains.sh
  4. # Create certs and assemble all the certificate CA path test cert chains.
  5. ###########################################################
  6. ########## update server-0-ca.pem ################
  7. ###########################################################
  8. echo "Updating server-0-ca.pem"
  9. echo ""
  10. #pipe the following arguments to openssl req...
  11. echo -e "US\nWashington\nSeattle\nwolfSSL Inc.\nEngineering\nServer 0 CA\ninfo@wolfssl.com\n.\n.\n" | openssl req -new -key ../server-key.pem -nodes -sha1 > server-0-ca-req.pem
  12. openssl x509 -req -in server-0-ca-req.pem -extfile ../renewcerts/wolfssl.cnf -extensions pathlen_0 -days 1000 -CA ../ca-cert.pem -CAkey ../ca-key.pem -set_serial 100 -sha1 > server-0-ca.pem
  13. rm server-0-ca-req.pem
  14. openssl x509 -in server-0-ca.pem -text > ca_tmp.pem
  15. mv ca_tmp.pem server-0-ca.pem
  16. ###########################################################
  17. ########## update server-0-cert.pem ################
  18. ###########################################################
  19. echo "Updating server-0-cert.pem"
  20. echo ""
  21. #pipe the following arguments to openssl req...
  22. echo -e "US\nWashington\nSeattle\nwolfSSL Inc.\nEngineering\nServer 0\ninfo@wolfssl.com\n.\n.\n" | openssl req -new -key ../server-key.pem -nodes -sha1 > server-0-cert-req.pem
  23. openssl x509 -req -in server-0-cert-req.pem -extfile ../renewcerts/wolfssl.cnf -extensions test_pathlen -days 1000 -CA server-0-ca.pem -CAkey ../server-key.pem -set_serial 101 -sha1 > server-0-cert.pem
  24. rm server-0-cert-req.pem
  25. openssl x509 -in server-0-cert.pem -text > cert_tmp.pem
  26. mv cert_tmp.pem server-0-cert.pem
  27. ###########################################################
  28. ########## update server-1-ca.pem ################
  29. ###########################################################
  30. echo "Updating server-1-ca.pem"
  31. echo ""
  32. #pipe the following arguments to openssl req...
  33. echo -e "US\nWashington\nSeattle\nwolfSSL Inc.\nEngineering\nServer 1 CA\ninfo@wolfssl.com\n.\n.\n" | openssl req -new -key ../server-key.pem -nodes -sha1 > server-1-ca-req.pem
  34. openssl x509 -req -in server-1-ca-req.pem -extfile ../renewcerts/wolfssl.cnf -extensions pathlen_1 -days 1000 -CA ../ca-cert.pem -CAkey ../ca-key.pem -set_serial 102 -sha1 > server-1-ca.pem
  35. rm server-1-ca-req.pem
  36. openssl x509 -in server-1-ca.pem -text > ca_tmp.pem
  37. mv ca_tmp.pem server-1-ca.pem
  38. ###########################################################
  39. ########## update server-1-cert.pem ################
  40. ###########################################################
  41. echo "Updating server-1-cert.pem"
  42. echo ""
  43. #pipe the following arguments to openssl req...
  44. echo -e "US\nWashington\nSeattle\nwolfSSL Inc.\nEngineering\nServer 1\ninfo@wolfssl.com\n.\n.\n" | openssl req -new -key ../server-key.pem -nodes -sha1 > server-1-cert-req.pem
  45. openssl x509 -req -in server-1-cert-req.pem -extfile ../renewcerts/wolfssl.cnf -extensions test_pathlen -days 1000 -CA server-1-ca.pem -CAkey ../server-key.pem -set_serial 105 -sha1 > server-1-cert.pem
  46. rm server-1-cert-req.pem
  47. openssl x509 -in server-1-cert.pem -text > cert_tmp.pem
  48. mv cert_tmp.pem server-1-cert.pem
  49. ###########################################################
  50. ########## update server-0-1-ca.pem ################
  51. ###########################################################
  52. echo "Updating server-0-1-ca.pem"
  53. echo ""
  54. #pipe the following arguments to openssl req...
  55. echo -e "US\nWashington\nSeattle\nwolfSSL Inc.\nEngineering\nServer 0-1 CA\ninfo@wolfssl.com\n.\n.\n" | openssl req -new -key ../server-key.pem -nodes -sha1 > server-0-1-ca-req.pem
  56. openssl x509 -req -in server-0-1-ca-req.pem -extfile ../renewcerts/wolfssl.cnf -extensions pathlen_1 -days 1000 -CA server-0-ca.pem -CAkey ../server-key.pem -set_serial 110 -sha1 > server-0-1-ca.pem
  57. rm server-0-1-ca-req.pem
  58. openssl x509 -in server-0-1-ca.pem -text > ca_tmp.pem
  59. mv ca_tmp.pem server-0-1-ca.pem
  60. ###########################################################
  61. ########## update server-0-1-cert.pem ################
  62. ###########################################################
  63. echo "Updating server-0-1-cert.pem"
  64. echo ""
  65. #pipe the following arguments to openssl req...
  66. echo -e "US\nWashington\nSeattle\nwolfSSL Inc.\nEngineering\nServer 0-1\ninfo@wolfssl.com\n.\n.\n" | openssl req -new -key ../server-key.pem -nodes -sha1 > server-0-1-cert-req.pem
  67. openssl x509 -req -in server-0-1-cert-req.pem -extfile ../renewcerts/wolfssl.cnf -extensions test_pathlen -days 1000 -CA server-0-1-ca.pem -CAkey ../server-key.pem -set_serial 111 -sha1 > server-0-1-cert.pem
  68. rm server-0-1-cert-req.pem
  69. openssl x509 -in server-0-1-cert.pem -text > cert_tmp.pem
  70. mv cert_tmp.pem server-0-1-cert.pem
  71. ###########################################################
  72. ########## update server-1-0-ca.pem ################
  73. ###########################################################
  74. echo "Updating server-1-0-ca.pem"
  75. echo ""
  76. #pipe the following arguments to openssl req...
  77. echo -e "US\nWashington\nSeattle\nwolfSSL Inc.\nEngineering\nServer 1-0 CA\ninfo@wolfssl.com\n.\n.\n" | openssl req -new -key ../server-key.pem -nodes -sha1 > server-1-0-ca-req.pem
  78. openssl x509 -req -in server-1-0-ca-req.pem -extfile ../renewcerts/wolfssl.cnf -extensions pathlen_0 -days 1000 -CA server-1-ca.pem -CAkey ../server-key.pem -set_serial 103 -sha1 > server-1-0-ca.pem
  79. rm server-1-0-ca-req.pem
  80. openssl x509 -in server-1-0-ca.pem -text > ca_tmp.pem
  81. mv ca_tmp.pem server-1-0-ca.pem
  82. ###########################################################
  83. ########## update server-1-0-cert.pem ################
  84. ###########################################################
  85. echo "Updating server-1-0-cert.pem"
  86. echo ""
  87. #pipe the following arguments to openssl req...
  88. echo -e "US\nWashington\nSeattle\nwolfSSL Inc.\nEngineering\nServer 1-0\ninfo@wolfssl.com\n.\n.\n" | openssl req -new -key ../server-key.pem -nodes -sha1 > server-1-0-cert-req.pem
  89. openssl x509 -req -in server-1-0-cert-req.pem -extfile ../renewcerts/wolfssl.cnf -extensions test_pathlen -days 1000 -CA server-1-0-ca.pem -CAkey ../server-key.pem -set_serial 104 -sha1 > server-1-0-cert.pem
  90. rm server-1-0-cert-req.pem
  91. openssl x509 -in server-1-0-cert.pem -text > cert_tmp.pem
  92. mv cert_tmp.pem server-1-0-cert.pem
  93. ###########################################################
  94. ########## update server-127-ca.pem ################
  95. ###########################################################
  96. echo "Updating server-127-ca.pem"
  97. echo ""
  98. #pipe the following arguments to openssl req...
  99. echo -e "US\nWashington\nSeattle\nwolfSSL Inc.\nEngineering\nServer 127 CA\ninfo@wolfssl.com\n.\n.\n" | openssl req -new -key ../server-key.pem -nodes -sha1 > server-127-ca-req.pem
  100. openssl x509 -req -in server-127-ca-req.pem -extfile ../renewcerts/wolfssl.cnf -extensions pathlen_127 -days 1000 -CA ../ca-cert.pem -CAkey ../ca-key.pem -set_serial 106 -sha1 > server-127-ca.pem
  101. rm server-127-ca-req.pem
  102. openssl x509 -in server-127-ca.pem -text > ca_tmp.pem
  103. mv ca_tmp.pem server-127-ca.pem
  104. ###########################################################
  105. ########## update server-127-cert.pem ################
  106. ###########################################################
  107. echo "Updating server-127-cert.pem"
  108. echo ""
  109. #pipe the following arguments to openssl req...
  110. echo -e "US\nWashington\nSeattle\nwolfSSL Inc.\nEngineering\nServer 127\ninfo@wolfssl.com\n.\n.\n" | openssl req -new -key ../server-key.pem -nodes -sha1 > server-127-cert-req.pem
  111. openssl x509 -req -in server-127-cert-req.pem -extfile ../renewcerts/wolfssl.cnf -extensions test_pathlen -days 1000 -CA server-127-ca.pem -CAkey ../server-key.pem -set_serial 107 -sha1 > server-127-cert.pem
  112. rm server-127-cert-req.pem
  113. openssl x509 -in server-127-cert.pem -text > cert_tmp.pem
  114. mv cert_tmp.pem server-127-cert.pem
  115. ###########################################################
  116. ########## update server-128-ca.pem ################
  117. ###########################################################
  118. echo "Updating server-128-ca.pem"
  119. echo ""
  120. #pipe the following arguments to openssl req...
  121. echo -e "US\nWashington\nSeattle\nwolfSSL Inc.\nEngineering\nServer 128 CA\ninfo@wolfssl.com\n.\n.\n" | openssl req -new -key ../server-key.pem -nodes -sha1 > server-128-ca-req.pem
  122. openssl x509 -req -in server-128-ca-req.pem -extfile ../renewcerts/wolfssl.cnf -extensions pathlen_128 -days 1000 -CA ../ca-cert.pem -CAkey ../ca-key.pem -set_serial 106 -sha1 > server-128-ca.pem
  123. rm server-128-ca-req.pem
  124. openssl x509 -in server-128-ca.pem -text > ca_tmp.pem
  125. mv ca_tmp.pem server-128-ca.pem
  126. ###########################################################
  127. ########## update server-128-cert.pem ################
  128. ###########################################################
  129. echo "Updating server-128-cert.pem"
  130. echo ""
  131. #pipe the following arguments to openssl req...
  132. echo -e "US\nWashington\nSeattle\nwolfSSL Inc.\nEngineering\nServer 128\ninfo@wolfssl.com\n.\n.\n" | openssl req -new -key ../server-key.pem -nodes -sha1 > server-128-cert-req.pem
  133. openssl x509 -req -in server-128-cert-req.pem -extfile ../renewcerts/wolfssl.cnf -extensions test_pathlen -days 1000 -CA server-128-ca.pem -CAkey ../server-key.pem -set_serial 107 -sha1 > server-128-cert.pem
  134. rm server-128-cert-req.pem
  135. openssl x509 -in server-128-cert.pem -text > cert_tmp.pem
  136. mv cert_tmp.pem server-128-cert.pem
  137. ###########################################################
  138. ########## Assemble Chains ################
  139. ###########################################################
  140. # Success: PathLen of 0
  141. ## server-0-ca.pem: signed by ca-cert.pem
  142. ## server-0-cert.pem: signed by server-0-ca.pem
  143. cat server-0-cert.pem server-0-ca.pem > server-0-chain.pem
  144. # Success: PathLen of 1
  145. ## server-1-ca.pem: signed by ca-cert.pem
  146. ## server-1-0-ca.pem: signed by server-1-ca.pem
  147. ## server-1-0-cert.pem: signed by server-1-0-ca.pem
  148. cat server-1-0-cert.pem server-1-0-ca.pem server-1-ca.pem > server-1-0-chain.pem
  149. ## server-1-cert.pem: signed by server-1-ca.pem
  150. cat server-1-cert.pem server-1-ca.pem > server-1-chain.pem
  151. # Success: PathLen of 127
  152. ## server-127-ca.pem: signed by ca-cert.pem
  153. ## server-127-cert.pem: signed by server-127-cert.pem
  154. cat server-127-cert.pem server-127-ca.pem > server-127-chain.pem
  155. # Failure: PathLen of 128
  156. ## server-128-ca.pem: signed by ca-cert.pem
  157. ## server-128-cert.pem: signed by server-128-ca.pem
  158. cat server-128-cert.pem server-128-ca.pem > server-128-chain.pem
  159. # Failure: PathLen of 0, signing PathLen of 1
  160. ## server-0-1-ca.pem: signed by server-0-ca.pem
  161. ## server-0-1-cert.pem: signed by server-0-1-ca.pem
  162. cat server-0-1-cert.pem server-0-1-ca.pem server-0-ca.pem > server-0-1-chain.pem