renewcerts.sh 41 KB

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