Guest User

Untitled

a guest
May 20th, 2018
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. ### Create openssl key and cert :
  2.  
  3. ```bash
  4. openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365
  5. ```
  6. #### To convert these into .key and .crt format:
  7. ```bash
  8. openssl rsa -outform der -in key.pem -out server.key
  9. ```
  10. ```bash
  11. openssl x509 -outform der -in cert.pem -out server.crt
  12. ```
  13. ---
  14. ### To create rootCA:
  15. ```bash
  16. openssl genrsa -des3 -out rootCA.key 4096
  17. ```
  18. ```bash
  19. openssl req -x509 -new -nodes -key rootCA.key -sha256 -days 1024 -out rootCA.crt
  20. ```
  21. ### OR
  22. ```bash
  23. openssl genrsa -out "root-ca.key" 4096
  24. openssl req \
  25. -new -key "root-ca.key" \
  26. -out "root-ca.csr" -sha256 \
  27. -subj '/C=IN/ST=GA/L=PO/O=TEST/CN=Example CA'
  28. ```
  29.  
  30. Create a file root-ca.cnf and paste the following contents into it. This constrains the root CA to signing leaf certificates and not intermediate CAs
  31. ```
  32. [root_ca]
  33. basicConstraints = critical,CA:TRUE,pathlen:1
  34. keyUsage = critical, nonRepudiation, cRLSign, keyCertSign
  35. subjectKeyIdentifier=hash
  36. ```
  37. ```bash
  38. openssl x509 -req -days 3650 -in "root-ca.csr" \
  39. -signkey "root-ca.key" -sha256 -out "root-ca.crt" \
  40. -extfile "root-ca.cnf" -extensions \
  41. root_ca
  42. openssl genrsa -out "site.key" 4096
  43. openssl req -new -key "site.key" -out "site.csr" -sha256 \
  44. -subj '/C=IN/ST=GA/L=PO/O=TEST/CN=localhost'
  45. openssl x509 -req -days 750 -in "site.csr" -sha256 \
  46. -CA "root-ca.crt" -CAkey "root-ca.key" -CAcreateserial \
  47. -out "site.crt" -extfile "site.cnf" -extensions server
  48. ```
Add Comment
Please, Sign In to add comment