Skip to content

Commit d423c9b

Browse files
committed
remove boost
1 parent 15b5e2a commit d423c9b

File tree

3 files changed

+7
-89
lines changed

3 files changed

+7
-89
lines changed

CMakeLists.txt

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,6 @@ endif()
1717
find_package(Qt5 COMPONENTS Core Gui Test Widgets WebEngineWidgets Sql REQUIRED)
1818

1919
find_package(CURL REQUIRED)
20-
# Set policy for Boost to ensure compatibility with newer CMake versions
21-
if(POLICY CMP0167)
22-
cmake_policy(SET CMP0167 NEW)
23-
endif()
24-
find_package(Boost REQUIRED COMPONENTS system filesystem)
25-
26-
find_package(OpenSSL REQUIRED)
2720

2821
if(NOT EXISTS "${CMAKE_SOURCE_DIR}/libs/miniz/CMakeLists.txt")
2922
message(STATUS "Submodule 'libs/miniz' not found. Updating submodules...")
@@ -123,9 +116,6 @@ set(LINK_COMMON
123116
miniz
124117
LIEF::LIEF
125118
${CURL_LIBRARY}
126-
OpenSSL::SSL
127-
Boost::system
128-
Boost::filesystem
129119
)
130120

131121
set(LINK_GUI
@@ -134,7 +124,6 @@ set(LINK_GUI
134124

135125
set(INCLUDE_DIR
136126
${CURL_INCLUDE_DIR}
137-
${Boost_INCLUDE_DIRS}
138127
libs/miniz
139128
libs/LIEF/include
140129
src

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,11 @@ On Arch this should be enough, you get the rest probably when you install the ba
2626
Ensure the following are installed on your Linux desktop:
2727

2828
- `curl` (7.71.0 or newer)
29-
- `Boost`
3029
- `OpenSSL`
3130
- `Qt5`
3231

3332
```shell
34-
sudo pacman -S qt5-wayland qt5-webengine qt5-imageformats boost
33+
sudo pacman -S qt5-wayland qt5-webengine qt5-imageformats
3534
```
3635

3736
### Build

src/Network.cpp

Lines changed: 6 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -14,71 +14,9 @@
1414
#include <curl/curl.h>
1515
#include <cstdio>
1616
#include <iostream>
17-
#include <vector>
1817
#include <string>
1918
#include "../src/Network.hpp"
2019
#include "../src/Path.hpp"
21-
#include <boost/asio.hpp>
22-
#include <boost/asio/ssl.hpp>
23-
24-
namespace ssl = boost::asio::ssl;
25-
using tcp = boost::asio::ip::tcp;
26-
27-
std::string get_ssl_certificate(const std::string& host) {
28-
bool status = true;
29-
std::string cert_buffer;
30-
boost::asio::io_context io_context;
31-
32-
// Use SSLv23 context (it's compatible with all versions of SSL/TLS)
33-
ssl::context ssl_context(ssl::context::sslv23);
34-
35-
// Restrict supported protocol to TLSv1.3
36-
ssl_context.set_options(ssl::context::no_sslv2 | ssl::context::no_sslv3);
37-
ssl_context.set_options(ssl::context::no_tlsv1 | ssl::context::no_tlsv1_1);
38-
ssl_context.set_options(ssl::context::no_tlsv1_2);
39-
40-
// Resolver for HTTPS (default port 443)
41-
tcp::resolver resolver(io_context);
42-
tcp::resolver::results_type endpoints = resolver.resolve(host, "443");
43-
44-
ssl::stream<tcp::socket> stream(io_context, ssl_context);
45-
SSL_set_tlsext_host_name(stream.native_handle(), host.c_str());
46-
47-
try {
48-
boost::asio::connect(stream.lowest_layer(), endpoints);
49-
stream.handshake(ssl::stream_base::client);
50-
} catch (const boost::system::system_error& e) {
51-
std::cerr << "SSL handshake failed: " << e.what() << std::endl;
52-
status = false;
53-
}
54-
55-
if (status) {
56-
// Get certificate
57-
X509* cert = SSL_get_peer_certificate(stream.native_handle());
58-
if (!cert) {
59-
std::cerr << "No certificate found." << std::endl;
60-
status = false;
61-
}
62-
if (status) {
63-
// Verify the certificate matches the host
64-
if (X509_check_host(
65-
cert, host.c_str(), host.length(), 0, nullptr) != 1) {
66-
std::cerr << "Hostname verification failed." << std::endl;
67-
status = false;
68-
}
69-
if (status) {
70-
BIO* bio = BIO_new(BIO_s_mem());
71-
PEM_write_bio_X509(bio, cert);
72-
char* cert_str = nullptr;
73-
qint64 cert_len = BIO_get_mem_data(bio, &cert_str);
74-
cert_buffer = std::string(cert_str, cert_len);
75-
BIO_free(bio);
76-
}
77-
}
78-
X509_free(cert);
79-
}
80-
return cert_buffer;
81-
}
8220

8321
void Downloader::setUrl(QUrl url) {
8422
m_url = url;
@@ -134,20 +72,6 @@ void Downloader::runConnect(QFile *file, const std::string& url) {
13472
const std::string trle_domain = "https://www.trle.net";
13573
const std::string trcustoms_domain = "https://trcustoms.org";
13674

137-
// Securely determine which domain is being accessed
138-
if (url.compare(0, trle_domain.size(), trle_domain) == 0) {
139-
std::string cert_buffer = get_ssl_certificate("www.trle.net");
140-
std::vector<char>
141-
cert_buffer_vec(cert_buffer.begin(), cert_buffer.end());
142-
143-
curl_blob blob;
144-
blob.data = cert_buffer_vec.data();
145-
blob.len = cert_buffer_vec.size();
146-
blob.flags = CURL_BLOB_COPY;
147-
148-
status = curl_easy_setopt(curl, CURLOPT_CAINFO_BLOB, &blob);
149-
}
150-
15175
// Set the URL securely
15276
if (status == CURLE_OK) {
15377
status = curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
@@ -158,6 +82,12 @@ void Downloader::runConnect(QFile *file, const std::string& url) {
15882
status = curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 1L);
15983
}
16084

85+
// Set TLS v1.3 version
86+
if (status == CURLE_OK) {
87+
status = curl_easy_setopt(curl, CURLOPT_SSLVERSION,
88+
CURL_SSLVERSION_TLSv1_3);
89+
}
90+
16191
// Secure Public Key Pinning
16292
if (status == CURLE_OK) {
16393
if (url.compare(0, trle_domain.size(), trle_domain) == 0) {

0 commit comments

Comments
 (0)