Skip to content

Commit 334402f

Browse files
committed
URL Loader cURL SSL pem path
1 parent af2e8a2 commit 334402f

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

libs/openFrameworks/utils/ofURLFileLoader.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ using std::string;
2626
#include <fstream>
2727

2828
#if !defined(NO_OPENSSL)
29-
#define CERTIFICATE_FILE "ssl/cacert.pem"
30-
#define PRIVATE_KEY_FILE "ssl/cacert.key"
29+
#define CERTIFICATE_FILE "cacert.pem"
30+
#define PRIVATE_KEY_FILE "cacert.key"
3131
#endif
3232
#endif
3333

@@ -318,16 +318,17 @@ ofHttpResponse ofURLFileLoaderImpl::handleRequest(const ofHttpRequest & request)
318318
}
319319
if(version->features & CURL_VERSION_SSL) {
320320
#if !defined(NO_OPENSSL)
321-
const std::string caPath = "ssl";
322-
const std::string caFile = "ssl/cacert.pem";
323-
if (ofFile::doesFileExist(ofToDataPath(CERTIFICATE_FILE)) && checkValidCertifcate(ofToDataPath(CERTIFICATE_FILE))) {
324-
ofLogVerbose("ofURLFileLoader") << "SSL valid certificate found";
321+
const std::string certPath = ofToDataPath(CERTIFICATE_FILE, true);
322+
if (ofFile::doesFileExist(certPath) && checkValidCertifcate(certPath)) {
323+
ofLogVerbose("ofURLFileLoader") << "SSL valid certificate found at " << certPath;
325324
} else {
326325
ofLogVerbose("ofURLFileLoader") << "SSL certificate not found - generating";
327326
createSSLCertificate();
328327
}
329-
curl_easy_setopt(curl.get(), CURLOPT_CAPATH, ofToDataPath(caPath, true).c_str());
330-
curl_easy_setopt(curl.get(), CURLOPT_CAINFO, ofToDataPath(caFile, true).c_str());
328+
curl_easy_setopt(curl.get(), CURLOPT_CAINFO, certPath.c_str());
329+
#ifndef TARGET_WIN32
330+
curl_easy_setopt(curl.get(), CURLOPT_CAPATH, ofToDataPath("./", true).c_str());
331+
#endif
331332
#endif
332333
curl_easy_setopt(curl.get(), CURLOPT_SSL_VERIFYPEER, false);
333334
curl_easy_setopt(curl.get(), CURLOPT_SSL_VERIFYHOST, 2L);

0 commit comments

Comments
 (0)