apache/hadoop · error · SSLException

hostname in certificate didn't match

Error message

hostname in certificate didn't match: {hostnames} !={buf}

What it means

SSLHostnameVerifier strict matching: after extracting the CN (including wildcard forms) from the certificate's subject, none of the candidate hostnames equals or wildcard-matches the expected host, so the certificate was issued for a different host.

Solutions

  1. Use a certificate whose CN or subjectAltName matches the hostname being connected to.
  2. Fix DNS or the configured hostname so it matches the certificate identity.
  3. If intentional (e.g. testing), use an appropriate hostname verifier policy, but prefer issuing a correct certificate.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/ssl/SSLHostnameVerifier.java:457 when the library encounters an invalid state.

Common situations: See trigger scenarios.

Understand the failure class


AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22). Data as JSON: /api/errors/15b4a96b1525e66e. Report an issue: GitHub.

Appendix: source

Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/ssl/SSLHostnameVerifier.java:457

                    final String hostName =
                        StringUtils.toLowerCase(hosts[i].trim());
                    if (doWildcard) {
                        match = hostName.endsWith(cn.substring(1));
                        if (match && strictWithSubDomains) {
                            // If we're in strict mode, then [*.foo.com] is not
                            // allowed to match [a.b.foo.com]
                            match = countDots(hostName) == countDots(cn);
                        }
                    } else {
                        match = hostName.equals(cn);
                    }
                    if (match) {
                        break out;
                    }
                }
            }
            if (!match) {
                throw new SSLException("hostname in certificate didn't match: " + hostnames + " !=" + buf);
            }
        }

        public static boolean isIP4Address(final String cn) {
            boolean isIP4 = true;
            String tld = cn;
            int x = cn.lastIndexOf('.');
            // We only bother analyzing the characters after the final dot
            // in the name.
            if (x >= 0 && x + 1 < cn.length()) {
                tld = cn.substring(x + 1);
            }
            for (int i = 0; i < tld.length(); i++) {
                if (!Character.isDigit(tld.charAt(0))) {
                    isIP4 = false;
                    break;
                }
            }

View on GitHub (pinned to 2add963021)