@@ -197,6 +197,28 @@ setPeerCertificates(httplib::SSLClient& cli, libcdoc::NetworkBackend *network, c
197197 return libcdoc::OK;
198198}
199199
200+ //
201+ // Set proxy parameters
202+ //
203+ static libcdoc::result_t
204+ setProxy (httplib::SSLClient& cli, libcdoc::NetworkBackend *network)
205+ {
206+ libcdoc::NetworkBackend::ProxyCredentials cred;
207+ switch (auto result = network->getProxyCredentials (cred)) {
208+ case libcdoc::NOT_IMPLEMENTED:
209+ return libcdoc::OK;
210+ case libcdoc::OK:
211+ if (!cred.host .empty ()) {
212+ cli.set_proxy (cred.host , cred.port );
213+ }
214+ if (!cred.username .empty ()) {
215+ cli.set_proxy_basic_auth (cred.username , cred.password );
216+ }
217+ return libcdoc::OK;
218+ default : return result;
219+ }
220+ }
221+
200222//
201223// Post request and fetch response
202224//
@@ -262,6 +284,7 @@ libcdoc::NetworkBackend::sendKey (CapsuleInfo& dst, const std::string& url, cons
262284 httplib::SSLClient cli (host, port);
263285 result = setPeerCertificates (cli, this , buildURL (host, port));
264286 if (result != OK) return result;
287+ if (result = setProxy (cli, this ); result != OK) return result;
265288
266289 std::string full = path + " /key-capsules" ;
267290 httplib::Response rsp;
@@ -322,6 +345,7 @@ libcdoc::NetworkBackend::sendShare(std::vector<uint8_t>& dst, const std::string&
322345 httplib::SSLClient cli (host, port);
323346 result = setPeerCertificates (cli, this , buildURL (host, port));
324347 if (result != OK) return result;
348+ if (result = setProxy (cli, this ); result != OK) return result;
325349
326350 std::string full = path + " /key-shares" ;
327351 httplib::Response rsp;
@@ -360,6 +384,7 @@ libcdoc::NetworkBackend::fetchKey (std::vector<uint8_t>& dst, const std::string&
360384 httplib::SSLClient cli (host, port, d->x509 .get (), d->pkey );
361385 result = setPeerCertificates (cli, this , buildURL (host, port));
362386 if (result != OK) return result;
387+ if (result = setProxy (cli, this ); result != OK) return result;
363388
364389 std::string full = path + " /key-capsules/" + transaction_id;
365390 httplib::Headers hdrs;
@@ -395,6 +420,7 @@ libcdoc::NetworkBackend::fetchNonce(std::vector<uint8_t>& dst, const std::string
395420 httplib::SSLClient cli (host, port);
396421 result = setPeerCertificates (cli, this , buildURL (host, port));
397422 if (result != OK) return result;
423+ if (result = setProxy (cli, this ); result != OK) return result;
398424
399425 std::string full = path + " /key-shares/" + share_id + " /nonce" ;
400426 httplib::Response rsp;
@@ -430,6 +456,7 @@ libcdoc::NetworkBackend::fetchShare(ShareInfo& share, const std::string& url, co
430456
431457 result = setPeerCertificates (cli, this , buildURL (host, port));
432458 if (result != OK) return result;
459+ if (result = setProxy (cli, this ); result != OK) return result;
433460
434461 std::string full = path + " /key-shares/" + share_id;
435462 LOG_DBG (" Share url: {}" , full);
@@ -680,6 +707,7 @@ libcdoc::NetworkBackend::signSID(std::vector<uint8_t>& dst, std::vector<uint8_t>
680707 httplib::SSLClient cli (host, port);
681708 result = setPeerCertificates (cli, this , buildURL (host, port));
682709 if (result != OK) return result;
710+ if (result = setProxy (cli, this ); result != OK) return result;
683711
684712 //
685713 // Let user choose certificate (if multiple)
@@ -801,6 +829,7 @@ libcdoc::NetworkBackend::signMID(std::vector<uint8_t>& dst, std::vector<uint8_t>
801829 httplib::SSLClient cli (host, port);
802830 result = setPeerCertificates (cli, this , buildURL (host, port));
803831 if (result != OK) return result;
832+ if (result = setProxy (cli, this ); result != OK) return result;
804833
805834 //
806835 // Authenticate
0 commit comments