try_init_openssl_env_vars() breaks certificate validation (on FreeBSD)
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 18/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- rust
- 領域
- cryptography, security
調査の方向性
The bug sits in the candidate directory list and environment setup in src/lib.rs, where try_init_openssl_env_vars() calls probe() and then sets SSL_CERT_DIR and SSL_CERT_FILE. Start by reading that probe logic and reproduce the FreeBSD case by checking which candidate directories contain a certs subdirectory. Done means the variables are only set to paths OpenSSL can actually use, verified by the sample program succeeding.
索引モデルが issue の本文から書いたものです。
説明
try_init_openssl_env_vars() invokes probe() and then manipulates the process environment with SSL_CERT_DIR/SSL_CERT_FILE. This may happen on any system, but for me at least on FreeBSD, when the following condition is met:
https://github.com/alexcrichton/openssl-probe/blob/4221247cfad3e77b758bf9b6e4c3d91a557c429e/src/lib.rs#L31-L50
None of these directories contain a CAfile, but contain a dir CANDIDATE/certs which is not CApath. That path is being used to set SSL_CERT_DIR, OpenSSL picks up this empty directory and fails all validations.
Here on the example of FreeBSD:
For many years FreeBSD contains certctl(8) to manage the system truststore which is assembled from various sources into a CApath in /etc/ssl/certs. If one relies on OpenSSL's SSL_CTX_set_default_verify_paths() all is good.
certctl(8) includes by default these two paths with CA certificates:
/usr/share/certs/trusted: comes with the base system and contains all NSS CA certificate from Mozilla/usr/local/share/certs: is initially empty and allows an admin to drop off custom/enterprise CAs (which a do at work).
certcrtl rehash scans all of them and puts symlinks into /etc/ssl/certs, but since candidate_cert_dirs[] has ""/usr/local/share" before "/etc/ssl" an invalid value is set and all fails.
A sample main which fails:
use curl::easy::Easy;
fn main() {
openssl_probe::init_ssl_cert_env_vars();
let mut data = Vec::new();
let mut handle = Easy::new();
handle.url("https://www.rust-lang.org/").unwrap();
{
let mut transfer = handle.transfer();
transfer.write_function(|new_data| {
data.extend_from_slice(new_data);
Ok(new_data.len())
}).unwrap();
transfer.perform().unwrap();
}
}
Remove the first line in the main and you are good to go.
This causes problems with downstream consumers like git2-rs and then cargo. I will report the issue also downstream.
- 主要言語
- Rust
- スター
- 61
- フォーク
- 23
- 平均マージ
- 43分
- マージ済み PR(30日)
- 2
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
rustls/openssl-probe のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 58/100
rustls/openssl-probe#50 · コメント 4 件 ·
-
/etc/ssl/certs/ca-bundle.crt no longer discovered on Linux再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
rustls/openssl-probe#48 · コメント 2 件 ·
-
Support for Windowsオープン
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
rustls/openssl-probe#23 · コメント 1 件 ·
-
Freebsd certs not found再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 30/100
rustls/openssl-probe#20 · コメント 2 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 15/100
rustls/openssl-probe#8 · コメント 6 件 ·
rustls/openssl-probe の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
pop-os/cosmic-settings#2296 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
jonathanong/no-mistakes#3431 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
Eyevinn/open-live-ingest#36 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
superradcompany/microsandbox#2071 ·
メンテナーはふだん 1 日以内に返信