Skip to content

Commit a4958d1

Browse files
authored
Add missing SSL Options (#467)
* Add missing SSL Options * Add constants to systest
1 parent 0162fe1 commit a4958d1

File tree

3 files changed

+65
-7
lines changed

3 files changed

+65
-7
lines changed

curl-sys/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,10 @@ pub const CURL_IPRESOLVE_V6: c_int = 2;
637637

638638
pub const CURLSSLOPT_ALLOW_BEAST: c_long = 1 << 0;
639639
pub const CURLSSLOPT_NO_REVOKE: c_long = 1 << 1;
640+
pub const CURLSSLOPT_NO_PARTIALCHAIN: c_long = 1 << 2;
641+
pub const CURLSSLOPT_REVOKE_BEST_EFFORT: c_long = 1 << 3;
642+
pub const CURLSSLOPT_NATIVE_CA: c_long = 1 << 4;
643+
pub const CURLSSLOPT_AUTO_CLIENT_CERT: c_long = 1 << 5;
640644

641645
/// These enums are for use with the CURLOPT_HTTP_VERSION option.
642646
///

src/easy/handler.rs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3813,6 +3813,46 @@ impl SslOpt {
38133813
SslOpt { bits: 0 }
38143814
}
38153815

3816+
/// Tell libcurl to automatically locate and use a client certificate for authentication,
3817+
/// when requested by the server.
3818+
///
3819+
/// This option is only supported for Schannel (the native Windows SSL library).
3820+
/// Prior to 7.77.0 this was the default behavior in libcurl with Schannel.
3821+
///
3822+
/// Since the server can request any certificate that supports client authentication in
3823+
/// the OS certificate store it could be a privacy violation and unexpected. (Added in 7.77.0)
3824+
pub fn auto_client_cert(&mut self, on: bool) -> &mut SslOpt {
3825+
self.flag(curl_sys::CURLSSLOPT_AUTO_CLIENT_CERT, on)
3826+
}
3827+
3828+
/// Tell libcurl to use the operating system's native CA store for certificate verification.
3829+
///
3830+
/// Works only on Windows when built to use OpenSSL.
3831+
///
3832+
/// This option is experimental and behavior is subject to change. (Added in 7.71.0)
3833+
pub fn native_ca(&mut self, on: bool) -> &mut SslOpt {
3834+
self.flag(curl_sys::CURLSSLOPT_NATIVE_CA, on)
3835+
}
3836+
3837+
/// Tells libcurl to ignore certificate revocation checks in case of missing or
3838+
/// offline distribution points for those SSL backends where such behavior is present.
3839+
///
3840+
/// This option is only supported for Schannel (the native Windows SSL library).
3841+
///
3842+
/// If combined with CURLSSLOPT_NO_REVOKE, the latter takes precedence. (Added in 7.70.0)
3843+
pub fn revoke_best_effort(&mut self, on: bool) -> &mut SslOpt {
3844+
self.flag(curl_sys::CURLSSLOPT_REVOKE_BEST_EFFORT, on)
3845+
}
3846+
3847+
/// Tells libcurl to not accept "partial" certificate chains, which it otherwise does by default.
3848+
///
3849+
/// This option is only supported for OpenSSL and will fail the certificate verification
3850+
/// if the chain ends with an intermediate certificate and not with a root cert.
3851+
/// (Added in 7.68.0)
3852+
pub fn no_partial_chain(&mut self, on: bool) -> &mut SslOpt {
3853+
self.flag(curl_sys::CURLSSLOPT_NO_PARTIALCHAIN, on)
3854+
}
3855+
38163856
/// Tells libcurl to disable certificate revocation checks for those SSL
38173857
/// backends where such behavior is present.
38183858
///

systest/build.rs

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ fn main() {
6262
false
6363
});
6464

65+
// Version symbols are extracted from https://curl.se/libcurl/c/symbols-in-versions.html
6566
cfg.skip_const(move |s| {
6667
if version < 77 {
6768
match s {
@@ -73,7 +74,8 @@ fn main() {
7374
| "CURL_VERSION_ZSTD"
7475
| "CURL_VERSION_UNICODE"
7576
| "CURL_VERSION_HSTS"
76-
| "CURL_VERSION_GSASL" => return true,
77+
| "CURL_VERSION_GSASL"
78+
| "CURLSSLOPT_AUTO_CLIENT_CERT" => return true,
7779
_ => {}
7880
}
7981
}
@@ -110,15 +112,23 @@ fn main() {
110112
| "CURLOPT_ISSUERCERT_BLOB"
111113
| "CURLOPTTYPE_BLOB"
112114
| "CURL_BLOB_NOCOPY"
113-
| "CURL_BLOB_COPY" => return true,
115+
| "CURL_BLOB_COPY"
116+
| "CURLSSLOPT_NATIVE_CA" => return true,
114117
_ => {}
115118
}
116119
}
117120
if version < 70 {
118121
match s {
119-
"CURL_VERSION_HTTP3" | "CURL_VERSION_BROTLI" | "CURLVERSION_SEVENTH" => {
120-
return true
121-
}
122+
"CURL_VERSION_HTTP3"
123+
| "CURL_VERSION_BROTLI"
124+
| "CURLVERSION_SEVENTH"
125+
| "CURLSSLOPT_REVOKE_BEST_EFFORT" => return true,
126+
_ => {}
127+
}
128+
}
129+
if version < 68 {
130+
match s {
131+
"CURLSSLOPT_NO_PARTIALCHAIN" => return true,
122132
_ => {}
123133
}
124134
}
@@ -202,18 +212,22 @@ fn main() {
202212
_ => {}
203213
}
204214
}
205-
206215
if version < 47 {
207216
if s.starts_with("CURL_HTTP_VERSION_2") {
208217
return true;
209218
}
210219
}
211-
212220
if version < 43 {
213221
if s.starts_with("CURLPIPE_") {
214222
return true;
215223
}
216224
}
225+
if version < 25 {
226+
match s {
227+
"CURLSSLOPT_ALLOW_BEAST" => return true,
228+
_ => {}
229+
}
230+
}
217231

218232
// OSX doesn't have this yet
219233
s == "CURLSSLOPT_NO_REVOKE" ||

0 commit comments

Comments
 (0)