Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for --proxy-cacert or --proxy-insecure #160

Closed
lunatik13 opened this issue Apr 30, 2017 · 4 comments · Fixed by #344
Closed

Add support for --proxy-cacert or --proxy-insecure #160

lunatik13 opened this issue Apr 30, 2017 · 4 comments · Fixed by #344

Comments

@lunatik13
Copy link

Currently it's impossible to use this unix curl example:
curl -x https://squid.domain.com:443 --proxy-user user:pass https://ifconfig.co --proxy-cacert bundle.crt
Or maybe i can use sщme available functions ?

@lunatik13
Copy link
Author

squid.conf

https_port $SQUID_EXT_IP:443 cert=/path/to/wild.domain.crt  key=/path/to/wild.domain.key
extern crate curl;

use std::io::{stdout, Write};

use curl::easy::Easy;

fn main() {
    let mut easy = Easy::new();
    easy.proxy("https://squid.domain.com").unwrap();
    easy.proxy_port(443).unwrap();
    easy.proxy_username("user").unwrap();
    easy.proxy_password("pass").unwrap();
    easy.url("https://httpbin.org/ip").unwrap();
    easy.write_function(|data| {
        Ok(stdout().write(data).unwrap())
    }).unwrap();
    easy.perform().unwrap();

    println!("{}", easy.response_code().unwrap());
}

Error

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error { description: "Peer certificate cannot be authenticated with given CA certificates", code: 60, extra: Some("SSL certificate problem: unable to get local issuer certificate") }', src/libcore/result.rs:868

@alexcrichton
Copy link
Owner

I'd definitely love to have support for these! This would probably just involve binding a constant or two and then adding the appropriate functions to access it.

Would you be interested in sending a PR for this functionality? I could certainly help out if needed!

@lunatik13
Copy link
Author

lunatik13 commented Jun 10, 2017

I am try to add some changes to curl-rust.
Example usage:

extern crate curl;

use std::io::{stdout, Write};

use curl::easy::Easy;

fn main() {
    let mut easy = Easy::new();
    let proxy_user = "user".to_string();
    let proxy_pass = "pass".to_string();

    easy.proxy("https://bla.com").unwrap();
    easy.proxy_port(443).unwrap();
    easy.proxy_username(&proxy_user).unwrap();
    easy.proxy_password(&proxy_pass).unwrap();
    easy.proxy_capath("/path/to/dit/with/cert").unwrap();
    easy.url("https://httpbin.org/ip").unwrap();
    easy.write_function(|data| {
        Ok(stdout().write(data).unwrap())
    }).unwrap();
    easy.perform().unwrap();

    println!("{}", easy.response_code().unwrap());
}

example.toml

[package]
name = "parser-config"
version = "0.1.0"
authors = ["user"]

# [dependencies]
# curl = "*"
[dependencies.curl]
path = "/local/curl-rust"

Error:
thread 'main' panicked at 'called Result::unwrap()on anErr value: Error { description: "An unknown option was passed in to libcurl", code: 48, extra: None }', /checkout/src/libcore/result.rs:859
Changes commit

@alexcrichton
Copy link
Owner

You may want to try running cargo run inside of the systest folder which will validate the value of CURLOPT_PROXY_CAPATH, and failing that perhaps you're linking against a version of libcurl itself that doesn't have the option?

sagebind added a commit that referenced this issue Jun 30, 2020
This completes the bindings for proxy SSL options and fixes #160.
alexcrichton pushed a commit that referenced this issue Jun 30, 2020
* Add proxy_cacert support

This completes the bindings for proxy SSL options and fixes #160.

* Formatting

* Add CURLOPT_PROXY_CAPATH debut version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants