procedures:internal_ca
Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
| procedures:internal_ca [2023/02/08 08:33] – gizmo | procedures:internal_ca [2023/02/10 13:45] (Version actuelle) – gizmo | ||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| - | CA - Interne | + | # CA - Interne |
| - | # Root CA | + | ## Root CA |
| ``` | ``` | ||
| openssl genrsa -aes256 -out rootCA.key 4096 | openssl genrsa -aes256 -out rootCA.key 4096 | ||
| - | openssl req -x509 -new -nodes -key rootCA.key -sha512 -days 3650 -out rootCA.crt | + | openssl req -new -subj "/ |
| + | openssl req -x509 -in rootCA.csr | ||
| + | openssl x509 -in rootCA.crt -noout -serial > rootCA.srl | ||
| ``` | ``` | ||
| - | ``` | + | Certif à importer |
| - | Country Name (2 letter code) [AU]:FR | + | |
| - | State or Province Name (full name) [Some-State]:Ille-et-Vilaine | + | |
| - | Locality Name (eg, city) []:Rennes | + | |
| - | Organization Name (eg, company) [Internet Widgits Pty Ltd]: | + | |
| - | Organizational Unit Name (eg, section) []: | + | |
| - | Common Name (e.g. server FQDN or YOUR name) []:ca.grif | + | |
| - | Email Address []: | + | |
| - | ``` | + | |
| - | ``` | + | ## Client Cert |
| - | C = FR, ST = Ille-et-Vilaine, | + | |
| - | ``` | + | |
| - | # Client Cert | + | Script dispo ici **/ |
| - | openssl genrsa -out mydomain.com.key 4096 | + | |
| - | openssl req -new -key mydomain.com.key -out mydomain.com.csr | + | |
| - | ou en one line : | ||
| - | ``` | ||
| - | openssl req -new -sha256 -key mydomain.com.key -subj "/ | ||
| ``` | ``` | ||
| + | # | ||
| + | if [ " | ||
| + | echo " | ||
| + | exit 1 | ||
| + | fi | ||
| - | verify csr : | + | FQDN=$1 |
| - | ``` | + | |
| - | openssl req -in mydomain.com.csr -noout -text | + | |
| - | ``` | + | |
| - | generate cert : | + | ROOT=$(pwd) |
| - | ``` | + | ROOT_CRT=" |
| - | openssl x509 -req -in mydomain.com.csr -CA rootCA.crt -CAkey | + | ROOT_KEY=" |
| + | ROOT_SRL=" | ||
| + | DEST_CERT=" | ||
| + | VALIDATE=" | ||
| + | |||
| + | if [ ! -d " | ||
| + | mkdir -p ${DEST_CERT} | ||
| + | fi | ||
| + | |||
| + | if [[ " | ||
| + | echo " | ||
| + | echo " | ||
| + | subjectKeyIdentifier | ||
| + | authorityKeyIdentifier = keyid:always, | ||
| + | keyUsage | ||
| + | issuerAltName | ||
| + | subjectAltName | ||
| + | " > v3.ext_${FQDN} | ||
| + | |||
| + | echo "Valid fqdn, generate certificate for ${FQDN}" | ||
| + | | ||
| + | chmod 0644 ${DEST_CERT}/ | ||
| + | openssl req -new -key " | ||
| + | -sha512 \ | ||
| + | -subj "/ | ||
| + | -out " | ||
| + | | ||
| + | |||
| + | cat ${DEST_CERT}/ | ||
| + | |||
| + | rm v3.ext_${FQDN} | ||
| + | else | ||
| + | echo "Not a valid fqdn!" | ||
| + | exit 1 | ||
| + | fi | ||
| ``` | ``` | ||
| - | verify cert : | + | ## Vhost delivery |
| - | ``` | + | |
| - | openssl x509 -in mydomain.com.crt -text -noout | + | Sur rda.grif, y a un vhost qui permet d' |
| ``` | ``` | ||
| + | server { | ||
| + | listen *:80; | ||
| - | source | + | server_name |
| + | |||
| + | access_log / | ||
| + | error_log / | ||
| + | |||
| + | location / { | ||
| + | try_files $uri @redirect; | ||
| + | } | ||
| + | |||
| + | location @redirect { | ||
| + | return 301 https:// | ||
| + | } | ||
| + | } | ||
| + | |||
| + | server { | ||
| + | listen 443 ssl http2; | ||
| + | listen [::]:443 ssl http2; | ||
| + | server_name | ||
| + | |||
| + | if ($host = ' | ||
| + | rewrite | ||
| + | } | ||
| + | |||
| + | index index.html index.htm index.php; | ||
| + | access_log | ||
| + | error_log | ||
| + | |||
| + | include / | ||
| + | |||
| + | ssl_certificate / | ||
| + | ssl_certificate_key / | ||
| + | |||
| + | location / { | ||
| + | root / | ||
| + | autoindex on; | ||
| + | |||
| + | location ~\.key { | ||
| + | allow 172.17.0.63; | ||
| + | deny all; | ||
| + | } | ||
| + | |||
| + | location ~\.(sh|srl|csr)$ { | ||
| + | deny all; | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | |||
| + | ``` | ||
procedures/internal_ca.1675845183.txt.gz · Dernière modification : de gizmo
