mkcerts.sh 1.1 KB

12345678910111213141516171819202122232425
  1. #!/bin/sh
  2. OPENSSL=openssl
  3. # Root CA: create certificate directly
  4. CN="Test Root CA" $OPENSSL req -config ca.cnf -x509 -nodes \
  5. -keyout root.pem -out root.pem -newkey rsa:2048 -days 3650
  6. # Server certificate: create request first
  7. CN="Test Server Cert" $OPENSSL req -config ca.cnf -nodes \
  8. -keyout skey.pem -out req.pem -newkey rsa:1024
  9. # Sign request: end entity extensions
  10. $OPENSSL x509 -req -in req.pem -CA root.pem -days 3600 \
  11. -extfile ca.cnf -extensions usr_cert -CAcreateserial -out server.pem
  12. # Intermediate CA: request first
  13. CN="Test Intermediate CA" $OPENSSL req -config ca.cnf -nodes \
  14. -keyout intkey.pem -out intreq.pem -newkey rsa:2048
  15. # Sign request: CA extensions
  16. $OPENSSL x509 -req -in intreq.pem -CA root.pem -days 3600 \
  17. -extfile ca.cnf -extensions v3_ca -CAcreateserial -out intca.pem
  18. # Client certificate: request first
  19. CN="Test Client Cert" $OPENSSL req -config ca.cnf -nodes \
  20. -keyout ckey.pem -out creq.pem -newkey rsa:1024
  21. # Sign using intermediate CA
  22. $OPENSSL x509 -req -in creq.pem -CA intca.pem -CAkey intkey.pem -days 3600 \
  23. -extfile ca.cnf -extensions usr_cert -CAcreateserial -out client.pem