Conflict with certificates with sub domains

Please fill out the fields below so we can help you better. Note: you must provide your domain name to get help. Domain names for issued certificates are all made public in Certificate Transparency logs (e.g. crt.sh | example.com), so withholding your domain name here does not increase secrecy, but only makes it harder for us to provide help.

My domain is:

this is the main domain
vmaportfolios.com

this is for staging
staging.vmaportfolios.com

for our database
ydb.vmaportfolios.com

I ran this command:

sudo certbot --nginx -d staging.vmaportfolios.com
sudo certbot --nginx -d ydb.vmaportfolios.com

The operating system my web server runs on is (include version):

ubuntu 22.04 nginx

nginx configuration for staging

 server_name staging.vmaportfolios.com;

    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/staging.example.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/staging.example.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

nginx configuration for ydb

    server_name ydb.vmaportfolios.com;

    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/ydb.example.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/ydb.example.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

i follow the installation of certbot in here

and when i visit the site it says

This server couldn't prove that it's ydb.vmaportfolios.com ; its security certificate is from staging.vmaportfolios.com . This may be caused by a misconfiguration or an attacker intercepting your connection.

i am not sure where the error is or i misconfigure? the ssl certificate is actually different in my nginx configuration so how did this happen?

Thank you.

Hello @nelsondev, welcome to the Let's Encrypt community. :slightly_smiling_face:

Likely a nginx configuration issue.

For general nginx information you might find nginx documentation and https://forum.nginx.org/ helpful.

Please share the output of sudo nginx -T, that is a capitol T.

Edit:
Also using the online tool Let's Debug yields this WARNING
https://letsdebug.net/ydb.vmaportfolios.com/2029279

UnexpectedHttpResponse
WARNING
Sending an ACME HTTP validation request to ydb.vmaportfolios.com results in unexpected HTTP response 401 Unauthorized. This indicates that the webserver is misconfigured or misbehaving.
401 Unauthorized

<html>
<head><title>401 Authorization Required</title></head>
<body>
<center><h1>401 Authorization Required</h1></center>
<hr><center>nginx/1.18.0 (Ubuntu)</center>
</body>
</html>


Trace:
@0ms: Making a request to http://ydb.vmaportfolios.com/.well-known/acme-challenge/letsdebug-test (using initial IP 154.26.128.88)
@0ms: Dialing 154.26.128.88
@548ms: Server response: HTTP 401 Unauthorized

And curl shows
curl -i http://ydb.vmaportfolios.com/.well-known/acme-challenge/sometestfile

$ curl -i http://ydb.vmaportfolios.com/.well-known/acme-challenge/sometestfile
HTTP/1.1 401 Unauthorized
Server: nginx/1.18.0 (Ubuntu)
Date: Fri, 14 Jun 2024 01:19:36 GMT
Content-Type: text/html
Content-Length: 188
Connection: keep-alive
WWW-Authenticate: Basic realm="Restricted Access"

<html>
<head><title>401 Authorization Required</title></head>
<body>
<center><h1>401 Authorization Required</h1></center>
<hr><center>nginx/1.18.0 (Ubuntu)</center>
</body>
</html>

Edit:
The certificate being served https://decoder.link/sslchecker/ydb.vmaportfolios.com/443
shows " Hostname: close Doesn't match Common Name or/and SANs" for ydb.vmaportfolios.com

2 Likes

Hey @Bruce5051 thanks for your reply

here is the result for nginx -T

nginx: [warn] conflicting server name "ydb.vmaportfolios.com" on 0.0.0.0:80, ignored
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
# configuration file /etc/nginx/nginx.conf:
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
        worker_connections 768;
        # multi_accept on;
}

http {

        ##
        # Basic Settings
        ##

        sendfile on;
        tcp_nopush on;
        types_hash_max_size 2048;
        # server_tokens off;

        # server_names_hash_bucket_size 64;
        # server_name_in_redirect off;

        include /etc/nginx/mime.types;
        default_type application/octet-stream;

        ##
        # SSL Settings
        ##

        ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE
        ssl_prefer_server_ciphers on;

        ##
        # Logging Settings
        ##

        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;

        ##
        # Gzip Settings
        ##

        gzip on;

        # gzip_vary on;
        # gzip_proxied any;
        # gzip_comp_level 6;
        # gzip_buffers 16 8k;
        # gzip_http_version 1.1;
        # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

        ##
        # Virtual Host Configs
        ##

        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;
}


#mail {
#       # See sample authentication script at:
#       # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
#       # auth_http localhost/auth.php;
#       # pop3_capabilities "TOP" "USER";
#       # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
#       server {
#               listen     localhost:110;
#               protocol   pop3;
#               proxy      on;
#       }
#
#       server {
#               listen     localhost:143;
#               protocol   imap;
#               proxy      on;
#       }
#}

# configuration file /etc/nginx/sites-enabled/phpmyadmin:
## phpmyadmin for vma project



server {
        #listen 80 default_server;
        #listen [::]:80 default_server;

        # SSL configuration
        #
        # listen 443 ssl default_server;
        # listen [::]:443 ssl default_server;
        #
        # Note: You should disable gzip for SSL traffic.
        # See: https://bugs.debian.org/773332
        #
        # Read up on ssl_ciphers to ensure a secure configuration.
        # See: https://bugs.debian.org/765782
        #
        # Self signed certs generated by the ssl-cert package
        # Don't use them in a production server!
        #
        # include snippets/snakeoil.conf;

        root /usr/share/phpmyadmin;

        # Add index.php to the list if you are using PHP
        index index.php index.html;

        server_name ydb.vmaportfolios.com;

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ =404;
                auth_basic "Restricted Access";
                auth_basic_user_file /etc/nginx/.htpasswd;

        }

        # pass PHP scripts to FastCGI server
        #
        location ~ \.php$ {
               include snippets/fastcgi-php.conf;
        #
        #       # With php-fpm (or other unix sockets):
               fastcgi_pass unix:/run/php/php8.2-fpm.sock;
        #       # With php-cgi (or other tcp sockets):
        #       fastcgi_pass 127.0.0.1:9000;
        }

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        location ~ /\.ht {
               deny all;
        }


    #listen 443 ssl; # managed by Certbot
    #ssl_certificate /etc/letsencrypt/live/ydb.vmaportfolios.com/fullchain.pem; # managed by Certbot
    #ssl_certificate_key /etc/letsencrypt/live/ydb.vmaportfolios.com/privkey.pem; # managed by Certbot
    #include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    #ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}




server {
    if ($host = ydb.vmaportfolios.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot



        server_name ydb.vmaportfolios.com;
    listen 80;
    return 404; # managed by Certbot


}


# Default server configuration
#
server {
        #listen 80;
        #listen [::]:80;

        # SSL configuration
        #
        # listen 443 ssl default_server;
        # listen [::]:443 ssl default_server;
        #
        # Note: You should disable gzip for SSL traffic.
        # See: https://bugs.debian.org/773332
        #
        # Read up on ssl_ciphers to ensure a secure configuration.
        # See: https://bugs.debian.org/765782
        #
        # Self signed certs generated by the ssl-cert package
        # Don't use them in a production server!
        #
        # include snippets/snakeoil.conf;

        root /var/www/staging/vankemeisha-school-system/public;

        # Add index.php to the list if you are using PHP
        index index.php;

        server_name staging.vmaporfolios.com;

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ /index.php?$query_string;
        }

        # pass PHP scripts to FastCGI server
        #
        location ~ \.php$ {
                include snippets/fastcgi-php.conf;
        #
        #       # With php-fpm (or other unix sockets):
                fastcgi_pass unix:/run/php/php8.2-fpm.sock;
        #       # With php-cgi (or other tcp sockets):
        #       fastcgi_pass 127.0.0.1:9000;
        }

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        location ~ /\.ht {
                deny all;
        }

        #listen [::]:443 ssl ipv6only=on; # managed by Certbot
        listen 443 ssl; # managed by Certbot
        ssl_certificate /etc/letsencrypt/live/staging.vmaportfolios.com/fullchain.pem; # managed by Certbot
        ssl_certificate_key /etc/letsencrypt/live/staging.vmaportfolios.com/privkey.pem; # managed by Certbot
        include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
        ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}


# Virtual Host configuration for example.com
#
# You can move that to a different file under sites-available/ and symlink that
# to sites-enabled/ to enable it.
#
#server {
#       listen 80;
#       listen [::]:80;
#
#       server_name example.com;
#
#       root /var/www/example.com;
#       index index.html;
#
#       location / {
#               try_files $uri $uri/ =404;
#       }
#}

server {

    if ($host = staging.vmaportfolios.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


        listen 80;
        listen [::]:80;

        server_name staging.vmaportfolios.com;
    return 404; # managed by Certbot




}

# configuration file /etc/letsencrypt/options-ssl-nginx.conf:
# This file contains important security parameters. If you modify this file
# manually, Certbot will be unable to automatically provide future security
# updates. Instead, Certbot will print and log an error message with a path to
# the up-to-date file that you will need to refer to when manually updating
# this file. Contents are based on https://ssl-config.mozilla.org

ssl_session_cache shared:le_nginx_SSL:10m;
ssl_session_timeout 1440m;
ssl_session_tickets off;

ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers off;

ssl_ciphers "ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384";

# configuration file /etc/nginx/sites-enabled/vmaportfolio:
##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# https://www.nginx.com/resources/wiki/start/
# https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/
# https://wiki.debian.org/Nginx/DirectoryStructure
#
# In most cases, administrators will remove this file from sites-enabled/ and
# leave it as reference inside of sites-available where it will continue to be
# updated by the nginx packaging team.
#
# This file will automatically load configuration files provided by other
# applications, such as Drupal or Wordpress. These applications will be made
# available underneath a path with that package name, such as /drupal8.
#
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
##

# Default server configuration
#
server {

        # SSL configuration
        #
        # listen 443 ssl default_server;
        # listen [::]:443 ssl default_server;
        #
        # Note: You should disable gzip for SSL traffic.
        # See: https://bugs.debian.org/773332
        #
        # Read up on ssl_ciphers to ensure a secure configuration.
        # See: https://bugs.debian.org/765782
        #
        # Self signed certs generated by the ssl-cert package
        # Don't use them in a production server!
        #
        # include snippets/snakeoil.conf;

        root /var/www/production/;

        # Add index.php to the list if you are using PHP
        index index.php;

        server_name vmaportfolios.com www.vmaportfolios.com;

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ /index.php?$query_string;
        }

        # pass PHP scripts to FastCGI server
        #
        location ~ \.php$ {
                include snippets/fastcgi-php.conf;
        #
        #       # With php-fpm (or other unix sockets):
                fastcgi_pass unix:/run/php/php8.2-fpm.sock;
        #       # With php-cgi (or other tcp sockets):
        #       fastcgi_pass 127.0.0.1:9000;
        }

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        location ~ /\.ht {
                deny all;
        }

    listen [::]:443 ssl ipv6only=on; # managed by Certbot
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/vmaportfolios.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/vmaportfolios.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot


}


# Virtual Host configuration for example.com
#
# You can move that to a different file under sites-available/ and symlink that
# to sites-enabled/ to enable it.
#
#server {
#       listen 80;
#       listen [::]:80;
#
#       server_name example.com;
#
#       root /var/www/example.com;
#       index index.html;
#
#       location / {
#               try_files $uri $uri/ =404;
#       }
#}

server {
    if ($host = www.vmaportfolios.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    if ($host = vmaportfolios.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


        listen 80;
        listen [::]:80;

        server_name vmaportfolios.com www.vmaportfolios.com;
    return 404; # managed by Certbot




}

i remove some part that are not relevant

I commented out the SSL certificates for YDB so that I can access the staging environment. The staging will work if I remove or comment out the SSL certificate for YDB. The same goes for staging: if I comment out the SSL certificate, the YDB will work.

1 Like

Hi @nelsondev,

Please show the output of sudo certbot certificates

1 Like

here


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Found the following certs:
  Certificate Name: staging.vmaportfolios.com
    Serial Number: 31d8bc8b79556e991e43475c9c162066224
    Key Type: ECDSA
    Domains: staging.vmaportfolios.com
    Expiry Date: 2024-09-11 05:55:23+00:00 (VALID: 89 days)
    Certificate Path: /etc/letsencrypt/live/staging.vmaportfolios.com/fullchain.pem
    Private Key Path: /etc/letsencrypt/live/staging.vmaportfolios.com/privkey.pem
  Certificate Name: vmaportfolios.com
    Serial Number: 4c541c4af75d96170c6c80a603bb29f7a68
    Key Type: ECDSA
    Domains: vmaportfolios.com www.vmaportfolios.com
    Expiry Date: 2024-09-11 05:50:48+00:00 (VALID: 89 days)
    Certificate Path: /etc/letsencrypt/live/vmaportfolios.com/fullchain.pem
    Private Key Path: /etc/letsencrypt/live/vmaportfolios.com/privkey.pem
  Certificate Name: ydb.vmaportfolios.com
    Serial Number: 44ce13485b289715da2c9ec5cf98fd6ed91
    Key Type: ECDSA
    Domains: ydb.vmaportfolios.com
    Expiry Date: 2024-09-11 22:34:40+00:00 (VALID: 89 days)
    Certificate Path: /etc/letsencrypt/live/ydb.vmaportfolios.com/fullchain.pem
    Private Key Path: /etc/letsencrypt/live/ydb.vmaportfolios.com/privkey.pem
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Did you restart nginx after getting the new certificates?

Edit:
Also for ydb.vmaportfolios.com the only ssl_certificate is commented out.

`

2 Likes

I actually restarted many times, but not when I received the new certificates.

i commented out the blocks related to ssl for ydb.vmaportfolios.com so that i can access the staging.

1 Like

I believe it is a misconfiguration, (side note: I've had a migraine headache all day)
so kindly wait for more knowledgeable Let's Encrypt community volunteers to assist.

2 Likes

Thanks @Bruce5051 i'll try to double check my nginx configuration.

3 Likes

I see a TYPO:
server_name staging.vmaporfolios.com;

It's T time!

6 Likes

@rg305 WOW thank you for that! that solves my issue haha!

4 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.