[25] Rocky Linux 9 – Certyfikat SSL – własny podpis
15 stycznia 2025Stworzymy teraz samodzielnie certyfikat SSL z podpisem własnym.
Zalecam używać certyfikatu z podpisem własnym tylko w środowisku laboratoryjnym – do celów testowania, programowania i tak dalej, nie zaleca się używania tego typu certyfikatów w systemie produkcyjnym.
[root@vrl01 ~]# vi /etc/ssl/openssl.cnf #dodaj na końcu # nazwa sekcji to dowolna nazwa # DNS:(nazwa hosta) # jeśli ustawiasz wiele nazw hostów lub nazw domen, wpisz je oddzielając przecinkami # DNS:vrl01.zicher.lab, DNS: www.zicher.lab [ zicher.lab ] subjectAltName = DNS:vrl01.zicher.lab [root@vrl01 ~]# cd /etc/pki/tls/certs [root@vrl01 certs]# openssl genrsa -aes128 2048 > server.key Enter PEM pass phrase: # wpisz hasło Verifying - Enter PEM pass phrase: # potwierdź hasło # usuń hasło z klucza prywatnego [root@vrl01 certs]# openssl rsa -in server.key -out server.key Enter pass phrase for server.key: # wpisz hasło writing RSA key [root@vrl01 certs]# openssl req -utf8 -new -key server.key -out server.csr You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. ----- Country Name (2 letter code) [XX]:PL # kod kraju State or Province Name (full name) []:Rybnik # województwo Locality Name (eg, city) [Default City]:Rybnik # miasto Organization Name (eg, company) [Default Company Ltd]:zicher.lab # firma/organizacja Organizational Unit Name (eg, section) []:zicher.lab # wydział firmy Common Name (eg, your name or your server's hostname) []:vrl01.zicher.lab # FQDN hosta dla którego tworzysz certyfikat Email Address []:admin@zicher.lab # adres email administratora Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []: An optional company name []: # utwórz certyfikat z 10-letnią datą ważności # -extensions (nazwa sekcji): nazwa sekcji, którą ustawiłeś w [openssl.cnf] [root@vrl01 certs]# openssl x509 -in server.csr -out server.crt -req -signkey server.key -extfile /etc/ssl/openssl.cnf -extensions zicher.lab -days 3650 Certificate request self-signature ok subject=C = PL, ST = Rybnik, L = Rybnik, O = zicherLAB, OU = zicherLAB, CN = vrl01.zicher.lab, emailAddress = admin@zicher.lab [root@vrl01 certs]# chmod 600 server.key [root@vrl01 certs]# ll server.* -rw-r--r--. 1 root root 1432 03-06 11:17 server.crt -rw-r--r--. 1 root root 1066 03-06 11:14 server.csr -rw-------. 1 root root 1704 03-06 11:13 server.key