support skipping cert validation for self-signed certificates
Problem
If I run a web server with a self signed certificate, I can ignore self-signed certificate validation with --insecure/-k option of curl command e.g. curl -k https://localhost:3031.
Surf will return an error if I try to do this equivalent operation:
// async-std = { version = "1.1.0", features = ["attributes"] }
// surf = "1.0.3"
use surf;
#[async_std::main]
async fn main() {
let url = "https://localhost:3031";
let result = surf::get(url).await;
println!("{:?}", result);
}
Error message printed:
Err(SSLConnectFailed(None))
Reproduce
I can create a self signed key and certificate with openssl:
openssl req -nodes -new -x509 -keyout server.key -out server.cert
I can then run a super basic web server (I made one with warp):
// tokio = " 0.2.0-alpha.6"
// warp = { git = "https://github.com/seanmonstar/warp.git", branch = "master", features = ["tls"] }
#[tokio::main]
async fn main() {
use warp::Filter;
// Match any request and return hello world!
let routes = warp::get().map(|| "Hello, World!");
warp::serve(routes)
.tls("server.cert", "server.key")
.run(([127, 0, 0, 1], 3031)).await;
}
Run the surf program above to test the server.
I guess the solution for this would be to allow passing your own client, in which curl-specific options can be set. https://github.com/http-rs/surf/issues/69 and https://github.com/http-rs/surf/pull/66 would be the tracking issues for that.