-
Notifications
You must be signed in to change notification settings - Fork 958
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
SSL certificate problem #445
Comments
Hi, thanks for reporting this. |
EDIT: This issue was fixed after deleting all CMake related folders and files and generating them again. Now it is working. Same issue for me. I am completely new to C++ so sorry if I may not be that competent! Code: #include <iostream>
#include <cpr/cpr.h>
int main(int argc, char **argv)
{
auto res = cpr::Get(cpr::Url{"https://www.google.com"});
std::cout << res.error.message << '\n';
return 0;
} Console Output: CMakeLists.txt (I have no clue whether this is relevant so I am just going to include it! I just followed the readme in this repo) cmake_minimum_required(VERSION 3.10)
project("stuff")
add_executable(app main.cpp)
include(FetchContent)
FetchContent_Declare(cpr GIT_REPOSITORY https://github.com/whoshuu/cpr.git GIT_TAG c8d33915dbd88ad6c92b258869b03aba06587ff9) # the commit hash for 1.5.0
FetchContent_MakeAvailable(cpr)
target_link_libraries(app PRIVATE cpr::cpr) |
@VenNeptury thanks! What happens if you run: $ ls -l /etc/ssl/certs/
|
It prints a lot of
|
I find a way to solve it. |
@VenNeptury, ok.
Does this one exist? This is where libcurl expects the @xiao-huangren, thanks for your suggestion. But be aware, that with this you disable and more or less invalidate all the TLS authenticity. |
There is no such file, that file is at |
Yes, you could try creating a symlink.
This is where |
That command prints the proper location It is always fixed temporarily by deleting CMakeCache.txt and rebuilding everything for some reason |
I started using cpr yesterday for the first time so this could be my error but I have been unable to access https sites and found this issue, which seems related to my problem. So far every https site I try to access, I get a status code of 0, which I believe is a cancelled request. I can access those sites no problem with curl and I can get to those sites if I set |
@VenNeptury, interesting discovery. What distro are you using? I might have to add additional CI runners for more distros to prevent those issues. |
Exactly the same as described by slzatz, Arch Linux |
Aha, ok. I'd say the problem here is, libcurl is not finding the ca bundle during compilation, because there a re only a few predefined directories for it. Since we are using libcurl with CMAKE and not their own build system, this could be interesting. |
Had the same error. Solved the issue on fedora 32 replacing: include(FetchContent)
FetchContent_Declare(cpr
GIT_REPOSITORY https://github.com/whoshuu/cpr.git
GIT_TAG v1.5.1
GIT_SHALLOW TRUE
)
FetchContent_MakeAvailable(cpr) by include(FetchContent)
FetchContent_Declare(cpr
GIT_REPOSITORY https://github.com/whoshuu/cpr.git
GIT_TAG v1.5.1
GIT_SHALLOW TRUE
)
FetchContent_GetProperties(cpr)
if(NOT cpr_POPULATED)
FetchContent_Populate(cpr)
set(USE_SYSTEM_CURL ON CACHE BOOL "" FORCE)
add_subdirectory(${cpr_SOURCE_DIR} ${cpr_BINARY_DIR})
endif() |
@phasmide, the same behaviour can be archived by setting With this you are requiring curl (libcurl) to be installed on your targets PC and this solution is less portable, since we depend on a well configured curl (libcurl) instance on the targets PC. I (we) will have to figure out how to set the ca-bundle path during configuration of curl using CMAKE (ping @KingKili ). |
Way simpler indeed.
I understand that: my wording was ill-chosen:
;)
Can't this be always set to Thank you for your response. |
Yes, but I currently do not know how :D |
Is there any news on this? It's a pretty critical problem. |
Currently not. I'm currently trying to understand how the curl CMake project works so I can fix this. |
A workaround for all of those with this issue (arch users?):
Example: # Configure
$ cmake .. -DCURL_CA_BUNDLE="/home/user_name/Downloads/cacert.pem"
# Build
$ cmake --build . The reason for this issue is the auto |
Can anybody confirm that installing For me on Manjaro, this fixed it. Arch: $ pacman -S ca-certificates Once installed you have to perform a clean rebuild to force curl to search again for certificates. $ cd cpr/build
$ rm -rf *
$ cmake ..
$ cmake --build . |
On plain vanilla arch. Since I had previously installed cpr through cmake FetchContent I deleted all the cpr and curl directories in |
Ok. Thanks for testing. I guess I cant get around setting up a pure Arch VM :) |
In my pure Arch installing ca-certificates fixes the issue. |
I've also fallen victim to this issue on an Ubuntu 20.04.2 system. I have tried:
I am temporarily settling on disabling verification. Will try to debug it some more. Note: I don't have this issue on Manjaro |
I had the same problem, then I installed the latest commit (04f06b8) and it worked :) |
I have had this issue on Ubuntu 20.04 running in WSL. Building if(WIN32)
set(WINSSL ON)
set(OPENSSL OFF)
else()
set(WINSSL OFF)
set(OPENSSL ON)
endif() Then refreshing my certs:
fixed it. |
With
if(WIN32)
set(CPR_FORCE_WINSSL_BACKEND ON)
else()
set(CPR_FORCE_OPENSSL_BACKEND ON)
endif() |
I'm still having this issue on MSYS2. |
@AquaVirus could you please give me a little bit more context.
|
My bad, it's working on MSYS2. The issue was that I was using outdated DLLs. |
it's worked .. is that secure ? |
Like always, it depends. If you just disable it to fix the missing cert file. NO! |
it's not working .. Let me show you what i do :- my project home tree like this how i include cpr :-
Go to cpr and build with cacert file
Go to my project and rebuild : -
|
Any reason you are not using |
Same here on Arch this fixed it for me, but not really an ideal fix, but werks so who cares ¯_(ツ)_/¯ |
Hello, I had same problem with ubuntu 21.04. solution: |
the same error on android: |
I ran into this issue on Arch as well. I already had |
I am using Fedora 35 with
|
I found out how to reproduce the issues and why this fails. How to reproduce?On the first configure it will always work. If you then configure again (without deleting the build folder) it will fail. If you delete the CMakeCache.txt and reconfigure it will work again. So the issue is clearly something which involves cache variables What is the issue?In https://github.com/libcpr/cpr/blob/master/CMakeLists.txt#L208 we always set In https://github.com/curl/curl/blob/90dd1fc66401d5bb7814f4edeb16a06c925b1f1e/CMakeLists.txt#L862 this will trigger autodetect as expected and then the correct path is detected and written into the same variable One line later though curl will set On the next configure CPR will set How to fix it?The easiest fix can be done in CPR here https://github.com/libcpr/cpr/blob/master/CMakeLists.txt#L208, just guard this
So once ca bundle is found, cpr will not set it again. Works like a charm Arguably this whole behavior could be seen as a flaw in curl. Mainly: Why do they use this variable for configuring auto mode instead of a separate variable. So my recommendation would be: Temporarily fix this in CPR and release a new version, because this a huge issue. But at the same way also get in contact with curl maintainers as this really should be fixed on their side. |
Nice catch @Leon0402 and I also can confirm this behaviour! Also I would suggest something like: if(NOT CURL_CA_BUNDLE_SET)
set(CURL_CA_BUNDLE "auto" CACHE INTERNAL"")
endif() Makes it a bit more reliable for your case. |
This allows people to set the bundle by hand if they want. |
SSL certificate problem: self signed certificate in certificate chain
SSL certificate problem: unable to get local issuer certificate
The text was updated successfully, but these errors were encountered: