diff --git a/Cargo.toml b/Cargo.toml index 1dda47c5a..a41051152 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,9 +22,9 @@ socket2 = "0.6.0" openssl-sys = { workspace = true, optional = true } openssl-probe = { version = "0.1.2", optional = true } -[target.'cfg(target_env = "msvc")'.dependencies] -schannel = "0.1.13" -windows-sys = { workspace = true, features = ["Win32_Foundation", "Win32_System_LibraryLoader", "Win32_Security_Cryptography"] } +[target.'cfg(windows)'.dependencies] +schannel = { version = "0.1.13", optional = true } +windows-sys = { workspace = true, optional = true, features = ["Win32_Foundation", "Win32_System_LibraryLoader", "Win32_Security_Cryptography"] } [dev-dependencies] mio = "0.6" @@ -48,7 +48,15 @@ spnego = ["curl-sys/spnego"] rustls = ["curl-sys/rustls"] static-curl = ["curl-sys/static-curl"] static-ssl = ["curl-sys/static-ssl"] -windows-static-ssl = ["static-curl", "curl-sys/windows-static-ssl"] +windows-cert-store = [ + "dep:schannel", + "dep:windows-sys", +] +windows-static-ssl = [ + "static-curl", + "curl-sys/windows-static-ssl", + "windows-cert-store", +] force-system-lib-on-osx = ['curl-sys/force-system-lib-on-osx'] protocol-ftp = ["curl-sys/protocol-ftp"] zlib-ng-compat = ["curl-sys/zlib-ng-compat", "static-curl"] diff --git a/src/easy/windows.rs b/src/easy/windows.rs index b56d44651..f8ab5ad27 100644 --- a/src/easy/windows.rs +++ b/src/easy/windows.rs @@ -2,7 +2,7 @@ use libc::c_void; -#[cfg(target_env = "msvc")] +#[cfg(all(windows, feature = "windows-cert-store"))] mod win { use schannel::cert_context::ValidUses; use schannel::cert_store::CertStore; @@ -116,12 +116,12 @@ mod win { } } -#[cfg(target_env = "msvc")] +#[cfg(all(windows, feature = "windows-cert-store"))] pub fn add_certs_to_context(ssl_ctx: *mut c_void) { unsafe { win::add_certs_to_context(ssl_ctx as *mut _); } } -#[cfg(not(target_env = "msvc"))] +#[cfg(not(all(windows, feature = "windows-cert-store")))] pub fn add_certs_to_context(_: *mut c_void) {}