Skip to content

Commit 6ba3cf1

Browse files
authored
Merge pull request #295 from simlay/make-tempfile-be-a-macos-specific-dependency
Make tempfile be a macos-only dependency
2 parents 0b69ce6 + 3018442 commit 6ba3cf1

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ alpn = ["security-framework/alpn"]
2020
security-framework = "2.0.0"
2121
security-framework-sys = "2.0.0"
2222
libc = "0.2"
23+
24+
[target.'cfg(target_os = "macos")'.dependencies]
2325
tempfile = "3.1.0"
2426

2527
[target.'cfg(target_os = "windows")'.dependencies]

src/imp/security_framework.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
extern crate libc;
22
extern crate security_framework;
33
extern crate security_framework_sys;
4-
extern crate tempfile;
54

65
use self::security_framework::base;
76
use self::security_framework::certificate::SecCertificate;
@@ -12,7 +11,6 @@ use self::security_framework::secure_transport::{
1211
self, ClientBuilder, SslConnectionType, SslContext, SslProtocol, SslProtocolSide,
1312
};
1413
use self::security_framework_sys::base::{errSecIO, errSecParam};
15-
use self::tempfile::TempDir;
1614
use std::error;
1715
use std::fmt;
1816
use std::io;
@@ -38,7 +36,7 @@ use {Protocol, TlsAcceptorBuilder, TlsConnectorBuilder};
3836
static SET_AT_EXIT: Once = Once::new();
3937

4038
#[cfg(not(any(target_os = "ios", target_os = "watchos", target_os = "tvos")))]
41-
static TEMP_KEYCHAIN: Mutex<Option<(SecKeychain, TempDir)>> = Mutex::new(None);
39+
static TEMP_KEYCHAIN: Mutex<Option<(SecKeychain, tempfile::TempDir)>> = Mutex::new(None);
4240

4341
fn convert_protocol(protocol: Protocol) -> SslProtocol {
4442
match protocol {
@@ -93,7 +91,7 @@ impl Identity {
9391
return Err(Error(base::Error::from(errSecParam)));
9492
}
9593

96-
let dir = TempDir::new().map_err(|_| Error(base::Error::from(errSecIO)))?;
94+
let dir = tempfile::TempDir::new().map_err(|_| Error(base::Error::from(errSecIO)))?;
9795
let keychain = keychain::CreateOptions::new()
9896
.password(&random_password()?)
9997
.create(dir.path().join("identity.keychain"))?;
@@ -159,7 +157,8 @@ impl Identity {
159157
let keychain = match *TEMP_KEYCHAIN.lock().unwrap() {
160158
Some((ref keychain, _)) => keychain.clone(),
161159
ref mut lock @ None => {
162-
let dir = TempDir::new().map_err(|_| Error(base::Error::from(errSecIO)))?;
160+
let dir =
161+
tempfile::TempDir::new().map_err(|_| Error(base::Error::from(errSecIO)))?;
163162

164163
let mut keychain = keychain::CreateOptions::new()
165164
.password(pass)

0 commit comments

Comments
 (0)