Putin is a war criminal and a son of a bitch!


 

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 4096

Vytvořte si konfiguraci pro request certifikátu v souboru openssl.req.cnf
####################################################################
[ req ]
default_bits        = 4096
default_keyfile     = private.key
distinguished_name    = req_distinguished_name
attributes        = req_attributes

string_mask = utf8only

req_extensions = v3_req # The extensions to add to a certificate request

[ req_distinguished_name ]
countryName                = Country Name (2 letter code)
countryName_default        = CZ
countryName_min            = 2
countryName_max            = 2

stateOrProvinceName        = State or Province Name (full name)
stateOrProvinceName_default    = Prague

localityName            = Prague

0.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 Ltd

organizationalUnitName        = Organizational Unit Name (eg, section)
organizationalUnitName_default    = IT

commonName              = Common Name (eg, YOUR name)
commonName_default        = peip.eu
commonName_max            = 64

emailAddress            = 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:FALSE
keyUsage = nonRepudiation, digitalSignature, keyEncipherment       # nonRepudiation, digitalSignature, nonRepudiation
extendedKeyUsage = serverAuth, clientAuth                          # serverAuth, clientAuth, codeSigning, emailProtection
subjectAltName = @alt_names


[ v3_req ]

# Extensions to add to a certificate request

basicConstraints = CA:FALSE
keyUsage = nonRepudiation, digitalSignature, keyEncipherment
subjectAltName = @alt_names

[ alt_names ]
IP.1 = 255.255.255.1
DNS.1 = peip.eu

Následně je potřeba vytvořit request pro certifikační autoritu
openssl req -new -key private.key -out request.csr -config openssl.req.cnf

Tento 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/