Skip to content

Commit 1ddd4e8

Browse files
authored
Add proxy_cacert support (#344)
* Add proxy_cacert support This completes the bindings for proxy SSL options and fixes #160. * Formatting * Add CURLOPT_PROXY_CAPATH debut version
1 parent 7087375 commit 1ddd4e8

File tree

4 files changed

+34
-6
lines changed

4 files changed

+34
-6
lines changed

curl-sys/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,7 @@ pub const CURLOPT_SSL_OPTIONS: CURLoption = CURLOPTTYPE_LONG + 216;
577577
pub const CURLOPT_UNIX_SOCKET_PATH: CURLoption = CURLOPTTYPE_OBJECTPOINT + 231;
578578
pub const CURLOPT_PIPEWAIT: CURLoption = CURLOPTTYPE_LONG + 237;
579579
pub const CURLOPT_PROXY_CAINFO: CURLoption = CURLOPTTYPE_OBJECTPOINT + 246;
580+
pub const CURLOPT_PROXY_CAPATH: CURLoption = CURLOPTTYPE_OBJECTPOINT + 247;
580581
pub const CURLOPT_PROXY_SSLCERT: CURLoption = CURLOPTTYPE_OBJECTPOINT + 254;
581582
pub const CURLOPT_PROXY_SSLKEY: CURLoption = CURLOPTTYPE_OBJECTPOINT + 256;
582583

src/easy/handle.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,11 @@ impl Easy {
568568
self.inner.proxy_cainfo(cainfo)
569569
}
570570

571+
/// Same as [`Easy2::proxy_capath`](struct.Easy2.html#method.proxy_capath)
572+
pub fn proxy_capath<P: AsRef<Path>>(&mut self, path: P) -> Result<(), Error> {
573+
self.inner.proxy_capath(path)
574+
}
575+
571576
/// Same as [`Easy2::proxy_sslcert`](struct.Easy2.html#method.proxy_sslcert)
572577
pub fn proxy_sslcert(&mut self, sslcert: &str) -> Result<(), Error> {
573578
self.inner.proxy_sslcert(sslcert)

src/easy/handler.rs

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -881,25 +881,41 @@ impl<H> Easy2<H> {
881881
self.setopt_long(curl_sys::CURLOPT_PROXYPORT, port as c_long)
882882
}
883883

884-
/// Set CA certificate to verify peer against for proxy
884+
/// Set CA certificate to verify peer against for proxy.
885885
///
886-
/// By default this value is not set and corresponds to `CURLOPT_PROXY_CAINFO`.
886+
/// By default this value is not set and corresponds to
887+
/// `CURLOPT_PROXY_CAINFO`.
887888
pub fn proxy_cainfo(&mut self, cainfo: &str) -> Result<(), Error> {
888889
let cainfo = CString::new(cainfo)?;
889890
self.setopt_str(curl_sys::CURLOPT_PROXY_CAINFO, &cainfo)
890891
}
891892

892-
/// Set client certificate for proxy
893+
/// Specify a directory holding CA certificates for proxy.
894+
///
895+
/// The specified directory should hold multiple CA certificates to verify
896+
/// the HTTPS proxy with. If libcurl is built against OpenSSL, the
897+
/// certificate directory must be prepared using the OpenSSL `c_rehash`
898+
/// utility.
899+
///
900+
/// By default this value is not set and corresponds to
901+
/// `CURLOPT_PROXY_CAPATH`.
902+
pub fn proxy_capath<P: AsRef<Path>>(&mut self, path: P) -> Result<(), Error> {
903+
self.setopt_path(curl_sys::CURLOPT_PROXY_CAPATH, path.as_ref())
904+
}
905+
906+
/// Set client certificate for proxy.
893907
///
894-
/// By default this value is not set and corresponds to `CURLOPT_PROXY_SSLCERT`.
908+
/// By default this value is not set and corresponds to
909+
/// `CURLOPT_PROXY_SSLCERT`.
895910
pub fn proxy_sslcert(&mut self, sslcert: &str) -> Result<(), Error> {
896911
let sslcert = CString::new(sslcert)?;
897912
self.setopt_str(curl_sys::CURLOPT_PROXY_SSLCERT, &sslcert)
898913
}
899914

900-
/// Set private key for HTTPS proxy
915+
/// Set private key for HTTPS proxy.
901916
///
902-
/// By default this value is not set and corresponds to `CURLOPT_PROXY_SSLKEY`.
917+
/// By default this value is not set and corresponds to
918+
/// `CURLOPT_PROXY_SSLKEY`.
903919
pub fn proxy_sslkey(&mut self, sslkey: &str) -> Result<(), Error> {
904920
let sslkey = CString::new(sslkey)?;
905921
self.setopt_str(curl_sys::CURLOPT_PROXY_SSLKEY, &sslkey)

systest/build.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,12 @@ fn main() {
116116
_ => {}
117117
}
118118
}
119+
if version < 52 {
120+
match s {
121+
"CURLOPT_PROXY_CAPATH" => return true,
122+
_ => {}
123+
}
124+
}
119125

120126
if version < 49 {
121127
if s.starts_with("CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE") {

0 commit comments

Comments
 (0)