Hej, mam mały problem z certyfikatem do mojej strony www przez curl w c++.
Chodzi o to, że na sprzęcie na którym koduje wszystko działa, ale gdy dodam certyfikat z mojej strony www i chcę aby strona była zaufana przez curlib, to mam taki wynik w konsoli
Post()
Thread
Post() - curl
* Trying 37.48.70.83:443...
* Connected to www.gigasoft.com.pl port 443 (#0)
* schannel: disabled automatic use of client certificate
* ALPN: offers http/1.1
* schannel: added 1 certificate(s) from CA file 'ca.crt'
* schannel: CertGetCertificateChain trust error CERT_TRUST_IS_UNTRUSTED_ROOT
* Closing connection 0
* schannel: shutting down SSL/TLS connection with www.gigasoft.com.pl port 443
Post() - error curl: SSL peer certificate or SSH remote key was not OK
A tak wygląda funkcja w C++
size_t write_data(void* buffer, size_t size, size_t nmemb, void* userp) {
std::string* data = (std::string*)userp;
data->append((char*)buffer, size * nmemb);
return size * nmemb;
}
std::string GigaSoftLib::Post(std::string url) {
printf("Post()\n");
std::string data;
std::thread t([&]() {
CURL* curl;
CURLcode res;
printf("Thread\n");
curl_global_init(CURL_GLOBAL_DEFAULT);
curl = curl_easy_init();
if (curl) {
printf("Post() - curl\n");
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYSTATUS, 1L);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &data);
curl_easy_setopt(curl, CURLOPT_CAPATH, "./");
curl_easy_setopt(curl, CURLOPT_CAINFO, "ca.crt");
res = curl_easy_perform(curl);
if (res != CURLE_OK) {
secret->variables.general.internet = 0;
secret->variables.info.msg = "Not internet connection";
printf("Post() - error curl: %s\n", curl_easy_strerror(res));
}
else {
secret->variables.general.internet = 1;
}
curl_easy_cleanup(curl);
curl_global_cleanup();
}
else {
printf("Post() - error curl: failed to initialize\n");
}
});
t.join();
std::string otp = url + "\n\n\n\n\n" + data;
// printf(otp.c_str());
return data;
}
Certyfikat na stronie www to Let's Encrypt, jeśli ktoś mi może podpowiedzieć jak to prawidłowo dodać i zrobić aby user nie musiał ręcznie instalować certyfikatu byłoby pięknie. Chce dodać że używam Visual Studio Comunity 2022!
Dziękuje wszystkim za podpowiedzi :)