gencerts.sh 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/bin/bash
  2. if ! [[ "$0" =~ "./gencerts.sh" ]]; then
  3. echo "must be run from 'fixtures'"
  4. exit 255
  5. fi
  6. if ! which cfssl; then
  7. echo "cfssl is not installed"
  8. exit 255
  9. fi
  10. cfssl gencert --initca=true ./ca-csr.json | cfssljson --bare ./ca
  11. mv ca.pem ca.crt
  12. if which openssl >/dev/null; then
  13. openssl x509 -in ca.crt -noout -text
  14. fi
  15. # generate DNS: localhost, IP: 127.0.0.1, CN: example.com certificates
  16. cfssl gencert \
  17. --ca ./ca.crt \
  18. --ca-key ./ca-key.pem \
  19. --config ./gencert.json \
  20. ./server-ca-csr.json | cfssljson --bare ./server
  21. mv server.pem server.crt
  22. mv server-key.pem server.key.insecure
  23. # generate IP: 127.0.0.1, CN: example.com certificates
  24. cfssl gencert \
  25. --ca ./ca.crt \
  26. --ca-key ./ca-key.pem \
  27. --config ./gencert.json \
  28. ./server-ca-csr-ip.json | cfssljson --bare ./server-ip
  29. mv server-ip.pem server-ip.crt
  30. mv server-ip-key.pem server-ip.key.insecure
  31. if which openssl >/dev/null; then
  32. openssl x509 -in ./server.crt -text -noout
  33. openssl x509 -in ./server-ip.crt -text -noout
  34. fi
  35. rm -f *.csr *.pem *.stderr *.txt