prestodb/presto · error · java.lang.IllegalStateException

Unexpected end of DN:

Error message

Unexpected end of DN: 

What it means

Copied OkHttp DN parser: nextAT hit the end of the distinguished-name string while parsing an attribute type (no '=' terminator found). The TLS certificate's subject/issuer string is truncated or malformed.

Source

Thrown at presto-client/src/main/java/okhttp/internal/tls/DistinguishedNameParser.java:76

        for (; pos < length && chars[pos] == ' '; pos++) {
            // skip preceding space chars, they can present after
            // comma or semicolon (compatibility with RFC 1779)
        }
        if (pos == length) {
            return null; // reached the end of DN
        }

        // mark the beginning of attribute type
        beg = pos;

        // attribute type chars
        pos++;
        for (; pos < length && chars[pos] != '=' && chars[pos] != ' '; pos++) {
            // we don't follow exact BNF syntax here:
            // accept any char except space and '='
        }
        if (pos >= length) {
            throw new IllegalStateException("Unexpected end of DN: " + dn);
        }

        // mark the end of attribute type
        end = pos;

        if (chars[pos] == ' ') {
            for (; pos < length && chars[pos] != '=' && chars[pos] == ' '; pos++) {
                // skip trailing space chars between attribute type and '='
                // (compatibility with RFC 1779)
            }

            if (chars[pos] != '=' || pos == length) {
                throw new IllegalStateException("Unexpected end of DN: " + dn);
            }
        }

        pos++; //skip '=' char

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Inspect the certificate DN for trailing commas/semicolons or empty components
  2. Fix the DN string to conform to RFC 2253 formatting
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at presto-client/src/main/java/okhttp/internal/tls/DistinguishedNameParser.java:76 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04). Data as JSON: /api/errors/9b8d044222b4563b. Report an issue: GitHub.