savsanta

openssl cert creation help

May 30th, 2022 (edited)
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. OpenSSl Certificate creation methods
  2.  
  3.  
  4. # Separate Generation of the server key using passout. Also uses CSR to signkey and generate a CA
  5. openssl genrsa -des3 -passout pass:x -out server.pass.key 2048
  6. openssl rsa -passin pass:x -in server.pass.key -out server.key
  7. rm server.pass.key
  8. openssl req -new -key server.key -out server.csr \
  9. -subj "/C=US/ST=Kansas/L=Marion/O=OrgName/OU=Accounting/CN=example.com"
  10. openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
  11.  
  12. # using openssl req to automatic to generate a server.key and server.crt. No CSR or CA here
  13. openssl req -x509 -nodes \
  14. -days 365 \
  15. -subj "/C=US/ST=MD/O= Bingo Was His Name Oh/CN=example.com" \
  16. -newkey rsa:2048 -keyout server.key \
  17. -out server.crt
  18.  
  19.  
  20. # Juniarto's guide on client certificate (for client verification)
  21. #Create Client Certificate [AT CLIENT]
  22.  
  23. openssl genrsa -des3 -out user.key 4096 #User Key
  24. openssl req -new -key user.key -out user.csr #Cert. Signing Request
  25.  
  26. user.key is known as USER/CLIENT PRIVATE KEY. It stays in the client and should not be sent to the server.
  27.  
  28. user.csr is known as CERTIFICATE SIGNING REQUEST. Send user.csr to the server. Server will create user.crt using server’s ca.crt and ca.key.
  29.  
  30. d. Send user.csr to server, to be signed by CA [AT SERVER]. Produce user.crt
  31.  
  32. openssl x509 -req -days 365 -in user.csr -CA ca.crt -CAkey ca.key -set_serial 01 -out user.crt
  33. You’ll typically want to increment the serial number with each signing. Once the certificate expires, a new CSR doesn’t need to be recreated; the same one can be signed, which will create a new certificate tied to that public key.
  34.  
  35. The signed certificate would be sent back to the user along with the CA cert (not private key!), for installation on their device.
  36.  
  37. e. But, usually you have to bundle ca.crt and user.crt before you send it to client.[AT CLIENT]
  38.  
  39. openssl pkcs12 -export -out user.pfx -inkey user.key -in user.crt -certfile ca.crt
  40.  
  41. Pass the user.pfx to the client to be installed in their browser.
Add Comment
Please, Sign In to add comment