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

CPR on NDK has problems with HTTPS #884

Open
RexiRexii opened this issue Feb 26, 2023 · 5 comments
Open

CPR on NDK has problems with HTTPS #884

RexiRexii opened this issue Feb 26, 2023 · 5 comments

Comments

@RexiRexii
Copy link

Description

I was using CPR on Visual Studio for my Android project, I did implement cURL with OpenSSL, and raw cURL worked perfectly fine with both http and https url's, however, when I tried the same with CPR, only http type url's worked, https for some reason doesn't work.

Example/How to Reproduce

  1. Create a cpr::Session
  2. Make a simple request through any URL that forces SSL
  3. Perform the request
  4. Response code will simply return 0, even though your cURL has OpenSSL

Possible Fix

I do not know the fix to this, which is why I made this bug report.

Where did you get it from?

GitHub (branch e.g. master)

Additional Context/Your Environment

  • OS: Android Marshmellow 6.0
  • Version: Clang 5.0 LLVM libc++ static library
@RexiRexii
Copy link
Author

I found a fix:
If you put

curl_easy_setopt(handle, CURLOPT_USE_SSL, CURLUSESSL_ALL); curl_easy_setopt(handle, CURLOPT_SSL_VERIFYPEER, 0L);

on every Request method in session (e.g Session::PreparePut(), Session::PreparePost() ) it will force SSL which will solve the problem for Android CPR users.

@COM8
Copy link
Member

COM8 commented Mar 4, 2023

@RexiRexii This is no fix. I have to warn you about using this since it basically disables all the authentication/trust (well mostly all) built up by HTTPS.

This error to me sounds like a root ca path issue.

What version of curl were you using?
I suggest trying the following:
Try setting the CURL_CA_FALLBACK CMake variable to ON

  1. Either directly in CMake via something like this: https://github.com/COM8/home-ui/blob/main/CMakeLists.txt#L113

  2. Or as a CMake argument, when configuring: cmake .. -DCURL_CA_FALLBACK=ON

@RexiRexii
Copy link
Author

I do not use CMake.
I am using curl-7.78

And many people other than me are facing the same issue, if i make a request using raw curl (a.k.a not using cpr) it works fine, but if i use cpr it does not.

@COM8
Copy link
Member

COM8 commented Mar 4, 2023

Since you are not using CMake, there should not be any difference in how raw curl and cpr use https. As far as I'm aware, we do not set any specific options related to CA path and so on when preparing a request.

Could you please provide a minimal example application, so I can have a look at it?

@COM8
Copy link
Member

COM8 commented Mar 4, 2023

Related to: #333

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants