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. openssl x509 -in ca.crt -noout -text
  13. # generate wildcard certificates DNS: m1/m2/m3.etcd.local
  14. cfssl gencert \
  15. --ca ./ca.crt \
  16. --ca-key ./ca-key.pem \
  17. --config ./gencert.json \
  18. ./server-ca-csr-1.json | cfssljson --bare ./server-1
  19. mv server-1.pem server-1.crt
  20. mv server-1-key.pem server-1.key.insecure
  21. cfssl gencert \
  22. --ca ./ca.crt \
  23. --ca-key ./ca-key.pem \
  24. --config ./gencert.json \
  25. ./server-ca-csr-2.json | cfssljson --bare ./server-2
  26. mv server-2.pem server-2.crt
  27. mv server-2-key.pem server-2.key.insecure
  28. cfssl gencert \
  29. --ca ./ca.crt \
  30. --ca-key ./ca-key.pem \
  31. --config ./gencert.json \
  32. ./server-ca-csr-3.json | cfssljson --bare ./server-3
  33. mv server-3.pem server-3.crt
  34. mv server-3-key.pem server-3.key.insecure
  35. rm -f *.csr *.pem *.stderr *.txt