Skip to content

Commit

Permalink
Merge pull request #316 from sfackler/verify-locations
Browse files Browse the repository at this point in the history
Stop using deprecated openssl-probe APIs
  • Loading branch information
sfackler authored Jan 25, 2025
2 parents a0e6f18 + 4a88faf commit 55aff8e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ schannel = "0.1.17"

[target.'cfg(not(any(target_os = "windows", target_vendor = "apple")))'.dependencies]
log = "0.4.5"
openssl = "0.10.46"
openssl = "0.10.69"
openssl-sys = "0.9.81"
openssl-probe = "0.1"

Expand Down
12 changes: 4 additions & 8 deletions src/imp/openssl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use self::openssl::x509::{store::X509StoreBuilder, X509VerifyResult, X509};
use std::error;
use std::fmt;
use std::io;
use std::sync::Once;

use {Protocol, TlsAcceptorBuilder, TlsConnectorBuilder};

Expand Down Expand Up @@ -85,11 +84,6 @@ fn supported_protocols(
Ok(())
}

fn init_trust() {
static ONCE: Once = Once::new();
ONCE.call_once(openssl_probe::init_ssl_cert_env_vars);
}

#[cfg(target_os = "android")]
fn load_android_root_certs(connector: &mut SslContextBuilder) -> Result<(), Error> {
use std::fs;
Expand Down Expand Up @@ -272,9 +266,11 @@ pub struct TlsConnector {

impl TlsConnector {
pub fn new(builder: &TlsConnectorBuilder) -> Result<TlsConnector, Error> {
init_trust();

let mut connector = SslConnector::builder(SslMethod::tls())?;

let probe = openssl_probe::probe();
connector.load_verify_locations(probe.cert_file.as_deref(), probe.cert_dir.as_deref())?;

if let Some(ref identity) = builder.identity {
connector.set_certificate(&identity.0.cert)?;
connector.set_private_key(&identity.0.pkey)?;
Expand Down
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,16 @@ use std::fmt;
use std::io;
use std::result;

#[cfg(not(any(target_os = "windows", target_vendor = "apple",)))]
#[cfg(not(any(target_os = "windows", target_vendor = "apple")))]
#[macro_use]
extern crate log;
#[cfg(any(target_vendor = "apple",))]
#[cfg(target_vendor = "apple")]
#[path = "imp/security_framework.rs"]
mod imp;
#[cfg(target_os = "windows")]
#[path = "imp/schannel.rs"]
mod imp;
#[cfg(not(any(target_vendor = "apple", target_os = "windows",)))]
#[cfg(not(any(target_vendor = "apple", target_os = "windows")))]
#[path = "imp/openssl.rs"]
mod imp;

Expand Down

0 comments on commit 55aff8e

Please sign in to comment.