Using Cloudflare's "Full" encyption mode, one can use self signed certificates for origin to Cloudflare connections:
The certificate presented by the origin will not be validated in any way. It can be expired, self-signed, or not even have a matching CN/SAN entry for the hostname requested.
-- https://developers.cloudflare.com/ssl/origin-configuration/ssl-modes/full/
Recently my self signed certificate made with the following commands (GNU/Linux) stopped working and Cloudflare threw a 526 error.
openssl genpkey -algorithm Ed25519 -out /etc/ssl/qycli.key
openssl req -new -x509 -key /etc/ssl/qycli.key -out /etc/ssl/qycli.crt -days 7300 -subj "/C=AQ/ST=qycli/L=qycli/O=HOSTYON/OU=SysOps/CN=HOSTYON"
Using the following certificate and key made the connection to Cloudflare work again:
openssl req -new -newkey ec -pkeyopt ec_paramgen_curve:prime256v1 -x509 -nodes -days 7300 -out /etc/ssl/qycli.crt -keyout /etc/ssl/qycli.key -subj "/C=AQ/ST=qycli/L=qycli/O=HOSTYON/OU=SysOps/CN=HOSTYON"
Can I specify several certificates and keys in a way that NGINX will consider them in order, one after the other, to keep the performance as high as possible, while providing a fallback for when Cloudflare does not consider a certificate and key safe enough anymore?
The NGINX documentation mentions:
Since version 1.11.0, this directive can be specified multiple times to load certificates of different types, for example, RSA and ECDSA:
-- https://nginx.org/en/docs/http/ngx_http_ssl_module.html#ssl_certificate
Would the following work as I expect it?
server {
listen 443 ssl;
server_name example.com;
ssl_certificate /etc/ssl/qycli.crt; # More performant, less secure ECDSA P-256 certificate
ssl_certificate_key /etc/ssl/qycli.key;
ssl_certificate /etc/ssl/qycli.2048.crt; # More performant, less secure RSA 2048 fallback certificate
ssl_certificate_key /etc/ssl/qycli.2048.key;
ssl_certificate /etc/ssl/qycli.384.crt; # Less performant, more secure ECDSA P-384 fallback certificate
ssl_certificate_key /etc/ssl/qycli.384.key;
ssl_certificate /etc/ssl/qycli.4096.crt; # More performant, less secure RSA 4096 certificate
ssl_certificate_key /etc/ssl/qycli.4096.key;
...
}
Certificates and keys made with:
# ECDSA
openssl req -new -newkey ec -pkeyopt ec_paramgen_curve:prime256v1 -x509 -nodes -days 7300 -out /etc/ssl/qycli.crt -keyout /etc/ssl/qycli.key -subj "/C=AQ/ST=qycli/L=qycli/O=HOSTYON/OU=SysOps/CN=HOSTYON"
openssl req -new -newkey ec -pkeyopt ec_paramgen_curve:secp384r1 -x509 -nodes -days 7300 -out /etc/ssl/qycli.384.crt -keyout /etc/ssl/qycli.384.key -subj "/C=AQ/ST=qycli/L=qycli/O=HOSTYON/OU=SysOps/CN=HOSTYON"
# RSA
openssl req -x509 -newkey rsa:2048 -keyout /etc/ssl/qycli.2048.key -out /etc/ssl/qycli.2048.crt -sha256 -days 7300 -nodes -subj "/C=AQ/ST=qycli/L=qycli/O=HOSTYON/OU=SysOps/CN=HOSTYON"
openssl req -x509 -newkey rsa:4096 -keyout /etc/ssl/qycli.4096.key -out /etc/ssl/qycli.4096.crt -sha256 -days 7300 -nodes -subj "/C=AQ/ST=qycli/L=qycli/O=HOSTYON/OU=SysOps/CN=HOSTYON"