@@ -60,6 +60,10 @@ RestClient::Connection::GetInfo() {
6060 ret.customUserAgent = this ->customUserAgent ;
6161 ret.lastRequest = this ->lastRequest ;
6262
63+ ret.certPath = this ->certPath ;
64+ ret.certType = this ->certType ;
65+ ret.keyPath = this ->keyPath ;
66+
6367 return ret;
6468}
6569
@@ -175,6 +179,21 @@ RestClient::Connection::SetBasicAuth(const std::string& username,
175179 this ->basicAuth .password = password;
176180}
177181
182+ void
183+ RestClient::Connection::SetCertPath (const std::string& cert) {
184+ this ->certPath = cert;
185+ }
186+
187+ void
188+ RestClient::Connection::SetCertType (const std::string& certType) {
189+ this ->certType = certType;
190+ }
191+
192+ void
193+ RestClient::Connection::SetKeyPath (const std::string& keyPath) {
194+ this ->keyPath = keyPath;
195+ }
196+
178197/* *
179198 * @brief helper function to get called from the actual request methods to
180199 * prepare the curlHandle for transfer with generic options, perform the
@@ -247,14 +266,38 @@ RestClient::Connection::performCurlRequest(const std::string& uri) {
247266 curl_easy_setopt (this ->curlHandle , CURLOPT_CAINFO,
248267 this ->caInfoFilePath .c_str ());
249268 }
269+
270+ // set cert file path
271+ if (!this ->certPath .empty ()) {
272+ curl_easy_setopt (this ->curlHandle , CURLOPT_SSLCERT,
273+ this ->certPath .c_str ());
274+ }
275+
276+ // set cert type
277+ if (!this ->certType .empty ()) {
278+ curl_easy_setopt (this ->curlHandle , CURLOPT_SSLCERTTYPE,
279+ this ->certType .c_str ());
280+ }
281+ // set key file path
282+ if (!this ->keyPath .empty ()) {
283+ curl_easy_setopt (this ->curlHandle , CURLOPT_SSLKEY,
284+ this ->keyPath .c_str ());
285+ }
286+
250287 res = curl_easy_perform (this ->curlHandle );
251288 if (res != CURLE_OK) {
252- if (res == CURLE_OPERATION_TIMEDOUT) {
253- ret.code = res;
254- ret.body = " Operation Timeout." ;
255- } else {
256- ret.body = " Failed to query." ;
257- ret.code = -1 ;
289+ switch (res) {
290+ case CURLE_OPERATION_TIMEDOUT:
291+ ret.code = res;
292+ ret.body = " Operation Timeout." ;
293+ break ;
294+ case CURLE_SSL_CERTPROBLEM:
295+ ret.code = res;
296+ ret.body = curl_easy_strerror (res);
297+ break ;
298+ default :
299+ ret.body = " Failed to query." ;
300+ ret.code = -1 ;
258301 }
259302 } else {
260303 int64_t http_code = 0 ;
0 commit comments