Skip to content

armgit / moli

Public Imported from GitHub
0

Best headless browser for AI agents. Lite, Fast, High-Compatibility. Built in Rust

build(crypto): replace vendored OpenSSL with AWS-LC

ldm01f9722573317
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index f2e8bdaa2..69bc5723a 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -55,6 +55,11 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4
+ - name: Install AWS-LC build dependencies
+ run: |
+ apt-get update
+ apt-get install --yes --no-install-recommends cmake libclang-dev
+
- name: Install clippy
run: rustup component add clippy
@@ -70,6 +75,11 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4
+ - name: Install AWS-LC build dependencies
+ run: |
+ apt-get update
+ apt-get install --yes --no-install-recommends cmake libclang-dev
+
- name: Install cargo-nextest
uses: taiki-e/install-action@13608cbb45b01feb47ef444ab1a42dc41ad56f1a # v2.79.11
with:
@@ -90,6 +100,11 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4
+ - name: Install AWS-LC build dependencies
+ run: |
+ apt-get update
+ apt-get install --yes --no-install-recommends cmake libclang-dev
+
- name: Install uv
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
with:
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index e30740ee5..29471ce69 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -105,7 +105,7 @@ jobs:
shell: bash
run: |
apt-get update
- apt-get install --yes --no-install-recommends binutils python3
+ apt-get install --yes --no-install-recommends binutils cmake libclang-dev python3
- name: Validate shell installer
shell: bash
diff --git a/.github/workflows/sequential-navigation-soak.yml b/.github/workflows/sequential-navigation-soak.yml
index 0d60f5df7..a0546c252 100644
--- a/.github/workflows/sequential-navigation-soak.yml
+++ b/.github/workflows/sequential-navigation-soak.yml
@@ -52,6 +52,11 @@ jobs:
persist-credentials: false
ref: ${{ github.event.pull_request.head.sha || inputs.head_ref || github.sha }}
+ - name: Install AWS-LC build dependencies
+ run: |
+ apt-get update
+ apt-get install --yes --no-install-recommends cmake libclang-dev
+
- name: Resolve commits and initialize evidence
id: refs
shell: bash
diff --git a/.github/workflows/spider-bench.yml b/.github/workflows/spider-bench.yml
index c396506d6..fdf34376c 100644
--- a/.github/workflows/spider-bench.yml
+++ b/.github/workflows/spider-bench.yml
@@ -53,6 +53,11 @@ jobs:
persist-credentials: false
ref: ${{ github.event.pull_request.base.sha || inputs.base_ref || github.event.repository.default_branch }}
+ - name: Install AWS-LC build dependencies
+ run: |
+ apt-get update
+ apt-get install --yes --no-install-recommends cmake libclang-dev
+
- name: Resolve commits and initialize evidence
id: refs
shell: bash
diff --git a/Cargo.lock b/Cargo.lock
index 63777b10a..2566ece58 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -186,6 +186,7 @@ version = "0.39.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "83a25cf98105baa966497416dbd42565ce3a8cf8dbfd59803ec9ad46f3126399"
dependencies = [
+ "bindgen",
"cc",
"cmake",
"dunce",
@@ -2313,6 +2314,7 @@ dependencies = [
"crossbeam-channel",
"curl",
"moli-dns-resolver",
+ "openssl-sys",
"parking_lot",
"tracing",
]
@@ -2370,7 +2372,6 @@ dependencies = [
"moli-url-policy",
"moli-web-bot-auth",
"moli-web-mime",
- "openssl-sys",
"parking_lot",
"rcgen",
"strum",
@@ -3309,24 +3310,15 @@ version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e"
-[[package]]
-name = "openssl-src"
-version = "300.6.0+3.6.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a8e8cbfd3a4a8c8f089147fd7aaa33cf8c7450c4d09f8f80698a0cf093abeff4"
-dependencies = [
- "cc",
-]
-
[[package]]
name = "openssl-sys"
version = "0.9.116"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f28a22dc7140cda5f096e5e7724a6962ca81a7f8bfd2979f9b18c11af56318c4"
dependencies = [
+ "aws-lc-sys",
"cc",
"libc",
- "openssl-src",
"pkg-config",
"vcpkg",
]
diff --git a/moli-curl/Cargo.toml b/moli-curl/Cargo.toml
index ae20d6dc1..488f18fad 100644
--- a/moli-curl/Cargo.toml
+++ b/moli-curl/Cargo.toml
@@ -7,8 +7,9 @@ edition = "2024"
[dependencies]
anyhow = "1.0.100"
crossbeam-channel = "0.5.15"
-curl = { version = "0.4.49", features = ["brotli", "http2", "poll_7_68_0", "static-curl", "static-ssl"] }
+curl = { version = "0.4.49", default-features = false, features = ["brotli", "http2", "poll_7_68_0", "ssl", "static-curl"] }
moli-dns-resolver = { path = "../moli-dns-resolver" }
+openssl-sys = { version = "0.9", features = ["aws-lc"] }
parking_lot = "0.12"
tracing = "0.1.41"
diff --git a/moli-fetch/Cargo.toml b/moli-fetch/Cargo.toml
index 87542af5c..7e4cb83c2 100644
--- a/moli-fetch/Cargo.toml
+++ b/moli-fetch/Cargo.toml
@@ -12,8 +12,8 @@ test-support = ["moli-cookie-jar/test-support"]
anyhow = "1.0.100"
cidr = "0.3.2"
crossbeam-channel = "0.5.15"
-curl = { version = "0.4.49", features = ["brotli", "http2", "poll_7_68_0", "static-curl", "static-ssl"] }
-curl-sys = "0.4.87"
+curl = { version = "0.4.49", default-features = false, features = ["brotli", "http2", "poll_7_68_0", "ssl", "static-curl"] }
+curl-sys = { version = "0.4.87", default-features = false }
http = "1"
moli-browser-profile = { path = "../moli-browser-profile" }
moli-cookie-jar = { path = "../moli-cookie-jar" }
@@ -32,12 +32,6 @@ tracing = "0.1.41"
url = "2.5.7"
wildcard = "0.3.0"
-[target.'cfg(windows)'.dependencies]
-openssl-sys = { version = "0.9", features = ["vendored"] }
-
-[target.'cfg(not(windows))'.dependencies]
-openssl-sys = "0.9"
-
[dev-dependencies]
h2 = "0.4"
moli-cookie-jar = { path = "../moli-cookie-jar", features = ["test-support"] }
diff --git a/moli-fetch/src/blocking/collectors.rs b/moli-fetch/src/blocking/collectors.rs
index 2d7ee5559..014624866 100644
--- a/moli-fetch/src/blocking/collectors.rs
+++ b/moli-fetch/src/blocking/collectors.rs
@@ -19,9 +19,8 @@ use crate::{
use crate::RedirectInfo;
use super::{
- StreamingHtmlResponseStart, configure_openssl_tls_context,
- create_streaming_cache_body_writer_for_response_parts, next_redirect_url_from_parts,
- store_response_cookies,
+ StreamingHtmlResponseStart, create_streaming_cache_body_writer_for_response_parts,
+ next_redirect_url_from_parts, store_response_cookies,
};
fn is_interim_response_status(status: u16) -> bool {
@@ -979,10 +978,6 @@ impl Handler for ResponseCollector {
self.headers.push((name, value));
true
}
-
- fn ssl_ctx(&mut self, ssl_ctx: *mut std::ffi::c_void) -> std::result::Result<(), curl::Error> {
- configure_openssl_tls_context(ssl_ctx)
- }
}
impl Handler for StreamingResponseCollector {
@@ -1053,10 +1048,6 @@ impl Handler for StreamingResponseCollector {
fn progress(&mut self, _: f64, _: f64, _: f64, _: f64) -> bool {
!self.cancel_handle.is_cancelled()
}
-
- fn ssl_ctx(&mut self, ssl_ctx: *mut std::ffi::c_void) -> std::result::Result<(), curl::Error> {
- configure_openssl_tls_context(ssl_ctx)
- }
}
impl Handler for RawStreamingResponseCollector {
@@ -1130,10 +1121,6 @@ impl Handler for RawStreamingResponseCollector {
fn progress(&mut self, _: f64, _: f64, _: f64, _: f64) -> bool {
!self.cancel_handle.is_cancelled()
}
-
- fn ssl_ctx(&mut self, ssl_ctx: *mut std::ffi::c_void) -> std::result::Result<(), curl::Error> {
- configure_openssl_tls_context(ssl_ctx)
- }
}
fn identity_encoded_content_length(headers: &[(String, String)]) -> Option<usize> {
diff --git a/moli-fetch/src/blocking/mod.rs b/moli-fetch/src/blocking/mod.rs
index 002b11e46..be89f76c2 100644
--- a/moli-fetch/src/blocking/mod.rs
+++ b/moli-fetch/src/blocking/mod.rs
@@ -2,7 +2,7 @@ mod cache;
mod collectors;
use std::{
- ffi::{c_char, c_long, c_void},
+ ffi::{c_char, c_long},
net::{IpAddr, ToSocketAddrs},
str,
time::Duration,
@@ -796,21 +796,6 @@ pub(crate) fn configure_easy<H: Handler>(
Ok(outgoing_headers)
}
-pub(crate) fn configure_openssl_tls_context(
- ssl_ctx: *mut c_void,
-) -> std::result::Result<(), curl::Error> {
- // WPT's Python TLS server and some real servers close TLS sockets without a
- // close_notify alert. Browsers tolerate that EOF, while OpenSSL 3 reports it
- // as SSL_ERROR_SSL unless this compatibility option is set.
- unsafe {
- openssl_sys::SSL_CTX_set_options(
- ssl_ctx.cast::<openssl_sys::SSL_CTX>(),
- openssl_sys::SSL_OP_IGNORE_UNEXPECTED_EOF,
- );
- }
- Ok(())
-}
-
fn enforce_request_target_policy(config: &FetchConfig, request_url: &Url) -> Result<()> {
if crate::should_request_be_blocked_due_to_bad_port(request_url) {
bail!("blocked bad port for `{request_url}`");
diff --git a/moli-fetch/src/runtime.rs b/moli-fetch/src/runtime.rs
index dc54bc03c..2f47462a3 100644
--- a/moli-fetch/src/runtime.rs
+++ b/moli-fetch/src/runtime.rs
@@ -41,10 +41,10 @@ use crate::{
CachedStreamingResponseLookup, RawStreamingResponseCollector, RequestHttpVersion,
RequestTransferMetrics, ResponseCollector, StreamingCachePlan, StreamingHtmlResponseStart,
StreamingResponseCollector, cached_streaming_response_body_exceeds_response_limit,
- cached_streaming_response_is_stale, configure_easy, configure_openssl_tls_context,
- cookie_access_report_for_request, cookie_header_from_report,
- finish_streaming_cached_response, load_cached_streaming_response_lookup,
- log_request_completion, merge_cached_not_modified_streaming_response_lookup,
+ cached_streaming_response_is_stale, configure_easy, cookie_access_report_for_request,
+ cookie_header_from_report, finish_streaming_cached_response,
+ load_cached_streaming_response_lookup, log_request_completion,
+ merge_cached_not_modified_streaming_response_lookup,
network_request_extra_info_from_headers, next_followed_redirect_url_from_parts,
remove_cached_response, response_headers_forbid_cache_storage, store_response_cookies,
transfer_metrics_from_easy, validation_headers_for_cached_streaming_response_lookup,
@@ -2750,10 +2750,6 @@ impl Handler for FetchTransferHandler {
_ => {}
}
}
-
- fn ssl_ctx(&mut self, ssl_ctx: *mut std::ffi::c_void) -> std::result::Result<(), curl::Error> {
- configure_openssl_tls_context(ssl_ctx)
- }
}
fn configure_network_observation(
diff --git a/moli-renderer-v8/Cargo.toml b/moli-renderer-v8/Cargo.toml
index 5ba9ecc5a..66f207291 100644
--- a/moli-renderer-v8/Cargo.toml
+++ b/moli-renderer-v8/Cargo.toml
@@ -82,7 +82,7 @@ moli-webidl-callback = { path = "../moli-webidl-callback" }
moli-websocket = { path = "../moli-websocket" }
moli-xpath = { path = "../moli-xpath" }
publicsuffix = "2.3.0"
-curl = "0.4.49"
+curl = { version = "0.4.49", default-features = false, features = ["brotli", "http2", "poll_7_68_0", "ssl", "static-curl"] }
http = "1"
httpdate = "1.0.3"
html-escape = "0.2.13"
diff --git a/moli-webcrypto/Cargo.toml b/moli-webcrypto/Cargo.toml
index e4cc76f8f..8eb880654 100644
--- a/moli-webcrypto/Cargo.toml
+++ b/moli-webcrypto/Cargo.toml
@@ -9,7 +9,7 @@ description = "Renderer-neutral WebCrypto algorithms, keys, and JWK validation f
base64 = "0.22"
ed448-goldilocks = { version = "=0.14.0-pre.15", default-features = false, features = ["alloc", "signing"] }
moli-crypto = { path = "../moli-crypto" }
-openssl = "0.10.80"
+openssl = { version = "0.10.80", features = ["aws-lc"] }
pkcs8 = { version = "0.11.0", default-features = false, features = ["alloc"] }
serde = { version = "1.0.228", features = ["derive"] }
strum = { version = "0.28.0", features = ["derive"] }