fix: re-apply ignore_https_errors to recording context (#1178)

Security.setIgnoreCertificateErrors is session-scoped, so creating a new
BrowserContext for recording (Target.createBrowserContext) starts with the
default certificate validation enabled, ignoring the launch-time flag.

Store ignore_https_errors in BrowserManager alongside download_path, and
re-apply Security.setIgnoreCertificateErrors to the new session after
recording context creation — matching the existing pattern for download
behavior re-application.

Fixes #1172

Co-authored-by: wangjingjing <wangjingjing.99@bytedance.com>
This commit is contained in:
juniper929
2026-04-07 01:26:07 -05:00
committed by GitHub
co-authored by wangjingjing
parent 6d05a9485d
commit 6520e4123c
2 changed files with 18 additions and 0 deletions
+13
View File
@@ -3939,6 +3939,19 @@ async fn handle_recording_start(cmd: &Value, state: &mut DaemonState) -> Result<
.await; .await;
} }
// Re-apply HTTPS error ignore to the recording context.
// Security.setIgnoreCertificateErrors at launch only applies to the session it was sent on.
if mgr.ignore_https_errors {
let _ = mgr
.client
.send_command(
"Security.setIgnoreCertificateErrors",
Some(json!({ "ignore": true })),
Some(&new_session_id),
)
.await;
}
// Transfer cookies to new context // Transfer cookies to new context
if let Some(ref cr) = cookies_result { if let Some(ref cr) = cookies_result {
if let Some(cookie_arr) = cr.get("cookies").and_then(|v| v.as_array()) { if let Some(cookie_arr) = cr.get("cookies").and_then(|v| v.as_array()) {
+5
View File
@@ -202,6 +202,8 @@ pub struct BrowserManager {
default_timeout_ms: u64, default_timeout_ms: u64,
/// Stored download path from launch options, re-applied to new contexts (e.g., recording) /// Stored download path from launch options, re-applied to new contexts (e.g., recording)
pub download_path: Option<String>, pub download_path: Option<String>,
/// Whether to ignore HTTPS certificate errors, re-applied to new contexts (e.g., recording)
pub ignore_https_errors: bool,
/// Origins visited during this session, used by save_state to collect cross-origin localStorage. /// Origins visited during this session, used by save_state to collect cross-origin localStorage.
visited_origins: HashSet<String>, visited_origins: HashSet<String>,
} }
@@ -273,6 +275,7 @@ impl BrowserManager {
active_page_index: 0, active_page_index: 0,
default_timeout_ms: 25_000, default_timeout_ms: 25_000,
download_path: download_path.clone(), download_path: download_path.clone(),
ignore_https_errors,
visited_origins: HashSet::new(), visited_origins: HashSet::new(),
}; };
manager.discover_and_attach_targets().await?; manager.discover_and_attach_targets().await?;
@@ -360,6 +363,7 @@ impl BrowserManager {
active_page_index: 0, active_page_index: 0,
default_timeout_ms: 25_000, default_timeout_ms: 25_000,
download_path: None, download_path: None,
ignore_https_errors: false,
visited_origins: HashSet::new(), visited_origins: HashSet::new(),
}; };
@@ -1331,6 +1335,7 @@ async fn initialize_lightpanda_manager(
active_page_index: 0, active_page_index: 0,
default_timeout_ms: 25_000, default_timeout_ms: 25_000,
download_path: None, download_path: None,
ignore_https_errors: false,
visited_origins: HashSet::new(), visited_origins: HashSet::new(),
}; };