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

HTTPS url throws error #58

Closed
mempirate opened this issue Mar 23, 2023 · 8 comments
Closed

HTTPS url throws error #58

mempirate opened this issue Mar 23, 2023 · 8 comments
Labels
bug Something isn't working

Comments

@mempirate
Copy link

I've looked into the PRs and https urls should work, but I'm still getting an error. Double checked that the tls feature is enabled:

Network(hyper::Error(Connect, "invalid URL, scheme is not http"))

This happens when executing a query:

let result = client.query("SELECT 1").fetch_one::<usize>().await.unwrap();

Am I doing something wrong or is this a bug?

@makorne
Copy link

makorne commented Apr 12, 2023

I have the same error.
Looks like there need test with https.

@eabz
Copy link

eabz commented Apr 13, 2023

I was facing the same issue and solved it using my own hyper server.

const POOL_IDLE_TIMEOUT: Duration = Duration::from_secs(2);

let https = HttpsConnector::new();

let client = hyper::Client::builder()
       .pool_idle_timeout(POOL_IDLE_TIMEOUT)
       .build::<_, hyper::Body>(https);

let db = Client::with_http_client(client)
       .with_url(db_host)
       .with_user(db_username)
       .with_password(db_password)
       .with_database(db_name);

Make sure you have the following depends:

hyper = "0.14" 
hyper-tls = "0.5"

@loyd loyd added the bug Something isn't working label Apr 13, 2023
@mempirate
Copy link
Author

@eabz used the same workaround for now, ty

@ta3pks
Copy link

ta3pks commented Jul 26, 2023

I saw a pr merged like 2 years ago fixing this issue was it reverted for some reason ?

@LetMut1
Copy link

LetMut1 commented Aug 18, 2023

@eabz thanks a lot.

@MasterPtato
Copy link

The issue seems to stem from the fact that HttpConnector.enforce_http is not set to false when the tls flag is enabled. I believe this is why @eabz 's workaround works (relevant source code in HttpsConnector::new)

@loyd
Copy link
Collaborator

loyd commented Sep 27, 2023

It's a shame that this issue has existed for too long. It's better to have some fixes, even without checks in CI. I've created a dedicated issue for CI after spending half an hour trying to do it during this one.

Thanks to @MasterPtato for the direct tip. It seems to fix the problem.

My company doesn't use CH with HTTPs for now, so I'll be glad if someone can check this fix in an actual setup.

Another question is whether TLS error should have another variant in enum Error because it's an unrecoverable error.

loyd added a commit that referenced this issue Sep 27, 2023
@loyd
Copy link
Collaborator

loyd commented Sep 27, 2023

Released in v0.11.6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants