| 20 | |
| 21 | |
| 22 | static CURL* createCurl() { |
| 23 | CURL* curl = curl_easy_init(); |
| 24 | assert(curl); |
| 25 | |
| 26 | // curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); |
| 27 | std::string userAgent = APP_NAME + " " + APP_EDITION_NAME + "/" + APP_VERSION; |
| 28 | curl_easy_setopt(curl, CURLOPT_USERAGENT, userAgent.c_str()); |
| 29 | curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, true); |
| 30 | // Timeout to wait on initial HTTP connection. |
| 31 | // This is lower than the typical HTTP timeout of 60 seconds to avoid DAWs from aborting plugin scans. |
| 32 | curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 30); |
| 33 | |
| 34 | // If curl can't resolve a DNS entry, it sends a signal to interrupt the process. |
| 35 | // However, since we use curl on non-main thread, this crashes the application. |
| 36 | // So tell curl not to signal. |
| 37 | curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1); |
| 38 | |
| 39 | // Load root certificates |
| 40 | std::string caPath = asset::system("cacert.pem"); |
| 41 | curl_easy_setopt(curl, CURLOPT_CAINFO, caPath.c_str()); |
| 42 | |
| 43 | // Don't verify HTTPS certificates if verifyHttpsCerts is false |
| 44 | curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, settings::verifyHttpsCerts); |
| 45 | |
| 46 | return curl; |
| 47 | } |
| 48 | |
| 49 | |
| 50 | static size_t writeStringCallback(char* ptr, size_t size, size_t nmemb, void* userdata) { |
no test coverage detected