Support >
  About cybersecurity >
  What should I do if the primary domain is working correctly but the subdomain is showing an HTTPS error?
What should I do if the primary domain is working correctly but the subdomain is showing an HTTPS error?
Time : 2025-11-14 16:27:30
Edit : DNS.COM

  The primary domain is accessible, displaying a green padlock icon in the browser, but accessing subdomains results in security errors such as "Insecure connection," "Invalid certificate," or "Certificate does not match domain." While this is common, the underlying causes can be complex, involving certificate type, DNS configuration, server binding, SSL connection, and browser caching. To completely resolve subdomain HTTPS errors, a systematic troubleshooting process is needed to ensure the subdomain can function correctly independently or by sharing a certificate with the primary domain, ultimately achieving a complete and secure HTTPS environment.

  First, it's necessary to confirm whether the certificate type supports subdomain access. Many people use single-domain SSL certificates, containing only the primary domain, such as example.com. These certificates cannot automatically cover www.example.com, api.example.com, or other subdomains, inevitably resulting in "Untrusted" or "Mismatch" errors when accessing subdomains. The solution is to choose a certificate type that supports subdomains:

  Wildcard certificates, such as *.example.com, can cover all primary subdomains but exclude second-level subdomains like api.test.example.com.

  Multi-domain certificates allow manual binding of multiple domains and subdomains, supporting more flexible combinations.

  If a single-domain certificate is already in use, the most direct solution to subdomain HTTPS errors is to reapply for a certificate, choosing one that supports subdomains, and adding all business-related subdomains to the certificate binding.

  The second step is to check if the server's SSL configuration correctly binds the subdomains. Even if the certificate itself supports subdomains, errors will still occur if the corresponding certificate and key are not correctly specified in the server configuration. In Nginx, subdomains must be configured with a separate `server` block pointing to the correct certificate file, for example:

server {
    listen 443 ssl;
    server_name api.example.com;

    ssl_certificate /etc/nginx/ssl/fullchain.pem;
    ssl_certificate_key /etc/nginx/ssl/privkey.pem;

    root /var/www/api;
}

  In Apache, you would need to configure a corresponding VirtualHost for each subdomain:

<VirtualHost *:443>
    ServerName api.example.com
    DocumentRoot /var/www/api

    SSLEngine on
    SSLCertificateFile /path/fullchain.pem
    SSLCertificateKeyFile /path/privkey.pem
    SSLCertificateChainFile /path/chain.pem
</VirtualHost>

  If the top-level domain and subdomains share the same certificate file, but the server does not correctly point to fullchain.pem or has an incorrect server_name configuration, the subdomains will still report certificate errors. Therefore, it is essential to ensure that the configuration for each subdomain is correct.

  The third step is to check if the DNS configuration is effective. HTTPS requests resolve DNS before accessing subdomains. If the DNS resolution is incorrect or ineffective, even if the certificate is correct, the browser will still warn of an insecure connection. Common issues include:

  • Subdomain lacks A or CNAME record
  • Incorrect DNS resolution IP
  • DNS cache not refreshed

  You can check if the parsing is working using the following command:

nslookup api.example.com
dig api.example.com
ping api.example.com

  If the DNS resolution result is incorrect, you need to add or modify the corresponding record in the domain management platform and wait for the resolution to take effect. Also, if the DNS has a CDN or reverse proxy, you must ensure that HTTPS is enabled on the CDN and the correct certificate is bound; otherwise, the browser will report a certificate mismatch.

  Fourth, check if the certificate chain is complete. Some browsers have strict requirements for certificate chains. If the certificate used by the subdomain is missing an intermediate certificate, the top-level domain may display correctly, but the subdomain may report "untrusted". You can check the certificate chain completeness using the following command:

openssl s_client -connect api.example.com:443 -showcerts

  This forces subdomains to use HTTPS, avoiding warnings associated with mixed content.

  Sixth, consider TLS protocol and browser compatibility. If the server's TLS configuration is outdated, such as still using TLS 1.0 or TLS 1.1, some modern browsers may force errors when accessing subdomains, while the primary domain may be cached or whitelisted by the browser. It is recommended to enable TLS 1.2 and TLS 1.3 in Nginx or Apache and disable older protocols.

if ($scheme = http) {
    return 301 https://$host$request_uri;
}

  This forces subdomains to use HTTPS, avoiding warnings associated with mixed content.

  Sixth, consider TLS protocol and browser compatibility. If the server's TLS configuration is outdated, such as still using TLS 1.0 or TLS 1.1, some modern browsers may force errors when accessing subdomains, while the primary domain may be cached or whitelisted by the browser. It is recommended to enable TLS 1.2 and TLS 1.3 in Nginx or Apache and disable older protocols.

ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;

  Ensure the encryption protocol is compatible with modern browsers.

  Seventh, do not overlook browser caching issues. When subdomain HTTPS errors occur, try clearing the browser cache, switching devices, or using curl to test:

curl -I https://api.example.com

  If curl returns a 200 error and the certificate is valid, but the browser still reports an insecure error, the problem may be related to local caching or security policies. This can be resolved by clearing the cache or using incognito mode.

  Finally, if the subdomain uses a CDN or reverse proxy, you also need to check if the CDN is correctly configured with SSL. For example, some CDNs do not enable HTTPS by default. You need to bind the certificate in the console and select full-site HTTPS origin-back mode; otherwise, accessing the subdomain will result in an error. Furthermore, ensure that the CDN certificate is consistent with the origin server certificate to avoid certificate mismatches.

  Through the above troubleshooting process, you can usually pinpoint the reason why the main domain is working correctly but the subdomain is experiencing HTTPS errors. Key points include: whether the certificate type supports the subdomain, whether the server configuration is correctly bound, whether DNS resolution is effective, whether the certificate chain is complete, whether page resources are mixed, whether the TLS protocol is compatible, and whether the caching or CDN configuration is reasonable. Only when each step is correct can the subdomain operate securely and reliably in an HTTPS environment like the main domain.

  In summary, while subdomain HTTPS errors are common, they can usually be resolved through systematic troubleshooting. By selecting certificates that support subdomains, correctly configuring servers and DNS, improving the certificate chain, fixing mixed content, upgrading the TLS protocol, and checking caching and CDN configurations, errors can be completely eliminated, ensuring secure access to the entire site. Proper subdomain HTTPS configuration not only increases user trust but also aids in search engine optimization, enhances data transmission security, and provides a solid guarantee for the long-term stable operation of the website.

DNS Puff
DNS Luna
DNS Amy
DNS Grace
DNS Jude
DNS Sugar
DNS Becky
DNS NOC
Title
Email Address
Type
Information
Code
Submit