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:57] – gizmo | procedures:internal_ca [2023/02/10 13:45] (Version actuelle) – gizmo | ||
---|---|---|---|
Ligne 8: | Ligne 8: | ||
openssl x509 -in rootCA.crt -noout -serial > rootCA.srl | openssl x509 -in rootCA.crt -noout -serial > rootCA.srl | ||
``` | ``` | ||
+ | |||
+ | Certif à importer : https:// | ||
## Client Cert | ## Client Cert | ||
- | openssl genrsa -out mydomain.com.key 4096 | ||
- | openssl req -new -key mydomain.com.key -out mydomain.com.csr | ||
- | ou en one line : | + | Script dispo ici **/srv/internal\_ca/generate\_cert.sh** : |
- | ``` | + | |
- | openssl req -new -sha256 -key mydomain.com.key -subj "/C=FR/ST=Ille-et-Vilaine/L=Rennes/ | + | |
- | ``` | + | |
- | verify csr : | ||
- | ``` | ||
- | openssl req -in mydomain.com.csr -noout -text | ||
``` | ``` | ||
+ | # | ||
+ | if [ " | ||
+ | echo " | ||
+ | exit 1 | ||
+ | fi | ||
- | generate cert : | + | FQDN=$1 |
- | ``` | + | |
- | openssl x509 -req -in mydomain.com.csr -CA rootCA.crt -CAkey | + | ROOT=$(pwd) |
+ | ROOT_CRT=" | ||
+ | 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.1675846669.txt.gz · Dernière modification : 2023/02/08 08:57 de gizmo