createsslfiles.sh 917 B

1234567891011121314151617181920212223242526
  1. #!/bin/bash
  2. ROOTNAME=rootca
  3. USERNAME=user
  4. DIFFIENAME=dh2048
  5. echo "Creating ROOTCA key"
  6. openssl genrsa -out $ROOTNAME.key 2048
  7. echo "Creating ROOTCA cert"
  8. openssl req -x509 -new -nodes -key $ROOTNAME.key -days 20000 -out $ROOTNAME.crt
  9. echo "Creating USER key"
  10. openssl genrsa -out $USERNAME.key 2048
  11. echo "Creating USER base cert"
  12. openssl req -new -key $USERNAME.key -out $USERNAME.csr
  13. echo "Signing USER base cert using ROOT key and cert"
  14. openssl x509 -req -in $USERNAME.csr -CA $ROOTNAME.crt -CAkey $ROOTNAME.key -CAcreateserial -out $USERNAME.crt -days 20000
  15. echo "Creating DIFFIE params. This might take a while"
  16. openssl dhparam -out $DIFFIENAME.pem 2048
  17. # should OK
  18. echo "This should OK"
  19. openssl verify -CAfile $ROOTNAME.crt $ROOTNAME.crt
  20. # should OK
  21. echo "This should OK"
  22. openssl verify -CAfile $ROOTNAME.crt $USERNAME.crt
  23. # should FAIL
  24. echo "This should FAIL"
  25. openssl verify -CAfile $USERNAME.crt $USERNAME.crt