Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,27 @@ namespace lwsf { namespace internal
else
url.port = 80;
}

// Configure SSL certificate verification
if (options.support != epee::net_utils::ssl_support_t::e_ssl_support_disabled)
{
bool ca_file_valid = !ca_file_path_.empty() && std::filesystem::exists(ca_file_path_);

if (ca_file_valid) {
try {
options = epee::net_utils::ssl_options_t(
std::vector<std::vector<std::uint8_t>>{},
ca_file_path_
);
options.verification = epee::net_utils::ssl_verification_t::user_ca;
} catch (const std::exception& e) {
options.verification = epee::net_utils::ssl_verification_t::system_ca;
}
} else {
options.verification = epee::net_utils::ssl_verification_t::system_ca;
}
}

data_->client.set_server(std::move(url.host), std::to_string(url.port), std::move(login), std::move(options));
}
catch (const std::exception& e)
Expand Down Expand Up @@ -886,6 +907,11 @@ namespace lwsf { namespace internal
return true;
}

void wallet::setCaFilePath(const std::string &path)
{
ca_file_path_ = path;
}

uint64_t wallet::balance(const uint32_t accountIndex) const
{
const boost::lock_guard<boost::mutex> lock{data_->sync};
Expand Down
2 changes: 2 additions & 0 deletions src/wallet.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ namespace internal
const std::string filename_;
std::string password_;
std::string language_;
std::string ca_file_path_;
std::deque<std::function<std::error_code()>> work_queue_;
mutable std::string exception_error_;
mutable std::error_code error_;
Expand Down Expand Up @@ -267,6 +268,7 @@ namespace internal
virtual void setTrustedDaemon(bool) override {}
virtual bool trustedDaemon() const override { return true; }
virtual bool setProxy(const std::string &address) override;
void setCaFilePath(const std::string &path);
virtual uint64_t balance(uint32_t accountIndex = 0) const override;
virtual uint64_t unlockedBalance(uint32_t accountIndex = 0) const override;

Expand Down