I was trying to use the HTTP3 feature in Nginx. I referred to this post (Binary Packages Now Available for the Preview NGINX QUIC+HTTP/3 Implementation) to implement Nginx server with HTTP3 feature. And my Nginx config is like the following ( almost default ).
server {
listen 80;
server_name localhost;
# for better compatibility it's recommended
# to use the same port for quic and https
listen 443 http3 reuseport;
listen 443 ssl;
ssl_certificate certs/localhost.crt;
ssl_certificate_key certs/localhost.key;
ssl_protocols TLSv1.3;
#access_log /var/log/nginx/host.access.log main;
location / {
# required for browsers to direct them into quic port
add_header Alt-Svc 'h3=":8443"; ma=86400';
add_header X-protocol $server_protocol always;
root /usr/share/nginx/html;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
I created the self-singed SSL certificate and apply it. This self-singed SSL certificate is created by the following.
$ openssl genpkey -algorithm RSA -out localhost.key
$ openssl req -new -key localhost.key -out localhost.csr -subj "/CN=localhost" -addext "subjectAltName=DNS:localhost"
$ openssl x509 -req -in localhost.csr -signkey localhost.key -out localhost.crt
Then, I created a pem file for it by the below command and distribute it to directories for curl.
$ cat localhost.crt localhost.key > localhost.pem
$ cp localhost.pem /usr/local/share/ca-certificates/
$ cp localhost.pem /etc/ssl/certs/
sudo update-ca-certificates
All of the above processes completed, I tried to access the Nginx server via curl, then, I got an error with the message below.
$ curl -IL https://localhost/
curl: (60) SSL certificate problem: self-signed certificate
More details here: https://curl.se/docs/sslcerts.html
curl failed to verify the legitimacy of the server and therefore could not
establish a secure connection to it. To learn more about this situation and
how to fix it, please visit the web page mentioned above.
Updated: 20230212 14:00
I can make curl trust the localhost domain by processing the following.
cp localhost.crt /usr/local/share/ca-certificates/
sudo update-ca-certificates
# Discard unnecessary files
rm /usr/local/share/ca-certificates/localhost.pem
rm /etc/ssl/certs/localhost.pem
rm localhost.pem
Updated: 20230212 11:00
I know curl can't access through HTTP3 without the special addon, but I wonder why I got an error message showing the certificate is not trusted even though the pem file is set to the Root cert path for curl.
I also accessed this Nginx server via Chrome. However, it seems not to be applied HTTP3 protocol.
Updated: 20230212 11:00
I found the response header for HTTP3 has been set correctly, however, the actual protocol of connection Chrome showed me is HTTP 1.1, not HTTP3. I guess it might not work fine.
The OS version I'm using is the following.
I established this env by using Docker image ubuntu:latest.
$ cat /etc/os-release
PRETTY_NAME="Ubuntu 22.04.1 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.1 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy
I would really appreciate it if anyone could help me. Thank you.

-kto ignore this problem (testing only, never production!).