renewcerts-for-test.sh 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #!/bin/sh
  2. # $1 cert, $2 name, $3 ca, $4 extensions, $5 serial
  3. update_cert(){
  4. openssl req \
  5. -new \
  6. -key $1-key.pem \
  7. -out $1-cert.csr \
  8. -subj "/C=US/ST=Washington/L=Seattle/O=wolfSSL/OU=Engineering/CN=$2/emailAddress=info@wolfssl.com"
  9. openssl x509 \
  10. -req -in $1-cert.csr \
  11. -extfile $6 \
  12. -extensions $4 \
  13. -days 1000 \
  14. -CA $3-cert.pem \
  15. -CAkey $3-key.pem \
  16. -set_serial $5 \
  17. -out $1-cert.pem \
  18. -sha256
  19. rm $1-cert.csr
  20. openssl x509 -in $1-cert.pem -text > $1_tmp.pem
  21. mv $1_tmp.pem $1-cert.pem
  22. cat $3-cert.pem >> $1-cert.pem
  23. }
  24. printf '%s\n' "Using CNF: $1"
  25. openssl req \
  26. -new \
  27. -key root-ca-key.pem \
  28. -out root-ca-cert.csr \
  29. -subj "/C=US/ST=Washington/L=Seattle/O=wolfSSL/OU=Engineering/CN=wolfSSL root CA/emailAddress=info@wolfssl.com"
  30. openssl x509 \
  31. -req -in root-ca-cert.csr \
  32. -extfile $1 \
  33. -extensions v3_ca \
  34. -days 1000 \
  35. -signkey root-ca-key.pem \
  36. -set_serial 99 \
  37. -out root-ca-cert.pem \
  38. -sha256
  39. rm root-ca-cert.csr
  40. openssl x509 -in root-ca-cert.pem -text > tmp.pem
  41. mv tmp.pem root-ca-cert.pem
  42. update_cert intermediate1-ca "wolfSSL intermediate CA 1" root-ca v3_ca 01 $1
  43. update_cert intermediate2-ca "wolfSSL intermediate CA 2" root-ca v3_ca 02 $1
  44. update_cert intermediate3-ca "wolfSSL REVOKED intermediate CA" root-ca v3_ca 03 $1 # REVOKED
  45. update_cert ocsp-responder "wolfSSL OCSP Responder" root-ca v3_ocsp 04 $1
  46. update_cert server1 "www1.wolfssl.com" intermediate1-ca v3_req1 05 $1
  47. update_cert server2 "www2.wolfssl.com" intermediate1-ca v3_req1 06 $1 # REVOKED
  48. update_cert server3 "www3.wolfssl.com" intermediate2-ca v3_req2 07 $1
  49. update_cert server4 "www4.wolfssl.com" intermediate2-ca v3_req2 08 $1 # REVOKED
  50. update_cert server5 "www5.wolfssl.com" intermediate3-ca v3_req3 09 $1