gencerts.sh 891 B

12345678910111213141516171819202122232425262728293031323334
  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. cfssl gencert \
  13. --ca ./ca.crt \
  14. --ca-key ./ca-key.pem \
  15. --config ./gencert.json \
  16. ./server-ca-csr.json | cfssljson --bare ./server
  17. mv server.pem server.crt
  18. mv server-key.pem server.key.insecure
  19. cfssl gencert --ca ./ca.crt \
  20. --ca-key ./ca-key.pem \
  21. --config ./gencert.json \
  22. ./server-ca-csr.json 2>revoked.stderr | cfssljson --bare ./server-revoked
  23. mv server-revoked.pem server-revoked.crt
  24. mv server-revoked-key.pem server-revoked.key.insecure
  25. grep serial revoked.stderr | awk ' { print $9 } ' >revoke.txt
  26. cfssl gencrl revoke.txt ca.crt ca-key.pem | base64 -d >revoke.crl
  27. rm -f *.csr *.pem *.stderr *.txt