Skip to content

Name the CA file or directory when loading it fails - #584

Open
iliaal wants to merge 1 commit into
ClickHouse:masterfrom
iliaal:fix/ssl-ca-load-error
Open

iliaal wants to merge 1 commit into
ClickHouse:masterfrom
iliaal:fix/ssl-ca-load-error

Conversation

@iliaal

@iliaal iliaal commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

With OpenSSL 3, a missing or unreadable CA file fails with OpenSSL error: -2147483646 : Unknown SSL error. ERR_reason_error_string() returns NULL for system errors, and throwSSLError() has no fallback.

Fix:

  • throwSSLError() falls back to ERR_error_string_n(), which includes the errno text.
  • prepareSSLContext() prefixes CA file and directory load failures with the path, for example Failed to load CA file '/nonexistent': ... No such file or directory.
  • The error queue is cleared before each CA load and after throwSSLError() reads it, so a stale entry can't be reported as the cause of an unrelated failure.
  • The comment above the disabled X509_check_ip() block no longer claims IP addresses go unverified: since OpenSSL 3.0, SSL_set1_host() checks IP literals.

Test: SSLContext.MissingCAFileErrorNamesFileAndReason fails on master and passes here.

With OpenSSL 3, a missing or unreadable CA file failed with "OpenSSL
error: -2147483646 : Unknown SSL error", because
ERR_reason_error_string() returns NULL for system errors and
throwSSLError() had no fallback. I now fall back to
ERR_error_string_n(), which formats the errno text, and
prepareSSLContext() prefixes CA file and directory load failures with
the path.

The error queue is cleared before each CA load and after
throwSSLError() reads it, so a stale entry cannot be reported as the
reason of an unrelated failure. The comment above the disabled
X509_check_ip() block no longer claims IP addresses go unverified,
since OpenSSL 3.0 SSL_set1_host() checks IP literals.
@iliaal
iliaal requested review from mzitnik and slabko as code owners October 18, 2026 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant