http-rs / http-rs/surf

support skipping cert validation for self-signed certificates

Open
#115 1 comment 4 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
1.5k
Forks
128
PR merge metrics
No merged PRs in 30d

Description

# 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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.