Curl: Fix CURL (51) SSL error: no alternative certificate subject name matches

前端 未结 6 1676
失恋的感觉
失恋的感觉 2020-12-13 01:06

I am new to CURL world, coming from Windows + .NET domain.

Trying to access Rest API for basic authentication at http://www.evercam.io/docs/api/v1/authentication.

6条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-13 02:10

    I had the same issue. In my case I was using digitalocean and nginx.
    I have first setup a domain example.app and a subdomain dev.exemple.app in digitalocean. Second,I purchased two ssl certificat from godaddy. And finaly, I configured two domain in nginx to use those two ssl certificat with the following snipet

    My example.app domain config

        server {
        listen 7000 default_server;
        listen [::]:7000 default_server;
    
         listen 443 ssl default_server;
         listen [::]:443 ssl default_server;
    
        root /srv/nodejs/echantillonnage1;
    
        # Add index.php to the list if you are using PHP
        index index.html index.htm index.nginx-debian.html;
    
        server_name echantillonnage.app;
        ssl_certificate /srv/nodejs/certificatSsl/widcardcertificate/echantillonnage.app.chained.crt;
        ssl_certificate_key /srv/nodejs/certificatSsl/widcardcertificate/echantillonnage.app.key;
    
        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                proxy_pass http://127.0.0.1:8090;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection 'upgrade';
                proxy_set_header Host $host;
                proxy_cache_bypass $http_upgrade;
        #try_files $uri $uri/ =404;
        }
     }
    

    My dev.example.app

       server {
        listen 7000 default_server;
        listen [::]:7000 default_server;
    
         listen 444 ssl default_server;
         listen [::]:444 ssl default_server;
    
        root /srv/nodejs/echantillonnage1;
    
        # Add index.php to the list if you are using PHP
        index index.html index.htm index.nginx-debian.html;
    
        server_name dev.echantillonnage.app;
        ssl_certificate /srv/nodejs/certificatSsl/dev/dev.echantillonnage.app.chained.crt;
        ssl_certificate_key /srv/nodejs/certificatSsl/dev/dev.echantillonnage.app.key;
    
        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                proxy_pass http://127.0.0.1:8091;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection 'upgrade';
                proxy_set_header Host $host;
                proxy_cache_bypass $http_upgrade;
        #try_files $uri $uri/ =404;
        }
     }
    

    When I was launching https://dev.echantillonnage.app , I was getting

        Fix CURL (51) SSL error: no alternative certificate subject name matches
    

    My mistake was the two lines bellow

        listen 444 ssl default_server;
         listen [::]:444 ssl default_server;
    

    I had to change this to:

         listen 443 ssl;
         listen [::]:443 ssl;
    

提交回复
热议问题