Skip to content

Commit c21d62c

Browse files
authored
Merge branch 'master' into master
2 parents 71f08ce + 485e489 commit c21d62c

File tree

6 files changed

+32
-16
lines changed

6 files changed

+32
-16
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- uses: actions/checkout@v2
2121
- uses: sfackler/actions/rustup@master
2222
- uses: sfackler/actions/rustfmt@master
23-
23+
2424
windows:
2525
strategy:
2626
fail-fast: false
@@ -35,7 +35,7 @@ jobs:
3535
- uses: actions/checkout@v2
3636
- uses: sfackler/actions/rustup@master
3737
with:
38-
version: 1.65.0
38+
version: 1.80.0
3939
- run: echo "::set-output name=version::$(rustc --version)"
4040
id: rust-version
4141
- uses: actions/cache@v1

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
## [Unreleased]
44

5+
## [v0.2.12]
6+
7+
### Fixed
8+
9+
* Stopped using a deprecated openssl-probe API.
10+
511
## [v0.2.11]
612

713
### Fixed

Cargo.toml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
[package]
22
name = "native-tls"
3-
version = "0.2.12"
4-
edition = "2018"
3+
version = "0.2.14"
54
authors = ["Steven Fackler <[email protected]>"]
65
license = "MIT OR Apache-2.0"
76
description = "A wrapper over a platform's native TLS implementation"
87
repository = "https://github.com/sfackler/rust-native-tls"
98
readme = "README.md"
10-
rust-version = "1.53.0"
9+
rust-version = "1.80.0"
1110

1211
[package.metadata.docs.rs]
1312
features = ["alpn"]
@@ -34,7 +33,7 @@ schannel = "0.1.17"
3433

3534
[target.'cfg(not(any(target_os = "windows", target_vendor = "apple")))'.dependencies]
3635
log = "0.4.5"
37-
openssl = "0.10.46"
36+
openssl = "0.10.69"
3837
openssl-sys = "0.9.81"
3938
openssl-probe = "0.1"
4039

build.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,6 @@ fn main() {
1717
println!("cargo:rustc-cfg=have_min_max_version");
1818
}
1919
}
20+
21+
println!("cargo::rustc-check-cfg=cfg(have_min_max_version)")
2022
}

src/imp/openssl.rs

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,16 @@ use self::openssl::ssl::{
1111
SslVerifyMode,
1212
};
1313
use self::openssl::x509::{store::X509StoreBuilder, X509VerifyResult, X509};
14+
use self::openssl_probe::ProbeResult;
1415
use std::error;
1516
use std::fmt;
1617
use std::io;
17-
use std::sync::Once;
18+
use std::sync::LazyLock;
1819

1920
use crate::{Protocol, TlsAcceptorBuilder, TlsConnectorBuilder};
2021

22+
static PROBE_RESULT: LazyLock<ProbeResult> = LazyLock::new(openssl_probe::probe);
23+
2124
#[cfg(feature = "have_min_max_version")]
2225
fn supported_protocols(
2326
min: Option<Protocol>,
@@ -85,11 +88,6 @@ fn supported_protocols(
8588
Ok(())
8689
}
8790

88-
fn init_trust() {
89-
static ONCE: Once = Once::new();
90-
ONCE.call_once(openssl_probe::init_ssl_cert_env_vars);
91-
}
92-
9391
#[cfg(target_os = "android")]
9492
fn load_android_root_certs(connector: &mut SslContextBuilder) -> Result<(), Error> {
9593
use std::fs;
@@ -272,9 +270,20 @@ pub struct TlsConnector {
272270

273271
impl TlsConnector {
274272
pub fn new(builder: &TlsConnectorBuilder) -> Result<TlsConnector, Error> {
275-
init_trust();
276-
277273
let mut connector = SslConnector::builder(SslMethod::tls())?;
274+
275+
// We need to load these separately so an error on one doesn't prevent the other from loading.
276+
if let Some(cert_file) = &PROBE_RESULT.cert_file {
277+
if let Err(e) = connector.load_verify_locations(Some(cert_file), None) {
278+
debug!("load_verify_locations cert file error: {:?}", e);
279+
}
280+
}
281+
if let Some(cert_dir) = &PROBE_RESULT.cert_dir {
282+
if let Err(e) = connector.load_verify_locations(None, Some(cert_dir)) {
283+
debug!("load_verify_locations cert dir error: {:?}", e);
284+
}
285+
}
286+
278287
if let Some(ref identity) = builder.identity {
279288
connector.set_certificate(&identity.0.cert)?;
280289
connector.set_private_key(&identity.0.pkey)?;

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ use std::fmt;
103103
use std::io;
104104
use std::result;
105105

106-
#[cfg(not(any(target_os = "windows", target_vendor = "apple",)))]
106+
#[cfg(not(any(target_os = "windows", target_vendor = "apple")))]
107107
#[macro_use]
108108
extern crate log;
109109
#[cfg(target_vendor = "apple")]
@@ -112,7 +112,7 @@ mod imp;
112112
#[cfg(target_os = "windows")]
113113
#[path = "imp/schannel.rs"]
114114
mod imp;
115-
#[cfg(not(any(target_vendor = "apple", target_os = "windows",)))]
115+
#[cfg(not(any(target_vendor = "apple", target_os = "windows")))]
116116
#[path = "imp/openssl.rs"]
117117
mod imp;
118118

0 commit comments

Comments
 (0)