fix: pass --ignore-certificate-errors Chrome flag when --ignore-https-errors is set (#1132)
* fix: pass --ignore-certificate-errors Chrome flag when --ignore-https-errors is set The existing CDP-level Security.setIgnoreCertificateErrors only takes effect after Chrome opens a connection, but some TLS errors (e.g. ERR_SSL_PROTOCOL_ERROR) are rejected at the network layer before CDP can intervene. Adding the Chrome launch flag ensures certificate errors are bypassed from process start. Fixes #1124 * test: add unit tests for --ignore-certificate-errors Chrome flag --------- Co-authored-by: ctate <366502+ctate@users.noreply.github.com>
This commit is contained in:
@@ -190,6 +190,10 @@ fn build_chrome_args(options: &LaunchOptions) -> Result<ChromeArgs, String> {
|
||||
(dir.clone(), Some(dir))
|
||||
};
|
||||
|
||||
if options.ignore_https_errors {
|
||||
args.push("--ignore-certificate-errors".to_string());
|
||||
}
|
||||
|
||||
if options.allow_file_access {
|
||||
args.push("--allow-file-access-from-files".to_string());
|
||||
args.push("--allow-file-access".to_string());
|
||||
@@ -1169,6 +1173,35 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_build_args_ignore_https_errors_includes_flag() {
|
||||
let opts = LaunchOptions {
|
||||
ignore_https_errors: true,
|
||||
..Default::default()
|
||||
};
|
||||
let result = build_chrome_args(&opts).unwrap();
|
||||
assert!(result
|
||||
.args
|
||||
.iter()
|
||||
.any(|a| a == "--ignore-certificate-errors"));
|
||||
if let Some(ref dir) = result.temp_user_data_dir {
|
||||
let _ = std::fs::remove_dir_all(dir);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_build_args_ignore_https_errors_default_no_flag() {
|
||||
let opts = LaunchOptions::default();
|
||||
let result = build_chrome_args(&opts).unwrap();
|
||||
assert!(!result
|
||||
.args
|
||||
.iter()
|
||||
.any(|a| a == "--ignore-certificate-errors"));
|
||||
if let Some(ref dir) = result.temp_user_data_dir {
|
||||
let _ = std::fs::remove_dir_all(dir);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_chrome_process_drop_cleans_temp_dir() {
|
||||
let dir = std::env::temp_dir().join(format!(
|
||||
|
||||
Reference in New Issue
Block a user