-
Notifications
You must be signed in to change notification settings - Fork 1.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
https: certificate pinning #314
Comments
To make it clearer: I want to inject a method that checks the certificate during SSL handshake. If the method returns true the certificate is accepted. |
Here is an example how easy that works in .net: https://www.owasp.org/index.php/Certificate_and_Public_Key_Pinning#.Net I think a good solution would be an analog callback in the http_client_config class. It would be called in asio_connection:async_handshake. |
Have a look, it's been implemented in this fork: https://github.com/glukacsy/cpprestsdk |
Thank you for that information. Good to see that there is progress on that topic. Although the discussion on #135 seems to have been stopped some time ago. |
I'm looking forward for a solution for certificate pinning as well, for linux & OSX though. |
My workaround is the following (under Windows, but probably you can adapt for other OS):
|
Not so nice about this solution: The content is downloaded before the certificate is checked. I consider a certificate error as just that and so for me that is ok. |
Hi @marnef, I tried to implement this for linux, yet in my case the appropriate object is SSL (instead of HINTERNET), and it is never filled with the certificate data, not in the progress_handler, and not afterwards when I parse the actual response. |
Anyway as suggested above, in order to achieve pinning here is what I did: In the file https://github.com/Microsoft/cpprestsdk/blob/master/Release/src/http/client/http_client_asio.cpp override the method bool handle_cert_verification(bool preverified, boost::asio::ssl::verify_context &verifyCtx) The correct fix is to call the predefined set_verify_callback, which should be done in http_client_asio instead of calling a predefined validation function. |
Hi @marnef , |
Hi @Tom883, see my comment from June 15. It works fine, but is not really nice because it's OS dependent. |
Hi, The design changed along with our requirements for accepting the certificate chain. Using this approach we leave the validation of the certificate chain up to the consumer of casablanca. |
@chogorma, can you prepare pull requests? This seams like a really useful option. |
@matra774, yes i can do that, will get the PR open as soon as i can. |
Opened a PR for the approach we have taken: #702 |
Hi all,
I'm trying to implement certificate pinning. This means that the server is sending the untrusted certificate [which is why I need to call http_client_config::set_validate_certificates(false) -> unsafe] and I have to compare its public key or a hash value of it with a value known at compile time. That's all under Windows, which means there is no set_ssl_context_callback.
Does anyone have an idea how I can install a callback that allows my check of the hash or any other idea? Or how can I access the certificate at all?
The text was updated successfully, but these errors were encountered: