Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).

## [Unreleased]

### Added

- Support for `SSL_CERT_FILE` and `SSL_CERT_DIR` environment variables for
custom CA store.

## [0.9] - 2026-07-18

[0.9]: https://github.com/ccache/ccache-storage-http-cpp/releases/tag/v0.9
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,14 @@ export CCACHE_REMOTE_STORAGE="https://cache.example.com @use-netrc"
export CCACHE_REMOTE_STORAGE="https://cache.example.com @netrc-file=/path/to/my-netrc"
```

### Custom CA store

Set `SSL_CERT_FILE` to a CA certificate bundle or `SSL_CERT_DIR` to a CA
certificate directory to override the CA store used for HTTPS requests.

Note: The helper process is spawned by ccache, so these variables must be set
before ccache is invoked.

## Optional debug logging

You can set the `CRSH_LOGFILE` environment variable to enable debug logging to a
Expand Down
10 changes: 10 additions & 0 deletions src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,16 @@ std::optional<Config> parse_config()
config.idle_timeout_seconds = *idle_val;
LOG("Idle timeout: " + std::to_string(config.idle_timeout_seconds));

const char* ssl_cert_file = std::getenv("SSL_CERT_FILE");
if (ssl_cert_file && ssl_cert_file[0] != '\0') {
config.ssl_cert_file = ssl_cert_file;
}

const char* ssl_cert_dir = std::getenv("SSL_CERT_DIR");
if (ssl_cert_dir && ssl_cert_dir[0] != '\0') {
config.ssl_cert_dir = ssl_cert_dir;
}

const char* num_attr_str = std::getenv("CRSH_NUM_ATTR");
if (!num_attr_str || num_attr_str[0] == '\0') {
num_attr_str = "0";
Expand Down
4 changes: 4 additions & 0 deletions src/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ struct Config
std::vector<std::pair<std::string, std::string>> headers;
bool use_netrc = false;
std::optional<std::string> netrc_file;

// TLS certificate store overrides from the environment.
std::optional<std::string> ssl_cert_file;
std::optional<std::string> ssl_cert_dir;
};

std::optional<Config> parse_config();
8 changes: 8 additions & 0 deletions src/storage_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,14 @@ CURL* StorageClient::create_easy_handle(HttpRequest* request)
curl_easy_setopt(handle, CURLOPT_WRITEDATA, request);
curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, write_callback);

if (_config.ssl_cert_file) {
curl_easy_setopt(handle, CURLOPT_CAINFO, _config.ssl_cert_file->c_str());
}

if (_config.ssl_cert_dir) {
curl_easy_setopt(handle, CURLOPT_CAPATH, _config.ssl_cert_dir->c_str());
}

if (_config.use_netrc) {
curl_easy_setopt(handle, CURLOPT_NETRC, CURL_NETRC_OPTIONAL);
if (_config.netrc_file) {
Expand Down
Loading