-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
httpie refuses to trust a self-signed certificate #576
Comments
Trusting a self-signed certificate is never encouraged. It is dangerous if a program accepts it by default. A hacker can simply inject a self-signed one to make the users feeling secure while it is not the case. However, I would suggest |
@giskard22
Looking at #480 this is not the same root cause. HTTPie is, in this case, using the bundle you provide it. What I suspect is actually the cause is the following: Your "test domain" is not returning the full certificate chain but only its leaf (which works fine for browsers which can dynamically retrieve the rest of the chain) but not for httpie and other non-browser clients. In this case, you're providing part of the chain via
@alvis blanket advice is usually wrong and in this case it's quite alarmingly wrong. Self-signed certificates are a solution to a problem. I don't know @giskard22's use case for using a self-signed certificate here and neither do you. In that case your advice is not only most likely useless to @giskard22, it's also noise for the rest of the people receiving email notifications from issues on this repository. Self-signed certificates can be dangerous to trust without verification but in this case it seems @giskard22 knows the trust chain and trusts it making this usage perfectly safe. Yes, if you happen upon a site using HTTPS that you might need to enter sensitive information into, it is not advisable to use a self-signed certificate but this is a wildly different situation as I understand it. |
Yes, the use case here is using httpie through a corporate web proxy that does HTTPS man-in-the-middle so it can inspect traffic. It generates a domain-specific certificate on the fly. Blah. I don't understand how the proxy's failure to provide a full certificate chain causes this issue. Perhaps OpenSSL's behavior (or is it Python's behavior?) is different than MacOS's built-in mechanism. The trust chain for connections through the proxy looks like this:
I have been unable to obtain certificate 3. However, certificate 2 is available from the proxy. I imported into my Keychain and marked it trusted for SSL use. That was enough to satisfy everything on my Mac except httpie, including other command-line tools like curl. The observed behavior is the validation mechanism follows the chain until it finds a trusted certificate, then stops. The root certificate's absence is irrelevant. In the httpie debug output I posted in my initial report, I had stored certificate 2 in |
So OpenSSL will look in the bundle you provide it for whatever it's missing. If it cannot find it there it fails the verification. This is transitively also Python's behaviour. SecureTransport (MacOS's built-in mechanism) works slightly differently but only if the certificates are in MacOS's Keychain. Also, on MacOS the default Python has a hacked-up (for lack of a better term) version of OpenSSL that uses Keychain and thus can resolve these even if you provide it your own certificate bundle (i.e., if you tell it only to trust what's in a bundle file, it'll say "LOL, but I got Keychain access and that trusts it so YOLO" ... or YOVO? (You Only Verify Once... Idk)). If the entire trust chain for these on-the-fly certificates is what you described, I think you should be able to get away with having a bundle that only includes links 2 and 3 in the chain. Also, if you installed |
I was finally able to identify and obtain the self-signed root certificate. Upon putting both that cert and the intermediate cert in a .pem file and using that file with Any thoughts on the following additional complication? The proxy lets traffic go to certain domains without inserting its custom certificate. It looks like you cannot use multiple I have a workaround that involves concatenating OpenSSL's provided root CA bundle and the custom bundle upon demand, but hoping to avoid that. |
So OpenSSL supports providing a directory full of |
ol' Postman to the rescue. You can turn off detection of self signed cert. |
SSL is good, probably devs know that. Disabling SSL because of corner cases and language limitations or whatever stinks. I know people just want to get work done. I just wonder when we'll say SSL is good and have the same gut reaction at saying "disable SSL verification". If you disable SSL verification, SSL is off. But SSL is good. We all know that right? Is it confusing or common knowledge that SSL verification is really what the whole SSL thing is? If postman has an option to disable SSL verification is that just a fancy way of saying something that is potentially insecure? curl has that same option as a flag called I hope https dev machines, self signed certs and corporate CAs are supplanted by scriptable automatic letsencrypt certs one day. It's a shame that python makes http less organic at trusting the system keychain / ssl store. It's a curl replacement except in this area. I guess golang has operating system detection for all this stuff. So a modern curl replacement (like bat) that's written in go would have pretty output, a nice CLI experience and handle custom CAs or ssl termination (load balancers). |
Nope, not good. Need to be able to curl even if adhoc developer certificate. |
I think we all know that we should not be using self signed SSL certs, but sometimes, in a dev environment, you just want to get on with it. |
I believe it's an anti-pattern to train users to turn off certificate verification for self-signed certs. httpie is used widely in my current (very large) org, we have a internal trusted CA cert that isn't public and isn't used for public internet trusts. httpie - unlike curl (when compiled with SecureTransport) - can't use this internal CA trust (in the keychain for our MacOS developer systems), which is a great shame and only enforces user/developer behaviour to turn off verification, when there is absolutely a good reason not to. |
Hi, What is exposed in the discussion is weird: most of the intervenants seem to think that a self-signed certificate is a "bad thing". |
Most people use httpie for development purposes. Most developers use self-signed certificates in development. This issue has been open for nearly 8 years. Why?
does not work.
or
I don't know, I wonder if some of these package authors enjoy enforcing their opinions on users? This violates universal design principles far more than the security drawbacks alleged. Do they really believe bypassing verification for all requests is safer than using a self-signed certificate? Do they even use this package themselves for development? |
I don't entirely understand the discussion for issue #480 but I think the root cause may be the same for this issue. I need httpie to trust a self-signed certificate. Technically it is a self-signed intermediate certificate authority, but I can use one of the actual server certificates from that authority and get the same result. This certificate satisfies every other application on my Mac (OS 10.12), including curl. Httpie simply won't trust it. Sample output:
If I use
--verify=no
, the connection is accepted. I've tried converting the certificate file to DER format instead of PEM with no change.Httpie was installed via Homebrew, which installed its own Python3 as a dependency.
The text was updated successfully, but these errors were encountered: