renewcerts.sh 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808
  1. #!/bin/bash
  2. # renewcerts.sh
  3. #
  4. # renews the following certs:
  5. # client-cert.pem
  6. # client-cert.der
  7. # client-ecc-cert.pem
  8. # client-ecc-cert.der
  9. # ca-cert.pem
  10. # ca-cert.der
  11. # ca-ecc-cert.pem
  12. # ca-ecc-cert.der
  13. # ca-ecc384-cert.pem
  14. # ca-ecc384-cert.der
  15. # server-cert.pem
  16. # server-cert.der
  17. # server-cert-chain.der
  18. # server-ecc-rsa.pem
  19. # server-ecc.pem
  20. # 1024/client-cert.der
  21. # 1024/client-cert.pem
  22. # server-ecc-comp.pem
  23. # client-ca.pem
  24. # test/digsigku.pem
  25. # ecc-privOnlyCert.pem
  26. # client-uri-cert.pem
  27. # client-relative-uri.pem
  28. # client-crl-dist.pem
  29. # entity-no-ca-bool-cert.pem
  30. # updates the following crls:
  31. # crl/cliCrl.pem
  32. # crl/crl.pem
  33. # crl/crl.revoked
  34. # crl/eccCliCRL.pem
  35. # crl/eccSrvCRL.pem
  36. #
  37. # pkcs7:
  38. # test-degenerate.p7b
  39. ###############################################################################
  40. ######################## FUNCTIONS SECTION ####################################
  41. ###############################################################################
  42. #function for restoring a previous configure state
  43. restore_config(){
  44. mv tmp.status config.status
  45. mv tmp.options.h wolfssl/options.h
  46. make clean
  47. make -j 8
  48. }
  49. check_result(){
  50. if [ $1 -ne 0 ]; then
  51. echo "Failed at \"$2\", Abort"
  52. exit 1
  53. else
  54. echo "Step Succeeded!"
  55. fi
  56. }
  57. #the function that will be called when we are ready to renew the certs.
  58. run_renewcerts(){
  59. cd certs/ || { echo "Couldn't cd to certs directory"; exit 1; }
  60. echo ""
  61. #move the custom cnf into our working directory
  62. cp renewcerts/wolfssl.cnf wolfssl.cnf || exit 1
  63. # To generate these all in sha1 add the flag "-sha1" on appropriate lines
  64. # That is all lines beginning with: "openssl req"
  65. ############################################################
  66. #### update the self-signed (2048-bit) client-uri-cert.pem #
  67. ############################################################
  68. echo "Updating 2048-bit client-uri-cert.pem"
  69. echo ""
  70. #pipe the following arguments to openssl req...
  71. echo -e "US\\nMontana\\nBozeman\\nwolfSSL_2048\\nURI\\nwww.wolfssl.com\\ninfo@wolfssl.com\\n.\\n.\\n" | openssl req -new -key client-key.pem -config ./wolfssl.cnf -nodes -out client-cert.csr
  72. check_result $? "Step 1"
  73. openssl x509 -req -in client-cert.csr -days 1000 -extfile wolfssl.cnf -extensions uri -signkey client-key.pem -out client-uri-cert.pem
  74. check_result $? "Step 2"
  75. rm client-cert.csr
  76. openssl x509 -in client-uri-cert.pem -text > tmp.pem
  77. check_result $? "Step 3"
  78. mv tmp.pem client-uri-cert.pem
  79. echo "End of section"
  80. echo "---------------------------------------------------------------------"
  81. ############################################################
  82. # Public Versions of client-key.pem
  83. ############################################################
  84. openssl rsa -inform pem -in certs/client-key.pem -outform der -out certs/client-keyPub.der -pubout
  85. openssl rsa -inform pem -in certs/client-key.pem -outform pem -out certs/client-keyPub.pem -pubout
  86. ############################################################
  87. # Public Versions of server-key.pem
  88. ############################################################
  89. #openssl rsa -inform pem -in certs/server-key.pem -outform der -out certs/server-keyPub.der -pubout
  90. openssl rsa -inform pem -in certs/server-key.pem -outform pem -out certs/server-keyPub.pem -pubout
  91. ############################################################
  92. # Public Versions of ecc-key.pem
  93. ############################################################
  94. #openssl ec -inform pem -in certs/ecc-key.pem -outform der -out certs/ecc-keyPub.der -pubout
  95. openssl ec -inform pem -in certs/ecc-key.pem -outform pem -out certs/ecc-keyPub.pem -pubout
  96. ############################################################
  97. #### update the self-signed (2048-bit) client-relative-uri.pem
  98. ############################################################
  99. echo "Updating 2048-bit client-relative-uri.pem"
  100. echo ""
  101. #pipe the following arguments to openssl req...
  102. echo -e "US\\nMontana\\nBozeman\\nwolfSSL_2048\\nRELATIVE_URI\\nwww.wolfssl.com\\ninfo@wolfssl.com\\n.\\n.\\n" | openssl req -new -key client-key.pem -config ./wolfssl.cnf -nodes -out client-cert.csr
  103. check_result $? "Step 1"
  104. openssl x509 -req -in client-cert.csr -days 1000 -extfile wolfssl.cnf -extensions relative_uri -signkey client-key.pem -out client-relative-uri.pem
  105. check_result $? "Step 2"
  106. rm client-cert.csr
  107. openssl x509 -in client-relative-uri.pem -text > tmp.pem
  108. check_result $? "Step 3"
  109. mv tmp.pem client-relative-uri.pem
  110. echo "End of section"
  111. echo "---------------------------------------------------------------------"
  112. ############################################################
  113. #### update the self-signed (2048-bit) client-crl-dist.pem
  114. ############################################################
  115. echo "Updating 2048-bit client-crl-dist.pem"
  116. echo ""
  117. #pipe the following arguments to openssl req...
  118. echo -e "US\\nMontana\\nBozeman\\nwolfSSL_2048\\nCRL_DIST\\nwww.wolfssl.com\\ninfo@wolfssl.com\\n.\\n.\\n" | openssl req -new -key client-key.pem -config ./wolfssl.cnf -nodes -out client-cert.csr
  119. check_result $? "Step 1"
  120. openssl x509 -req -in client-cert.csr -days 1000 -extfile wolfssl.cnf -extensions crl_dist_points -signkey client-key.pem -out client-crl-dist.pem
  121. check_result $? "Step 2"
  122. rm client-cert.csr
  123. openssl x509 -in client-crl-dist.pem -text > tmp.pem
  124. check_result $? "Step 3"
  125. mv tmp.pem client-crl-dist.pem
  126. openssl x509 -in client-crl-dist.pem -outform der -out client-crl-dist.der
  127. echo "End of section"
  128. echo "---------------------------------------------------------------------"
  129. ############################################################
  130. #### update the self-signed (2048-bit) client-cert.pem #####
  131. ############################################################
  132. echo "Updating 2048-bit client-cert.pem"
  133. echo ""
  134. #pipe the following arguments to openssl req...
  135. echo -e "US\\nMontana\\nBozeman\\nwolfSSL_2048\\nProgramming-2048\\nwww.wolfssl.com\\ninfo@wolfssl.com\\n.\\n.\\n" | openssl req -new -key client-key.pem -config ./wolfssl.cnf -nodes -out client-cert.csr
  136. check_result $? "Step 1"
  137. openssl x509 -req -in client-cert.csr -days 1000 -extfile wolfssl.cnf -extensions wolfssl_opts -signkey client-key.pem -out client-cert.pem
  138. check_result $? "Step 2"
  139. rm client-cert.csr
  140. openssl x509 -in client-cert.pem -text > tmp.pem
  141. check_result $? "Step 3"
  142. mv tmp.pem client-cert.pem
  143. echo "End of section"
  144. echo "---------------------------------------------------------------------"
  145. ############################################################
  146. #### update the self-signed (1024-bit) client-cert.pem #####
  147. ############################################################
  148. echo "Updating 1024-bit client-cert.pem"
  149. echo ""
  150. #pipe the following arguments to openssl req...
  151. echo -e "US\\nMontana\\nBozeman\\nwolfSSL_1024\\nProgramming-1024\\nwww.wolfssl.com\\ninfo@wolfssl.com\\n.\\n.\\n" | openssl req -new -key ./1024/client-key.pem -config ./wolfssl.cnf -nodes -out ./1024/client-cert.csr
  152. check_result $? "Step 1"
  153. openssl x509 -req -in ./1024/client-cert.csr -days 1000 -extfile wolfssl.cnf -extensions wolfssl_opts -signkey ./1024/client-key.pem -out ./1024/client-cert.pem
  154. check_result $? "Step 2"
  155. rm ./1024/client-cert.csr
  156. openssl x509 -in ./1024/client-cert.pem -text > ./1024/tmp.pem
  157. check_result $? "Step 3"
  158. mv ./1024/tmp.pem ./1024/client-cert.pem
  159. echo "End of section"
  160. echo "---------------------------------------------------------------------"
  161. ############################################################
  162. #### update the self-signed (3072-bit) client-cert.pem #####
  163. ############################################################
  164. echo "Updating 3072-bit client-cert.pem"
  165. echo ""
  166. #pipe the following arguments to openssl req...
  167. echo -e "US\\nMontana\\nBozeman\\nwolfSSL_3072\\nProgramming-3072\\nwww.wolfssl.com\\ninfo@wolfssl.com\\n.\\n.\\n" | openssl req -new -key ./3072/client-key.pem -config ./wolfssl.cnf -nodes -out ./3072/client-cert.csr
  168. check_result $? "Step 1"
  169. openssl x509 -req -in ./3072/client-cert.csr -days 1000 -extfile wolfssl.cnf -extensions wolfssl_opts -signkey ./3072/client-key.pem -out ./3072/client-cert.pem
  170. check_result $? "Step 2"
  171. rm ./3072/client-cert.csr
  172. openssl x509 -in ./3072/client-cert.pem -text > ./3072/tmp.pem
  173. check_result $? "Step 3"
  174. mv ./3072/tmp.pem ./3072/client-cert.pem
  175. openssl rsa -in ./3072/client-key.pem -outform der -out ./3072/client-key.der
  176. openssl rsa -inform pem -in ./3072/client-key.pem -outform der -out ./3072/client-keyPub.der -pubout
  177. openssl x509 -in ./3072/client-cert.pem -outform der -out ./3072/client-cert.der
  178. echo "End of section"
  179. echo "---------------------------------------------------------------------"
  180. ############################################################
  181. #### update the self-signed (4096-bit) client-cert.pem #####
  182. ############################################################
  183. echo "Updating 4096-bit client-cert.pem"
  184. echo ""
  185. #pipe the following arguments to openssl req...
  186. echo -e "US\\nMontana\\nBozeman\\nwolfSSL_4096\\nProgramming-4096\\nwww.wolfssl.com\\ninfo@wolfssl.com\\n.\\n.\\n" | openssl req -new -key ./4096/client-key.pem -config ./wolfssl.cnf -nodes -out ./4096/client-cert.csr
  187. check_result $? "Step 1"
  188. openssl x509 -req -in ./4096/client-cert.csr -days 1000 -extfile wolfssl.cnf -extensions wolfssl_opts -signkey ./4096/client-key.pem -out ./4096/client-cert.pem
  189. check_result $? "Step 2"
  190. rm ./4096/client-cert.csr
  191. openssl x509 -in ./4096/client-cert.pem -text > ./4096/tmp.pem
  192. check_result $? "Step 3"
  193. mv ./4096/tmp.pem ./4096/client-cert.pem
  194. openssl rsa -in ./4096/client-key.pem -outform der -out ./4096/client-key.der
  195. openssl rsa -inform pem -in ./4096/client-key.pem -outform der -out ./4096/client-keyPub.der -pubout
  196. openssl x509 -in ./4096/client-cert.pem -outform der -out ./4096/client-cert.der
  197. echo "End of section"
  198. echo "---------------------------------------------------------------------"
  199. ############################################################
  200. ########## update the self-signed ca-cert.pem ##############
  201. ############################################################
  202. echo "Updating ca-cert.pem"
  203. echo ""
  204. #pipe the following arguments to openssl req...
  205. echo -e "US\\nMontana\\nBozeman\\nSawtooth\\nConsulting\\nwww.wolfssl.com\\ninfo@wolfssl.com\\n.\\n.\\n" | openssl req -new -key ca-key.pem -config ./wolfssl.cnf -nodes -out ca-cert.csr
  206. check_result $? "Step 1"
  207. openssl x509 -req -in ca-cert.csr -days 1000 -extfile wolfssl.cnf -extensions wolfssl_opts -signkey ca-key.pem -out ca-cert.pem
  208. check_result $? "Step 2"
  209. rm ca-cert.csr
  210. openssl x509 -in ca-cert.pem -text > tmp.pem
  211. check_result $? "Step 3"
  212. mv tmp.pem ca-cert.pem
  213. echo "End of section"
  214. echo "---------------------------------------------------------------------"
  215. ############################################################
  216. ########## update the self-signed ca-cert-chain.der ########
  217. ############################################################
  218. echo "Updating ca-cert-chain.der"
  219. echo ""
  220. #pipe the following arguments to openssl req...
  221. echo -e "US\\nMontana\\nBozeman\\nSawtooth\\nConsulting\\nwww.wolfssl.com\\ninfo@wolfssl.com\\n.\\n.\\n" | openssl req -new -key 1024/ca-key.pem -config ./wolfssl.cnf -nodes -out ca-cert.csr
  222. check_result $? "Step 1"
  223. openssl x509 -req -in ca-cert.csr -days 1000 -extfile wolfssl.cnf -extensions wolfssl_opts -signkey 1024/ca-key.pem -outform DER -out ca-cert-chain.der
  224. check_result $? "Step 2"
  225. rm ca-cert.csr
  226. echo "End of section"
  227. echo "---------------------------------------------------------------------"
  228. ############################################################
  229. ########## update the self-signed ca-ecc-cert.pem ##########
  230. ############################################################
  231. echo "Updating ca-ecc-cert.pem"
  232. echo ""
  233. #pipe the following arguments to openssl req...
  234. echo -e "US\\nWashington\\nSeattle\\nwolfSSL\\nDevelopment\\nwww.wolfssl.com\\ninfo@wolfssl.com\\n.\\n.\\n" | openssl req -new -key ca-ecc-key.pem -config ./wolfssl.cnf -nodes -out ca-ecc-cert.csr
  235. check_result $? "Step 1"
  236. openssl x509 -req -in ca-ecc-cert.csr -days 1000 -extfile wolfssl.cnf -extensions ca_ecc_cert -signkey ca-ecc-key.pem -out ca-ecc-cert.pem
  237. check_result $? "Step 2"
  238. rm ca-ecc-cert.csr
  239. openssl x509 -in ca-ecc-cert.pem -text > tmp.pem
  240. check_result $? "Step 3"
  241. mv tmp.pem ca-ecc-cert.pem
  242. echo "End of section"
  243. echo "---------------------------------------------------------------------"
  244. ############################################################
  245. ########## update the self-signed ca-ecc384-cert.pem #######
  246. ############################################################
  247. echo "Updating ca-ecc384-cert.pem"
  248. echo ""
  249. #pipe the following arguments to openssl req...
  250. echo -e "US\\nWashington\\nSeattle\\nwolfSSL\\nDevelopment\\nwww.wolfssl.com\\ninfo@wolfssl.com\\n.\\n.\\n" | openssl req -new -key ca-ecc384-key.pem -config ./wolfssl.cnf -nodes -sha384 -out ca-ecc384-cert.csr
  251. check_result $? "Step 1"
  252. openssl x509 -req -in ca-ecc384-cert.csr -days 1000 -extfile wolfssl.cnf -extensions ca_ecc_cert -signkey ca-ecc384-key.pem -sha384 -out ca-ecc384-cert.pem
  253. check_result $? "Step 2"
  254. rm ca-ecc384-cert.csr
  255. openssl x509 -in ca-ecc384-cert.pem -text > tmp.pem
  256. check_result $? "Step 3"
  257. mv tmp.pem ca-ecc384-cert.pem
  258. echo "End of section"
  259. echo "---------------------------------------------------------------------"
  260. ############################################################
  261. ##### update the self-signed (1024-bit) ca-cert.pem ########
  262. ############################################################
  263. echo "Updating 1024-bit ca-cert.pem"
  264. echo ""
  265. #pipe the following arguments to openssl req...
  266. echo -e "US\\nMontana\\nBozeman\\nSawtooth\\nConsulting_1024\\nwww.wolfssl.com\\ninfo@wolfssl.com\\n.\\n.\\n" | openssl req -new -key ./1024/ca-key.pem -config ./wolfssl.cnf -nodes -sha1 -out ./1024/ca-cert.csr
  267. check_result $? "Step 1"
  268. openssl x509 -req -in ./1024/ca-cert.csr -days 1000 -extfile wolfssl.cnf -extensions wolfssl_opts -signkey ./1024/ca-key.pem -out ./1024/ca-cert.pem
  269. check_result $? "Step 2"
  270. rm ./1024/ca-cert.csr
  271. openssl x509 -in ./1024/ca-cert.pem -text > ./1024/tmp.pem
  272. check_result $? "Step 3"
  273. mv ./1024/tmp.pem ./1024/ca-cert.pem
  274. echo "End of section"
  275. echo "---------------------------------------------------------------------"
  276. ###########################################################
  277. ########## update and sign server-cert.pem ################
  278. ###########################################################
  279. echo "Updating server-cert.pem"
  280. echo ""
  281. #pipe the following arguments to openssl req...
  282. echo -e "US\\nMontana\\nBozeman\\nwolfSSL\\nSupport\\nwww.wolfssl.com\\ninfo@wolfssl.com\\n.\\n.\\n" | openssl req -new -key server-key.pem -config ./wolfssl.cnf -nodes > server-req.pem
  283. check_result $? "Step 1"
  284. openssl x509 -req -in server-req.pem -extfile wolfssl.cnf -extensions wolfssl_opts -days 1000 -CA ca-cert.pem -CAkey ca-key.pem -set_serial 01 > server-cert.pem
  285. check_result $? "Step 2"
  286. rm server-req.pem
  287. openssl x509 -in ca-cert.pem -text > ca_tmp.pem
  288. check_result $? "Step 3"
  289. openssl x509 -in server-cert.pem -text > srv_tmp.pem
  290. check_result $? "Step 4"
  291. mv srv_tmp.pem server-cert.pem
  292. cat ca_tmp.pem >> server-cert.pem
  293. rm ca_tmp.pem
  294. echo "End of section"
  295. echo "---------------------------------------------------------------------"
  296. ###########################################################
  297. ########## update and sign server-revoked-key.pem #########
  298. ###########################################################
  299. echo "Updating server-revoked-cert.pem"
  300. echo ""
  301. #pipe the following arguments to openssl req...
  302. echo -e "US\\nMontana\\nBozeman\\nwolfSSL_revoked\\nSupport_revoked\\nwww.wolfssl.com\\ninfo@wolfssl.com\\n.\\n.\\n" | openssl req -new -key server-revoked-key.pem -config ./wolfssl.cnf -nodes > server-revoked-req.pem
  303. check_result $? "Step 1"
  304. openssl x509 -req -in server-revoked-req.pem -extfile wolfssl.cnf -extensions wolfssl_opts -days 1000 -CA ca-cert.pem -CAkey ca-key.pem -set_serial 02 > server-revoked-cert.pem
  305. check_result $? "Step 2"
  306. rm server-revoked-req.pem
  307. openssl x509 -in ca-cert.pem -text > ca_tmp.pem
  308. check_result $? "Step 3"
  309. openssl x509 -in server-revoked-cert.pem -text > srv_tmp.pem
  310. check_result $? "Step 4"
  311. mv srv_tmp.pem server-revoked-cert.pem
  312. cat ca_tmp.pem >> server-revoked-cert.pem
  313. rm ca_tmp.pem
  314. echo "End of section"
  315. echo "---------------------------------------------------------------------"
  316. ###########################################################
  317. ########## update and sign server-duplicate-policy.pem ####
  318. ###########################################################
  319. echo "Updating server-duplicate-policy.pem"
  320. echo ""
  321. #pipe the following arguments to openssl req...
  322. echo -e "US\\nMontana\\nBozeman\\nwolfSSL\\ntesting duplicate policy\\nwww.wolfssl.com\\ninfo@wolfssl.com\\n.\\n.\\n" | openssl req -new -key server-key.pem -config ./wolfssl.cnf -nodes > ./test/server-duplicate-policy-req.pem
  323. check_result $? "Step 1"
  324. openssl x509 -req -in ./test/server-duplicate-policy-req.pem -extfile wolfssl.cnf -extensions policy_test -days 1000 -CA ca-cert.pem -CAkey ca-key.pem -set_serial 02 > ./test/server-duplicate-policy.pem
  325. check_result $? "Step 2"
  326. rm ./test/server-duplicate-policy-req.pem
  327. openssl x509 -in ca-cert.pem -text > ca_tmp.pem
  328. check_result $? "Step 3"
  329. openssl x509 -in ./test/server-duplicate-policy.pem -text > srv_tmp.pem
  330. check_result $? "Step 4"
  331. mv srv_tmp.pem ./test/server-duplicate-policy.pem
  332. cat ca_tmp.pem >> ./test/server-duplicate-policy.pem
  333. rm ca_tmp.pem
  334. echo "End of section"
  335. echo "---------------------------------------------------------------------"
  336. ###########################################################
  337. #### update and sign (1024-bit) server-cert.pem ###########
  338. ###########################################################
  339. echo "Updating 1024-bit server-cert.pem"
  340. echo ""
  341. #pipe the following arguments to openssl req...
  342. echo -e "US\\nMontana\\nBozeman\\nwolfSSL\\nSupport_1024\\nwww.wolfssl.com\\ninfo@wolfssl.com\\n.\\n.\\n" | openssl req -new -key ./1024/server-key.pem -config ./wolfssl.cnf -nodes -sha1 > ./1024/server-req.pem
  343. check_result $? "Step 1"
  344. openssl x509 -req -in ./1024/server-req.pem -extfile wolfssl.cnf -extensions wolfssl_opts -days 1000 -CA ./1024/ca-cert.pem -CAkey ./1024/ca-key.pem -set_serial 01 > ./1024/server-cert.pem
  345. check_result $? "Step 2"
  346. rm ./1024/server-req.pem
  347. openssl x509 -in ./1024/ca-cert.pem -text > ./1024/ca_tmp.pem
  348. check_result $? "Step 3"
  349. openssl x509 -in ./1024/server-cert.pem -text > ./1024/srv_tmp.pem
  350. check_result $? "Step 4"
  351. mv ./1024/srv_tmp.pem ./1024/server-cert.pem
  352. cat ./1024/ca_tmp.pem >> ./1024/server-cert.pem
  353. rm ./1024/ca_tmp.pem
  354. echo "End of section"
  355. echo "---------------------------------------------------------------------"
  356. ############################################################
  357. ########## update and sign the server-ecc-rsa.pem ##########
  358. ############################################################
  359. echo "Updating server-ecc-rsa.pem"
  360. echo ""
  361. echo -e "US\\nMontana\\nBozeman\\nElliptic - RSAsig\\nECC-RSAsig\\nwww.wolfssl.com\\ninfo@wolfssl.com\\n.\\n.\\n" | openssl req -new -key ecc-key.pem -config ./wolfssl.cnf -nodes > server-ecc-req.pem
  362. check_result $? "Step 1"
  363. openssl x509 -req -in server-ecc-req.pem -extfile wolfssl.cnf -extensions wolfssl_opts -days 1000 -CA ca-cert.pem -CAkey ca-key.pem -set_serial 01 > server-ecc-rsa.pem
  364. check_result $? "Step 2"
  365. rm server-ecc-req.pem
  366. openssl x509 -in server-ecc-rsa.pem -text > tmp.pem
  367. check_result $? "Step 3"
  368. mv tmp.pem server-ecc-rsa.pem
  369. echo "End of section"
  370. echo "---------------------------------------------------------------------"
  371. ############################################################
  372. ####### update the self-signed client-ecc-cert.pem #########
  373. ############################################################
  374. echo "Updating client-ecc-cert.pem"
  375. echo ""
  376. #pipe the following arguments to openssl req...
  377. echo -e "US\\nOregon\\nSalem\\nClient ECC\\nFast\\nwww.wolfssl.com\\ninfo@wolfssl.com\\n.\\n.\\n" | openssl req -new -key ecc-client-key.pem -config ./wolfssl.cnf -nodes -out client-ecc-cert.csr
  378. check_result $? "Step 1"
  379. openssl x509 -req -in client-ecc-cert.csr -days 1000 -extfile wolfssl.cnf -extensions wolfssl_opts -signkey ecc-client-key.pem -out client-ecc-cert.pem
  380. check_result $? "Step 2"
  381. rm client-ecc-cert.csr
  382. openssl x509 -in client-ecc-cert.pem -text > tmp.pem
  383. check_result $? "Step 3"
  384. mv tmp.pem client-ecc-cert.pem
  385. echo "End of section"
  386. echo "---------------------------------------------------------------------"
  387. ############################################################
  388. ########## update the server-ecc.pem #######################
  389. ############################################################
  390. echo "Updating server-ecc.pem"
  391. echo ""
  392. #pipe the following arguments to openssl req...
  393. echo -e "US\\nWashington\\nSeattle\\nEliptic\\nECC\\nwww.wolfssl.com\\ninfo@wolfssl.com\\n.\\n.\\n" | openssl req -new -key ecc-key.pem -config ./wolfssl.cnf -nodes -out server-ecc.csr
  394. check_result $? "Step 1"
  395. openssl x509 -req -in server-ecc.csr -days 1000 -extfile wolfssl.cnf -extensions server_ecc -CA ca-ecc-cert.pem -CAkey ca-ecc-key.pem -set_serial 03 -out server-ecc.pem
  396. check_result $? "Step 2"
  397. rm server-ecc.csr
  398. openssl x509 -in server-ecc.pem -text > tmp.pem
  399. check_result $? "Step 3"
  400. mv tmp.pem server-ecc.pem
  401. echo "End of section"
  402. echo "---------------------------------------------------------------------"
  403. ############################################################
  404. ###### update the self-signed server-ecc-comp.pem ##########
  405. ############################################################
  406. echo "Updating server-ecc-comp.pem"
  407. echo ""
  408. #pipe the following arguments to openssl req...
  409. echo -e "US\\nMontana\\nBozeman\\nElliptic - comp\\nServer ECC-comp\\nwww.wolfssl.com\\ninfo@wolfssl.com\\n.\\n.\\n" | openssl req -new -key ecc-key-comp.pem -config ./wolfssl.cnf -nodes -out server-ecc-comp.csr
  410. check_result $? "Step 1"
  411. openssl x509 -req -in server-ecc-comp.csr -days 1000 -extfile wolfssl.cnf -extensions wolfssl_opts -signkey ecc-key-comp.pem -out server-ecc-comp.pem
  412. check_result $? "Step 2"
  413. rm server-ecc-comp.csr
  414. openssl x509 -in server-ecc-comp.pem -text > tmp.pem
  415. check_result $? "Step 3"
  416. mv tmp.pem server-ecc-comp.pem
  417. echo "End of section"
  418. echo "---------------------------------------------------------------------"
  419. ############################################################
  420. ############## create the client-ca.pem file ###############
  421. ############################################################
  422. echo "Updating client-ca.pem"
  423. echo ""
  424. cat client-cert.pem client-ecc-cert.pem > client-ca.pem
  425. echo "End of section"
  426. echo "---------------------------------------------------------------------"
  427. ############################################################
  428. ###### update the self-signed ecc-privOnlyCert.pem #########
  429. ############################################################
  430. echo "Updating ecc-privOnlyCert.pem"
  431. echo ""
  432. #pipe the following arguments to openssl req...
  433. echo -e ".\\n.\\n.\\nWR\\n.\\nDE\\n.\\n.\\n.\\n" | openssl req -new -key ecc-privOnlyKey.pem -config ./wolfssl.cnf -nodes -out ecc-privOnly.csr
  434. check_result $? "Step 1"
  435. openssl x509 -req -in ecc-privOnly.csr -days 1000 -signkey ecc-privOnlyKey.pem -out ecc-privOnlyCert.pem
  436. check_result $? "Step 2"
  437. rm ecc-privOnly.csr
  438. echo "End of section"
  439. echo "---------------------------------------------------------------------"
  440. ############################################################
  441. ###### update the self-signed test/digsigku.pem ##########
  442. ############################################################
  443. echo "Updating test/digsigku.pem"
  444. echo ""
  445. #pipe the following arguments to openssl req...
  446. echo -e "US\\nWashington\\nSeattle\\nFoofarah\\nArglebargle\\nfoobarbaz\\ninfo@worlss.com\\n.\\n.\\n" | openssl req -new -key ecc-key.pem -config ./wolfssl.cnf -nodes -sha1 -out digsigku.csr
  447. check_result $? "Step 1"
  448. openssl x509 -req -in digsigku.csr -days 1000 -extfile wolfssl.cnf -extensions digsigku -signkey ecc-key.pem -sha1 -set_serial 16393466893990650224 -out digsigku.pem
  449. check_result $? "Step 2"
  450. rm digsigku.csr
  451. openssl x509 -in digsigku.pem -text > tmp.pem
  452. check_result $? "Step 3"
  453. mv tmp.pem digsigku.pem
  454. mv digsigku.pem test/digsigku.pem
  455. echo "End of section"
  456. echo "---------------------------------------------------------------------"
  457. ###########################################################
  458. #### update and sign entity-no-ca-bool-cert.pem ###########
  459. ###########################################################
  460. echo "Updating entity-no-ca-bool-cert.pem"
  461. echo ""
  462. #pipe the following arguments to openssl req...
  463. echo -e "US\\nMontana\\nBozeman\\nwolfSSL\\nNoCaBool\\nwww.wolfssl.com\\ninfo@wolfssl.com\\n.\\n.\\n" | openssl req -new -key entity-no-ca-bool-key.pem -config ./wolfssl.cnf -nodes > entity-no-ca-bool-req.pem
  464. check_result $? "Step 1"
  465. openssl x509 -req -in entity-no-ca-bool-req.pem -extfile ./wolfssl.cnf -extensions "entity_no_CA_BOOL" -days 1000 -CA ca-cert.pem -CAkey ca-key.pem -set_serial 01 > entity-no-ca-bool-cert.pem
  466. check_result $? "Step 2"
  467. rm entity-no-ca-bool-req.pem
  468. openssl x509 -in ca-cert.pem -text > ca_tmp.pem
  469. check_result $? "Step 3"
  470. openssl x509 -in entity-no-ca-bool-cert.pem -text > entity_tmp.pem
  471. check_result $? "Step 4"
  472. mv entity_tmp.pem entity-no-ca-bool-cert.pem
  473. cat ca_tmp.pem >> entity-no-ca-bool-cert.pem
  474. rm ca_tmp.pem
  475. echo "End of section"
  476. ############################################################
  477. ########## make .der files from .pem files #################
  478. ############################################################
  479. echo "Creating der formatted certs..."
  480. echo ""
  481. openssl x509 -inform PEM -in ./1024/client-cert.pem -outform DER -out ./1024/client-cert.der
  482. check_result $? "Der Cert 1"
  483. openssl x509 -inform PEM -in ./1024/server-cert.pem -outform DER -out ./1024/server-cert.der
  484. check_result $? "Der Cert 2"
  485. openssl x509 -inform PEM -in ./1024/ca-cert.pem -outform DER -out ./1024/ca-cert.der
  486. check_result $? "Der Cert 3"
  487. openssl x509 -inform PEM -in ca-cert.pem -outform DER -out ca-cert.der
  488. check_result $? "Der Cert 4"
  489. openssl x509 -inform PEM -in ca-ecc-cert.pem -outform DER -out ca-ecc-cert.der
  490. check_result $? "Der Cert 5"
  491. openssl x509 -inform PEM -in ca-ecc384-cert.pem -outform DER -out ca-ecc384-cert.der
  492. check_result $? "Der Cert 6"
  493. openssl x509 -inform PEM -in client-cert.pem -outform DER -out client-cert.der
  494. check_result $? "Der Cert 7"
  495. openssl x509 -inform PEM -in server-cert.pem -outform DER -out server-cert.der
  496. check_result $? "Der Cert 8"
  497. openssl x509 -inform PEM -in client-ecc-cert.pem -outform DER -out client-ecc-cert.der
  498. check_result $? "Der Cert 9"
  499. openssl x509 -inform PEM -in server-ecc-rsa.pem -outform DER -out server-ecc-rsa.der
  500. check_result $? "Der Cert 10"
  501. openssl x509 -inform PEM -in server-ecc.pem -outform DER -out server-ecc.der
  502. check_result $? "Der Cert 11"
  503. openssl x509 -inform PEM -in server-ecc-comp.pem -outform DER -out server-ecc-comp.der
  504. check_result $? "Der Cert 12"
  505. cat server-cert.der ca-cert.der >server-cert-chain.der
  506. check_result $? "Der Cert 13"
  507. echo "End of section"
  508. echo "---------------------------------------------------------------------"
  509. ############################################################
  510. ########## generate Ed25519 certificates ###################
  511. ############################################################
  512. echo "Renewing Ed448 certificates"
  513. cd ed25519
  514. ./gen-ed25519-certs.sh
  515. cd ..
  516. echo "End of section"
  517. echo "---------------------------------------------------------------------"
  518. ############################################################
  519. ########## generate Ed448 certificates #####################
  520. ############################################################
  521. echo "Renewing Ed448 certificates"
  522. cd ed448
  523. ./gen-ed448-certs.sh
  524. cd ..
  525. echo "End of section"
  526. echo "---------------------------------------------------------------------"
  527. ############################################################
  528. ########## generate P-521 certificates #####################
  529. ############################################################
  530. echo "Renewing Ed448 certificates"
  531. cd p521
  532. ./gen-p521-certs.sh
  533. cd ..
  534. echo "End of section"
  535. echo "---------------------------------------------------------------------"
  536. ############################################################
  537. ###### update the ecc-rsa-server.p12 file ##################
  538. ############################################################
  539. echo "Updating ecc-rsa-server.p12 (password is \"\")"
  540. echo ""
  541. echo "" | openssl pkcs12 -des3 -descert -export -in server-ecc-rsa.pem -inkey ecc-key.pem -certfile server-ecc.pem -out ecc-rsa-server.p12 -password stdin
  542. check_result $? "Step 1"
  543. echo "End of section"
  544. echo "---------------------------------------------------------------------"
  545. ############################################################
  546. ###### update the test-servercert.p12 file #################
  547. ############################################################
  548. echo "Updating test-servercert.p12 (password is \"wolfSSL test\")"
  549. echo ""
  550. echo "wolfSSL test" | openssl pkcs12 -des3 -descert -export -in server-cert.pem -inkey server-key.pem -certfile ca-cert.pem -out test-servercert.p12 -password stdin
  551. check_result $? "Step 1"
  552. echo "End of section"
  553. echo "---------------------------------------------------------------------"
  554. ############################################################
  555. ###### update the test-servercert-rc2.p12 file #############
  556. ############################################################
  557. echo "Updating test-servercert-rc2.p12 (password is \"wolfSSL test\")"
  558. echo ""
  559. echo "wolfSSL test" | openssl pkcs12 -export -in server-cert.pem -inkey server-key.pem -certfile ca-cert.pem -out test-servercert-rc2.p12 -password stdin
  560. check_result $? "Step 1"
  561. echo "End of section"
  562. echo "---------------------------------------------------------------------"
  563. ############################################################
  564. ###### calling gen-ext-certs.sh ##################
  565. ############################################################
  566. echo "Calling gen-ext-certs.sh"
  567. echo ""
  568. cd .. || exit 1
  569. ./certs/test/gen-ext-certs.sh
  570. check_result $? "gen-ext-certs.sh"
  571. cd ./certs || { echo "Couldn't cd to certs directory"; exit 1; }
  572. echo "End of section"
  573. echo "---------------------------------------------------------------------"
  574. ############################################################
  575. ###### calling gen-badsig.sh ##################
  576. ############################################################
  577. echo "Calling gen-badsig.sh"
  578. echo ""
  579. cd ./test || { echo "Failed to switch to dir ./test"; exit 1; }
  580. ./gen-badsig.sh
  581. check_result $? "gen-badsig.sh"
  582. cd ../ || exit 1
  583. echo "End of section"
  584. echo "---------------------------------------------------------------------"
  585. ############################################################
  586. ###### calling gen-testcerts.sh ##################
  587. ############################################################
  588. echo "Calling gen-testcerts.sh"
  589. echo ""
  590. cd ./test || { echo "Failed to switch to dir ./test"; exit 1; }
  591. ./gen-testcerts.sh
  592. check_result $? "gen-testcerts.sh"
  593. cd ../ || exit 1
  594. echo "End of section"
  595. echo "---------------------------------------------------------------------"
  596. ############################################################
  597. ###### generate cms bundles in test directory ##############
  598. ############################################################
  599. echo "Generating CMS bundle"
  600. echo ""
  601. cd ./test || { echo "Failed to switch to dir ./test"; exit 1; }
  602. echo "test" | openssl cms -encrypt -binary -keyid -out ktri-keyid-cms.msg -outform der -recip ../client-cert.pem -nocerts
  603. check_result $? "generate ktri-keyid-cms.msg"
  604. cd ../ || exit 1
  605. echo "End of section"
  606. echo "---------------------------------------------------------------------"
  607. ############################################################
  608. ########## generate ocsp certs ######################
  609. ############################################################
  610. echo "Changing directory to ocsp..."
  611. echo ""
  612. # guard against recursive calls to renewcerts.sh
  613. if [ -d ocsp ]; then
  614. cd ./ocsp || { echo "Failed to switch to dir ./ocsp"; exit 1; }
  615. echo "Execute ocsp/renewcerts.sh..."
  616. ./renewcerts.sh
  617. check_result $? "renewcerts.sh"
  618. cd ../ || exit 1
  619. else
  620. echo "Error could not find ocsp directory"
  621. exit 1
  622. fi
  623. echo "End of section"
  624. echo "---------------------------------------------------------------------"
  625. ############################################################
  626. ###### calling assemble-chains.sh ##################
  627. ############################################################
  628. echo "Calling assemble-chains.sh"
  629. echo ""
  630. cd ./test-pathlen || { echo "Failed to switch to dir ./test-pathlen";
  631. exit 1; }
  632. ./assemble-chains.sh
  633. check_result $? "assemble-chains.sh"
  634. cd ../ || exit 1
  635. echo "End of section"
  636. echo "---------------------------------------------------------------------"
  637. ############################################################
  638. ########## store DER files as buffers ######################
  639. ############################################################
  640. echo "Changing directory to wolfssl root..."
  641. echo ""
  642. cd ../ || exit 1
  643. echo "Execute ./gencertbuf.pl..."
  644. echo ""
  645. ./gencertbuf.pl
  646. check_result $? "gencertbuf.pl"
  647. echo "End of section"
  648. echo "---------------------------------------------------------------------"
  649. ############################################################
  650. ########## generate the new crls ###########################
  651. ############################################################
  652. echo "Change directory to wolfssl/certs"
  653. echo ""
  654. cd ./certs || { echo "Failed to switch to dir ./certs"; exit 1; }
  655. echo "We are back in the certs directory"
  656. echo ""
  657. echo "Updating the crls..."
  658. echo ""
  659. cd ./crl || { echo "Failed to switch to dir ./crl"; exit 1; }
  660. echo "changed directory: cd/crl"
  661. echo ""
  662. ./gencrls.sh
  663. check_result $? "gencrls.sh"
  664. echo "ran ./gencrls.sh"
  665. echo ""
  666. ############################################################
  667. ########## generate PKCS7 bundles ##########################
  668. ############################################################
  669. echo "Changing directory to wolfssl certs..."
  670. echo ""
  671. cd ../ || exit 1
  672. echo "Creating test-degenerate.p7b..."
  673. echo ""
  674. openssl crl2pkcs7 -nocrl -certfile ./client-cert.pem -out test-degenerate.p7b -outform DER
  675. check_result $? ""
  676. echo "End of section"
  677. echo "---------------------------------------------------------------------"
  678. #cleanup the file system now that we're done
  679. echo "Performing final steps, cleaning up the file system..."
  680. echo ""
  681. rm ../wolfssl.cnf
  682. echo "End of Updates. Everything was successfully updated!"
  683. echo "---------------------------------------------------------------------"
  684. }
  685. ###############################################################################
  686. ##################### THE EXECUTABLE BODY #####################################
  687. ###############################################################################
  688. #start in root.
  689. cd ../ || exit 1
  690. #if there was an argument given, check it for validity or print out error
  691. if [ ! -z "$1" ]; then
  692. #valid argument print out other valid arguments
  693. if [ "$1" == "-h" ] || [ "$1" == "-help" ]; then
  694. echo ""
  695. echo "\"no argument\" will attempt to update all certificates"
  696. echo "-h or -help display this menu"
  697. echo ""
  698. echo ""
  699. #else the argument was invalid, tell user to use -h or -help
  700. else
  701. echo ""
  702. echo "That is not a valid option."
  703. echo ""
  704. echo "use -h or -help for a list of available options."
  705. echo ""
  706. fi
  707. else
  708. echo "Saving the configure state"
  709. echo ""
  710. cp config.status tmp.status || exit 1
  711. cp wolfssl/options.h tmp.options.h || exit 1
  712. echo "Running make clean"
  713. echo ""
  714. make clean
  715. check_result $? "make clean"
  716. # restore previous configure state
  717. restore_config
  718. check_result $? "restoring old configuration"
  719. fi #END already defined
  720. exit 0