CloudFlare Invalid SSL certificate

Viewed 1465

I have a Laravel 8 application.

I have no idea what I missed. I'm trying to deploy a site in my server.

I kept getting :

Invalid SSL certificate

https://mybabies.app/


server {
    listen 443;
    ssl_certificate /etc/nginx/ssl/mybabies.app.crt;
    ssl_certificate_key /etc/nginx/ssl/mybabies.app.key; 

    server_name mybabies.app www.mybabies.app;

    root /home/bheng/mybabies/public;

    index index.html index.htm index.php;

    charset utf-8;

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include /etc/nginx/fastcgi_params;
    }

    client_max_body_size 500M;

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    access_log on;
    access_log /var/log/nginx/access.log;
    error_log  /var/log/nginx/error.log error;
    error_page 404 /index.php;

    # Media: images, icons, video, audio, HTC
    location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|mp3|ogg|ogv|webm|htc|woff2|woff)$ {
        expires 1M;
        access_log off;
        add_header Cache-Control "public";
    }

    # CSS and Javascript
    location ~* \.(?:css|js)$ {
        expires 1y;
        access_log off;
        add_header Cache-Control "public";
    }


    location / {
        #limit_req zone=one burst=2 nodelay;
        try_files $uri $uri/ /index.php?$query_string;
        add_header 'Access-Control-Allow-Origin' '*';
    }

}

I already create crt + pem key in CloudFlare and configure in these 2 lines :

ssl_certificate /etc/nginx/ssl/mybabies.app.crt;
ssl_certificate_key /etc/nginx/ssl/mybabies.app.key; 

Edit

When I paused it

enter image description here

enter image description here

enter image description here

When I clicked View Certificate, I see

enter image description here


Updated

I created the cert from

enter image description here

1 Answers

To setup secure connection between Cloudflare and your server you need to generate Origin CA Certificate in page Origin Certificates, but you did this in Client Certificates instead, so that's why you are getting error.

They are completelly different things with different purpose. Read descriptions.

Client Certificates

Secure and authenticate your APIs and web applications with client certificates. Block traffic from devices that do not have a valid client SSL/TLS certificate with mTLS rules.

Origin Certificates

Generate a free TLS certificate signed by Cloudflare to install on your origin server. Origin Certificates are only valid for encryption between Cloudflare and your origin server.

After generating PEM an KEY you need to put them in .crt and .key and load in nginx config, like you did before.

listen 443;
ssl_certificate /etc/nginx/ssl/mybabies.app.crt;
ssl_certificate_key /etc/nginx/ssl/mybabies.app.key; 

Now connection Full (strict) should work.

If you want to use self-signed certificate instead, but still leverage secure connection between CF and server, then use option Full instead (without strict). By using Flexible your visitor will be still using HTTPS, but there will be no SSL connection between CF and server, and server will see this as HTTP connection, so this option is not recommended.

Rad more: https://support.cloudflare.com/hc/en-us/articles/200170416-What-do-the-SSL-options-mean-

Related