Skip to content

Conversation

Keno
Copy link
Member

@Keno Keno commented Jun 26, 2025

This adjusts LibGit2 to the new ca_root_locations API proposed in JuliaLang/NetworkOptions.jl#42. Opening this up early to have both sides up together. Obviously it's a little messy to have an API in NetworkOptions that returns multiples files/directories when this isn't necessarily supported in downstream clients. However, I think it's important that the case where SSL_CERT_DIR is delimiter separated and libgit2 is using openssl as its backend works, since we might encounter configurations that that look like that. As I said in the NetworkOptions PR, I could imagine situations in which having multiple files/directories could be useful (e.g. to always push our bundled files), but since we don't have an immediate use case for it, I don't see any great need to tweak our upstream libraries to support it. That said, I still think it's worth having NetworkOptions have the full API so that we don't have to break the API again in the future if we ever want to do this.

Largely written by Claude.

Update LibGit2 to use the new NetworkOptions.ca_root_locations() API
which returns a tuple of (files, directories) instead of a single path.

Key improvements:
- Query SSL backend first using git_libgit2_feature_backend
- Only call NetworkOptions.ca_root_locations() for backends that support
  custom certificates (OpenSSL and mbedTLS)
- Skip certificate configuration for system backends (SecureTransport,
  Schannel, WinHTTP) which use system certificates
- Support multiple certificate directories for OpenSSL by joining with delimiter
- Warn when multiple directories specified for mbedTLS (only supports one)
- Warn when multiple certificate files specified (only first is used)

This avoids unnecessary work for system certificate backends and properly
handles SSL_CERT_FILE and SSL_CERT_DIR environment variables based on the
underlying SSL/TLS implementation.
@Keno Keno requested a review from StefanKarpinski June 26, 2025 03:52
@Keno Keno added the DO NOT MERGE Do not merge this PR! label Jun 26, 2025
@Keno
Copy link
Member Author

Keno commented Jun 26, 2025

(Do not merge until the NetorkOptions PR is merged and bumped here).

@Keno Keno marked this pull request as draft June 26, 2025 03:52
@giordano giordano added the libgit2 The libgit2 library or the LibGit2 stdlib module label Jun 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DO NOT MERGE Do not merge this PR! libgit2 The libgit2 library or the LibGit2 stdlib module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants