Skip to content

Explicitly manage TLS/SSL CA paths for remote I/O#817

Merged
rapids-bot[bot] merged 12 commits intorapidsai:branch-25.10from
kingcrimsontianyu:fix_ssl_ca
Sep 15, 2025
Merged

Explicitly manage TLS/SSL CA paths for remote I/O#817
rapids-bot[bot] merged 12 commits intorapidsai:branch-25.10from
kingcrimsontianyu:fix_ssl_ca

Conversation

@kingcrimsontianyu
Copy link
Contributor

@kingcrimsontianyu kingcrimsontianyu commented Sep 10, 2025

Background

libcurl have two path parameters related to the certificate authority (CA):

  • CURLOPT_CAINFO, which specifies the CA bundle file path.
  • CURLOPT_CAPATH, which specifies the directory of individual CA certificates with hash-based naming.

The default paths are determined at compile-time, which can cause issues if the Linux distributions where libcurl is built and run are different (e.g. on Rocky Linux vs Ubuntu as in our CI vs our lab system), and the certificates files are likely at different locations. This problem has been observed in KvikIO's wheel distribution, where HTTPS would fail with the message:

error setting certificate verify locations: CAfile: /etc/pki/tls/certs/ca-bundle.crt CApath: /etc/ssl/certs

This PR

This PR addresses this problem. The certificate path is now explicitly searched for in the following order. The compile-time parameters, if any, are still used but treated with lowest priority.

  • CA bundle file: Check env vars CURL_CA_BUNDLE, and SSL_CERT_FILE
  • CA directory: Check env vars SSL_CERT_DIR
  • CA bundle file: Search a set of distribution-specific locations for accessible bundle
  • CA directory: Search a set of distribution-specific locations for accessible directory
  • CA bundle file: Check if the compile-time path is given and accessible
  • CA directory: Check if the compile-time parameter is given and accessible

Depends on #819 for the use of static structured binding which is only available in C++ >=20

Closes #711

@kingcrimsontianyu kingcrimsontianyu added improvement Improves an existing functionality non-breaking Introduces a non-breaking change c++ Affects the C++ API of KvikIO labels Sep 10, 2025
@copy-pr-bot
Copy link

copy-pr-bot bot commented Sep 10, 2025

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@kingcrimsontianyu
Copy link
Contributor Author

/ok to test 9cb4137

@kingcrimsontianyu
Copy link
Contributor Author

Verification

A libcurl intentionally built with bad CA bundle file and CA directory paths was used, and a toy code that uses the search method in this PR was tested under various conditions:

  • No env vars specified (i.e. searching standard system locations)
  • Correct CURL_CA_BUNDLE
  • Correct SSL_CERT_FILE
  • Correct SSL_CERT_DIR

The toy program is able to locate and use the correct certificate in all the conditions above.


void set_up_ca_paths(CurlHandle& curl)
{
static auto const [ca_bundle_file, ca_directory] = get_ca_paths();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

static structured binding is not supported in C++17, and this helped to identify an oversight to be fixed by #819.

@kingcrimsontianyu
Copy link
Contributor Author

/ok to test 1903a7b

@kingcrimsontianyu kingcrimsontianyu marked this pull request as ready for review September 14, 2025 20:30
@kingcrimsontianyu kingcrimsontianyu requested review from a team as code owners September 14, 2025 20:30
Copy link
Member

@madsbk madsbk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work

@kingcrimsontianyu
Copy link
Contributor Author

/merge

@rapids-bot rapids-bot bot merged commit dde1435 into rapidsai:branch-25.10 Sep 15, 2025
77 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ Affects the C++ API of KvikIO improvement Improves an existing functionality non-breaking Introduces a non-breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SSL error when loading remote file with pip installed kvikio

2 participants