Skip to content

Commit 6520e41

Browse files
juniper929wangjingjing
andauthored
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>
1 parent 6d05a94 commit 6520e41

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

cli/src/native/actions.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3939,6 +3939,19 @@ async fn handle_recording_start(cmd: &Value, state: &mut DaemonState) -> Result<
39393939
.await;
39403940
}
39413941

3942+
// Re-apply HTTPS error ignore to the recording context.
3943+
// Security.setIgnoreCertificateErrors at launch only applies to the session it was sent on.
3944+
if mgr.ignore_https_errors {
3945+
let _ = mgr
3946+
.client
3947+
.send_command(
3948+
"Security.setIgnoreCertificateErrors",
3949+
Some(json!({ "ignore": true })),
3950+
Some(&new_session_id),
3951+
)
3952+
.await;
3953+
}
3954+
39423955
// Transfer cookies to new context
39433956
if let Some(ref cr) = cookies_result {
39443957
if let Some(cookie_arr) = cr.get("cookies").and_then(|v| v.as_array()) {

cli/src/native/browser.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,8 @@ pub struct BrowserManager {
202202
default_timeout_ms: u64,
203203
/// Stored download path from launch options, re-applied to new contexts (e.g., recording)
204204
pub download_path: Option<String>,
205+
/// Whether to ignore HTTPS certificate errors, re-applied to new contexts (e.g., recording)
206+
pub ignore_https_errors: bool,
205207
/// Origins visited during this session, used by save_state to collect cross-origin localStorage.
206208
visited_origins: HashSet<String>,
207209
}
@@ -273,6 +275,7 @@ impl BrowserManager {
273275
active_page_index: 0,
274276
default_timeout_ms: 25_000,
275277
download_path: download_path.clone(),
278+
ignore_https_errors,
276279
visited_origins: HashSet::new(),
277280
};
278281
manager.discover_and_attach_targets().await?;
@@ -360,6 +363,7 @@ impl BrowserManager {
360363
active_page_index: 0,
361364
default_timeout_ms: 25_000,
362365
download_path: None,
366+
ignore_https_errors: false,
363367
visited_origins: HashSet::new(),
364368
};
365369

@@ -1331,6 +1335,7 @@ async fn initialize_lightpanda_manager(
13311335
active_page_index: 0,
13321336
default_timeout_ms: 25_000,
13331337
download_path: None,
1338+
ignore_https_errors: false,
13341339
visited_origins: HashSet::new(),
13351340
};
13361341

0 commit comments

Comments
 (0)