Pokud potřebujete vytvořit vlastní certifikát například pro webový server, níže je postup jak toho docílit pomocí openssl.
Nejdříve je nutné si vytvořit privátní certifikát
openssl genrsa -out private.key 4096Vytvořte si konfiguraci pro request certifikátu v souboru openssl.req.cnf
####################################################################[ req ]default_bits = 4096default_keyfile = private.keydistinguished_name = req_distinguished_nameattributes = req_attributesstring_mask = utf8onlyreq_extensions = v3_req # The extensions to add to a certificate request[ req_distinguished_name ]countryName = Country Name (2 letter code)countryName_default = CZcountryName_min = 2countryName_max = 2stateOrProvinceName = State or Province Name (full name)stateOrProvinceName_default = PraguelocalityName = Prague0.organizationName = Organization Name (eg, company)0.organizationName_default = PEIP - prvni evropska insvesticni psickova# we can do this but it is not needed normally :-)#1.organizationName = Second Organization Name (eg, company)#1.organizationName_default = World Wide Web Pty LtdorganizationalUnitName = Organizational Unit Name (eg, section)organizationalUnitName_default = ITcommonName = Common Name (eg, YOUR name)commonName_default = peip.eucommonName_max = 64emailAddress = Tato e-mailová adresa je chráněna před spamboty. Pro její zobrazení musíte mít povolen Javascript. emailAddress_max = 64# SET-ex3 = SET extension number 3[ req_attributes ]unstructuredName = cokoliv...basicConstraints = CA:FALSEkeyUsage = nonRepudiation, digitalSignature, keyEncipherment # nonRepudiation, digitalSignature, nonRepudiationextendedKeyUsage = serverAuth, clientAuth # serverAuth, clientAuth, codeSigning, emailProtectionsubjectAltName = @alt_names[ v3_req ]# Extensions to add to a certificate requestbasicConstraints = CA:FALSEkeyUsage = nonRepudiation, digitalSignature, keyEnciphermentsubjectAltName = @alt_names[ alt_names ]IP.1 = 255.255.255.1DNS.1 = peip.euNásledně je potřeba vytvořit request pro certifikační autoritu
openssl req -new -key private.key -out request.csr -config openssl.req.cnfTento req je potom možné poslat na certifikační autoritu typu digicert, postsignum, ica atd.
Pokud máte vlastní certifikační autoritu a chcete si podepsat certifikát, použijte
openssl ca -in request.csr -config openssl.CA.cnf
Další užitečné příkazy při generování ceritifikátů:
# Stažení certifikátu
openssl s_client -showcerts -connect donjirka.cz:443
# informace z req csr souboru
openssl req -noout -text -in donjirka_2021.csr
# informace z pem souboru
openssl x509 -in private.pem -text -noout
# překonvertování cer do crt
openssl x509 -inform DER -in public.cer -out public.crt
# nápověda na openssl.cnf pro různé verze
https://sources.debian.org/src/openssl/1.1.1g-1/apps/openssl.cnf/