User Tools

Site Tools


openssl

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
openssl [2023/12/26 07:01] A User Not Logged inopenssl [2025/04/08 12:41] (current) – [Trust self signed certs] ealmr
Line 1: Line 1:
-====== OpenSSL Commands ======+====== Trust self signed certs ======
  
-create private key with password protected:+Debian based:
  
-  openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048 -aes-128-cbc -out fd.key +  cp $DOMAIN_CRT /usr/local/share/ca-certificates/ 
 +  update-ca-certificates 
 + 
 +Arch Linux: 
 + 
 +  trust anchor $DOMAIN_CRT 
 +  #to trust non CA cert, see https://github.com/harvester/harvester/issues/4134#issuecomment-1888918283 
 +  sed -i 's/certificate-category: other-entry/certificate-category: authority/g' $P11_KIT 
 +  update-ca-trust 
 + 
 +Alpine: 
 + 
 +  cp $DOMAIN_CRT /usr/local/share/ca-certificates/ 
 +  update-ca-certificates 
 +  ls -la /etc/ssl/certs/ | grep $DOMAIN_CRT
      
 +====== General commands ======
 +
 +create root private key with password protected:
 +
 +  openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048 -aes-128-cbc -out root.key 
  
 show private key info: show private key info:
  
-  openssl pkey -in fd.key -text -noout +  openssl pkey -in root.key -text -noout 
      
 generate pub key: generate pub key:
  
-  openssl pkey -in fd.key -pubout -out fd-public.key+  openssl pkey -in root.key -pubout -out root-public.key
      
-create the CSR from config file:+sign root CA with new private key: 
 + 
 +  openssl x509 -in root.crt -signkey root.key -days 3650 
 + 
 +add self self signed to trust store: 
 + 
 +  # save to /etc/ca-certificates/trust-source 
 +  sudo trust anchor <path to crt>
      
-  openssl req -new -config fd.cnf -key fd.key -out fd.csr 
  
-creating CSRs from existing certificates:+====== Sign fake domain ======
  
-  openssl x509 -x509toreq -in fd.crt -out fd.csr -signkey fd.key -copy_extensions copyall+create private keys:
  
-create certificate from CSR:+  openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048 -out root.key 
 +  openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048 -out intermediate.key  
 +  openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048 -out domain.key
      
-  openssl x509 -req -in fd.csr -CA ca.crt -CAkey intermediate.key -CAcreateserial -out out.crt -copy_extensions copyall -days 3650+creating root CSR from existing root cert:
  
-sign root CA with new private key:+  openssl x509 -x509toreq -in "$ROOT_CRT" -out root.csr -signkey root.key -copy_extensions copyall 
 +   
 +generate new root cert: 
 + 
 +  openssl x509 -req -in root.csr -out root.crt -signkey root.key -days 3650 -copy_extensions copyall 
 +   
 +creating CSRs from existing intermediate cert: 
 + 
 +  openssl x509 -x509toreq -in "$INTER_CRT" -out intermediate.csr -signkey intermediate.key -copy_extensions copyall 
 + 
 +resign intermediate certificate from CSR with root CA
 +   
 +  openssl x509 -req -in intermediate.csr -CA root.crt -CAkey root.key -CAcreateserial -out intermediate.crt -copy_extensions copyall -days 3650 
 +   
 +creating CSRs from existing domain cert: 
 + 
 +  openssl x509 -x509toreq -in "$DOMAIN_CRT" -out domain.csr -signkey domain.key -copy_extensions copyall 
 + 
 +resign domain certificate from CSR with intermediate CA: 
 +   
 +  openssl x509 -req -in domain.csr -CA intermediate.crt -CAkey intermediate.key -CAcreateserial -out domain.crt -copy_extensions copyall -days 3650 
 + 
 +resign domain certificate from CSR directly with key: 
 + 
 +  openssl x509 -req -in domain.csr -key domain.key -out domain.crt -copy_extensions copyall -days 3650 
 +   
 +====== Create cert for IP ====== 
 + 
 +create config file req.cnf: 
 + 
 +<code> 
 +[req] 
 +default_bits = 4096 
 +distinguished_name = req_distinguished_name 
 +req_extensions = req_ext 
 +prompt = no 
 + 
 +[req_distinguished_name] 
 +commonName = <IP adress> 
 + 
 +[req_ext] 
 +subjectAltName = IP:<IP address> 
 + 
 +</code> 
 + 
 +generate key: 
 + 
 +  openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048 -out ip.key 
 +   
 +generate CSR: 
 + 
 +  openssl req -new -key ip.key -out ip.csr -config req.cnfq 
 +   
 +create cert:
  
-  openssl x509 -in CA.crt -signkey root.key -days 3650+  openssl x509 -req -days 3650 -in ip.csr -signkey ip.key -out ip.cert -extensions req_ext -extfile req.cnf
  
openssl.1703574060.txt.gz · Last modified: by A User Not Logged in

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki