diff --git a/crates/openconnect/build.rs b/crates/openconnect/build.rs index bf708c0..7886ca9 100644 --- a/crates/openconnect/build.rs +++ b/crates/openconnect/build.rs @@ -1,12 +1,257 @@ -#[path = "build/desktop.rs"] -mod desktop; -#[path = "build/ios.rs"] -mod ios; +use std::{env, path::PathBuf}; + +fn build_libxml2(deps_dir: &PathBuf, out_dir: &PathBuf) -> PathBuf { + let libxml2_dir = deps_dir.join("libxml2"); + let install_dir = out_dir.join("libxml2_install"); + + // The temporary location where we will build + let build_src = out_dir.join("libxml2_build"); + + // Track changes so cargo rebuilds if submodule changes + println!("cargo:rerun-if-changed={}", libxml2_dir.display()); + + // Prepare the build directory + // If the directory exists from a previous run, remove it to ensure a clean slate + if build_src.exists() { + std::fs::remove_dir_all(&build_src).unwrap(); + } + if install_dir.exists() { + std::fs::remove_dir_all(&install_dir).unwrap(); + } + std::fs::create_dir_all(&install_dir).unwrap(); + std::fs::create_dir_all(&build_src).unwrap(); + + // Copy the source code to OUT_DIR + // We use fs_extra options to copy contents recursively + let mut options = fs_extra::dir::CopyOptions::new(); + options.overwrite = true; + options.content_only = true; // Copy content of src into dest, not src folder itself + + fs_extra::dir::copy(&libxml2_dir, &build_src, &options).expect("Failed to copy C source code to OUT_DIR"); + + // Build the libxml2 library using autotools + let dst = { + let mut config = autotools::Config::new(&build_src); + config + .out_dir(&install_dir) + .reconf("-ivf") + .enable_static() + .disable_shared() + // Disable optional features that complicate static builds + .with("python", Some("no")) + .with("icu", Some("no")) + .with("http", Some("no")) + .with("ftp", Some("no")) + .with("catalog", Some("no")) + .with("docbook", Some("no")) + .with("legacy", Some("no")) + .with("threads", Some("no")) + .with("zlib", Some("no")) + .with("lzma", Some("no")) + // Ensure position-independent code (safe for static linking) + .cflag("-fPIC"); + config.build() + }; + + let lib_dir = dst.join("lib"); + let include_dir = dst.join("include/libxml2"); + + // Tell rustc where to find the static library + println!("cargo:rustc-link-search=native={}", lib_dir.display()); + + // Static linking of libxml2 + println!("cargo:rustc-link-lib=static=xml2"); + + // Export include path for downstream use (bindgen / cc) + println!("cargo:include={}", include_dir.display()); + + dst +} + +fn build_openconnect(deps_dir: &PathBuf, out_dir: &PathBuf) -> PathBuf { + let openconnect_dir = deps_dir.join("openconnect"); + let install_dir = out_dir.join("openconnect_install"); + + // The temporary location where we will build + let build_src = out_dir.join("openconnect_build"); + + // Track changes so cargo rebuilds if submodule changes + println!("cargo:rerun-if-changed={}", openconnect_dir.display()); + + // Prepare the build directory + // If the directory exists from a previous run, remove it to ensure a clean slate + if build_src.exists() { + std::fs::remove_dir_all(&build_src).unwrap(); + } + if install_dir.exists() { + std::fs::remove_dir_all(&install_dir).unwrap(); + } + std::fs::create_dir_all(&install_dir).unwrap(); + std::fs::create_dir_all(&build_src).unwrap(); + + // Copy the source code to OUT_DIR + // We use fs_extra options to copy contents recursively + let mut options = fs_extra::dir::CopyOptions::new(); + options.overwrite = true; + options.content_only = true; // Copy content of src into dest, not src folder itself + + fs_extra::dir::copy(&openconnect_dir, &build_src, &options).expect("Failed to copy C source code to OUT_DIR"); + + // Build the OpenConnect library using autotools. Keep the upstream LGPL + // library dynamically linked on macOS so it remains replaceable in the app + // bundle. Other platforms retain the existing static-link behavior. + let mut config = autotools::Config::new(&build_src); + config + .out_dir(&install_dir) + .reconf("-ivf") + .disable("nls", None) // disable translations to save space + .disable("docs", None) + .disable("dsa-tests", None) + .without("libproxy", None) + .without("stoken", None) + .without("libpcsclite", None) + .without("libpskc", None) + .without("gssapi", None) + .with("gnutls-tss2", Some("no")) + .with("vpnc-script", Some("/etc/vpnc/vpnc-script")); // Specify vpnc-script, otherwise it will fail on macOS + + if target_os() == "macos" { + config + .disable_static() + .enable_shared() + .with("gnutls", None) + .without("openssl", None); + config.ldflag("-liconv"); + config.env("LIBS", "-liconv"); + } + + if target_os() != "macos" { + config.enable_static().disable_shared(); + } + + if matches!(target_os().as_str(), "freebsd" | "openbsd") { + config.ldflag("-L/usr/local/lib"); + config.ldflag("-liconv"); + config.env("LIBS", "-liconv"); + } + + let dst = config.build(); + + let lib_dir = dst.join("lib"); + let include_dir = dst.join("include"); + + if target_os() == "macos" { + let configuration = std::fs::read_to_string(dst.join("build/config.h")) + .expect("Failed to read the OpenConnect TLS backend configuration"); + assert!( + configuration.lines().any(|line| line == "#define OPENCONNECT_GNUTLS 1") + && !configuration + .lines() + .any(|line| line == "#define OPENCONNECT_OPENSSL 1"), + "macOS OpenConnect must use GnuTLS" + ); + // Do not embed Cargo's temporary build directory in consumers of this library. + let library = std::fs::canonicalize(lib_dir.join("libopenconnect.dylib")).unwrap(); + let library_name = library.file_name().unwrap().to_str().unwrap(); + let status = std::process::Command::new("install_name_tool") + .arg("-id") + .arg(format!("@rpath/{library_name}")) + .arg(&library) + .status() + .expect("Failed to update the OpenConnect dylib install name"); + assert!(status.success(), "Failed to update the OpenConnect dylib install name"); + let status = std::process::Command::new("codesign") + .args(["--force", "--sign", "-"]) + .arg(&library) + .status() + .expect("Failed to sign the OpenConnect dylib"); + assert!(status.success(), "Failed to sign the OpenConnect dylib"); + println!("cargo:lib_dir={}", lib_dir.display()); + } + + println!("cargo:rustc-link-search=native={}", lib_dir.display()); + + if target_os() == "macos" { + println!("cargo:rustc-link-lib=dylib=openconnect"); + } + + if target_os() != "macos" { + println!("cargo:rustc-link-lib=static=openconnect"); + } + + // Export include path for downstream use (bindgen / cc) + println!("cargo:include={}", include_dir.display()); + + dst +} fn main() { - match std::env::var("CARGO_CFG_TARGET_OS").as_deref() { - Ok("ios") => ios::build(), - Ok("macos" | "linux" | "freebsd" | "openbsd") => desktop::build(), - target => panic!("Unsupported OpenConnect target: {target:?}"), + let target = target_os(); + assert!( + matches!(target.as_str(), "macos" | "linux" | "freebsd" | "openbsd"), + "Unsupported OpenConnect target: {target}" + ); + let manifest_dir = env::var("CARGO_MANIFEST_DIR").unwrap(); + let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); + let deps_dir = PathBuf::from(manifest_dir).join("deps"); + + let oc_dst = build_openconnect(&deps_dir, &out_dir); + println!( + "cargo:rustc-env=OPENCONNECT_PROTOCOL_BUILD={}", + oc_dst.join("build").display() + ); + println!( + "cargo:rustc-env=OPENCONNECT_PROTOCOL_SOURCE={}", + out_dir.join("openconnect_build").display() + ); + + // Only statically link libxml2 if `LIBXML2_STATIC` is set + if env::var("LIBXML2_STATIC").is_ok() { + let _libxml2_dst = build_libxml2(&deps_dir, &out_dir); + } else { + // Using pkg-config to find system libxml2 + pkg_config::probe_library("libxml-2.0").unwrap(); } + + // Using pkg-config to find system deps + pkg_config::probe_library("zlib").unwrap(); + if target_os() == "macos" { + pkg_config::probe_library("gnutls").unwrap(); + } + + if target_os() != "macos" { + pkg_config::probe_library("liblz4").unwrap(); + pkg_config::probe_library("gnutls").unwrap(); + + // Below are required by gnutls + pkg_config::probe_library("p11-kit-1").unwrap(); + pkg_config::probe_library("hogweed").unwrap(); + pkg_config::probe_library("nettle").unwrap(); + pkg_config::probe_library("gmp").unwrap(); + } + + // Compile the vpn.c file + println!("cargo:rerun-if-changed=src/ffi/vpn.c"); + println!("cargo:rerun-if-changed=src/ffi/vpn.h"); + + if matches!(target_os().as_str(), "freebsd" | "openbsd") { + println!("cargo:rustc-link-search=native=/usr/local/lib"); + println!("cargo:rustc-link-lib=iconv"); + } + + // Prevent silent fallback to dynamic libraries + if target_os() == "linux" { + println!("cargo:rustc-link-arg=-Wl,-Bstatic"); + println!("cargo:rustc-link-arg=-Wl,-Bdynamic"); + } + + cc::Build::new() + .file("src/ffi/vpn.c") + .include("src/ffi") + .include(&oc_dst.join("include")) + .compile("vpn"); +} + +fn target_os() -> String { + env::var("CARGO_CFG_TARGET_OS").expect("Cargo target OS") } diff --git a/crates/openconnect/build/desktop.rs b/crates/openconnect/build/desktop.rs deleted file mode 100644 index 7a075fd..0000000 --- a/crates/openconnect/build/desktop.rs +++ /dev/null @@ -1,252 +0,0 @@ -use std::{env, path::PathBuf}; - -fn build_libxml2(deps_dir: &PathBuf, out_dir: &PathBuf) -> PathBuf { - let libxml2_dir = deps_dir.join("libxml2"); - let install_dir = out_dir.join("libxml2_install"); - - // The temporary location where we will build - let build_src = out_dir.join("libxml2_build"); - - // Track changes so cargo rebuilds if submodule changes - println!("cargo:rerun-if-changed={}", libxml2_dir.display()); - - // Prepare the build directory - // If the directory exists from a previous run, remove it to ensure a clean slate - if build_src.exists() { - std::fs::remove_dir_all(&build_src).unwrap(); - } - if install_dir.exists() { - std::fs::remove_dir_all(&install_dir).unwrap(); - } - std::fs::create_dir_all(&install_dir).unwrap(); - std::fs::create_dir_all(&build_src).unwrap(); - - // Copy the source code to OUT_DIR - // We use fs_extra options to copy contents recursively - let mut options = fs_extra::dir::CopyOptions::new(); - options.overwrite = true; - options.content_only = true; // Copy content of src into dest, not src folder itself - - fs_extra::dir::copy(&libxml2_dir, &build_src, &options).expect("Failed to copy C source code to OUT_DIR"); - - // Build the libxml2 library using autotools - let dst = { - let mut config = autotools::Config::new(&build_src); - config - .out_dir(&install_dir) - .reconf("-ivf") - .enable_static() - .disable_shared() - // Disable optional features that complicate static builds - .with("python", Some("no")) - .with("icu", Some("no")) - .with("http", Some("no")) - .with("ftp", Some("no")) - .with("catalog", Some("no")) - .with("docbook", Some("no")) - .with("legacy", Some("no")) - .with("threads", Some("no")) - .with("zlib", Some("no")) - .with("lzma", Some("no")) - // Ensure position-independent code (safe for static linking) - .cflag("-fPIC"); - config.build() - }; - - let lib_dir = dst.join("lib"); - let include_dir = dst.join("include/libxml2"); - - // Tell rustc where to find the static library - println!("cargo:rustc-link-search=native={}", lib_dir.display()); - - // Static linking of libxml2 - println!("cargo:rustc-link-lib=static=xml2"); - - // Export include path for downstream use (bindgen / cc) - println!("cargo:include={}", include_dir.display()); - - dst -} - -fn build_openconnect(deps_dir: &PathBuf, out_dir: &PathBuf) -> PathBuf { - let openconnect_dir = deps_dir.join("openconnect"); - let install_dir = out_dir.join("openconnect_install"); - - // The temporary location where we will build - let build_src = out_dir.join("openconnect_build"); - - // Track changes so cargo rebuilds if submodule changes - println!("cargo:rerun-if-changed={}", openconnect_dir.display()); - - // Prepare the build directory - // If the directory exists from a previous run, remove it to ensure a clean slate - if build_src.exists() { - std::fs::remove_dir_all(&build_src).unwrap(); - } - if install_dir.exists() { - std::fs::remove_dir_all(&install_dir).unwrap(); - } - std::fs::create_dir_all(&install_dir).unwrap(); - std::fs::create_dir_all(&build_src).unwrap(); - - // Copy the source code to OUT_DIR - // We use fs_extra options to copy contents recursively - let mut options = fs_extra::dir::CopyOptions::new(); - options.overwrite = true; - options.content_only = true; // Copy content of src into dest, not src folder itself - - fs_extra::dir::copy(&openconnect_dir, &build_src, &options).expect("Failed to copy C source code to OUT_DIR"); - - // Build the OpenConnect library using autotools. Keep the upstream LGPL - // library dynamically linked on macOS so it remains replaceable in the app - // bundle. Other platforms retain the existing static-link behavior. - let mut config = autotools::Config::new(&build_src); - config - .out_dir(&install_dir) - .reconf("-ivf") - .disable("nls", None) // disable translations to save space - .disable("docs", None) - .disable("dsa-tests", None) - .without("libproxy", None) - .without("stoken", None) - .without("libpcsclite", None) - .without("libpskc", None) - .without("gssapi", None) - .with("gnutls-tss2", Some("no")) - .with("vpnc-script", Some("/etc/vpnc/vpnc-script")); // Specify vpnc-script, otherwise it will fail on macOS - - if target_os() == "macos" { - config - .disable_static() - .enable_shared() - .with("gnutls", None) - .without("openssl", None); - config.ldflag("-liconv"); - config.env("LIBS", "-liconv"); - } - - if target_os() != "macos" { - config.enable_static().disable_shared(); - } - - if matches!(target_os().as_str(), "freebsd" | "openbsd") { - config.ldflag("-L/usr/local/lib"); - config.ldflag("-liconv"); - config.env("LIBS", "-liconv"); - } - - let dst = config.build(); - - let lib_dir = dst.join("lib"); - let include_dir = dst.join("include"); - - if target_os() == "macos" { - let configuration = std::fs::read_to_string(dst.join("build/config.h")) - .expect("Failed to read the OpenConnect TLS backend configuration"); - assert!( - configuration.lines().any(|line| line == "#define OPENCONNECT_GNUTLS 1") - && !configuration - .lines() - .any(|line| line == "#define OPENCONNECT_OPENSSL 1"), - "macOS OpenConnect must use GnuTLS" - ); - // Do not embed Cargo's temporary build directory in consumers of this library. - let library = std::fs::canonicalize(lib_dir.join("libopenconnect.dylib")).unwrap(); - let library_name = library.file_name().unwrap().to_str().unwrap(); - let status = std::process::Command::new("install_name_tool") - .arg("-id") - .arg(format!("@rpath/{library_name}")) - .arg(&library) - .status() - .expect("Failed to update the OpenConnect dylib install name"); - assert!(status.success(), "Failed to update the OpenConnect dylib install name"); - let status = std::process::Command::new("codesign") - .args(["--force", "--sign", "-"]) - .arg(&library) - .status() - .expect("Failed to sign the OpenConnect dylib"); - assert!(status.success(), "Failed to sign the OpenConnect dylib"); - println!("cargo:lib_dir={}", lib_dir.display()); - } - - println!("cargo:rustc-link-search=native={}", lib_dir.display()); - - if target_os() == "macos" { - println!("cargo:rustc-link-lib=dylib=openconnect"); - } - - if target_os() != "macos" { - println!("cargo:rustc-link-lib=static=openconnect"); - } - - // Export include path for downstream use (bindgen / cc) - println!("cargo:include={}", include_dir.display()); - - dst -} - -pub fn build() { - let manifest_dir = env::var("CARGO_MANIFEST_DIR").unwrap(); - let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); - let deps_dir = PathBuf::from(manifest_dir).join("deps"); - - let oc_dst = build_openconnect(&deps_dir, &out_dir); - println!( - "cargo:rustc-env=OPENCONNECT_PROTOCOL_BUILD={}", - oc_dst.join("build").display() - ); - println!( - "cargo:rustc-env=OPENCONNECT_PROTOCOL_SOURCE={}", - out_dir.join("openconnect_build").display() - ); - - // Only statically link libxml2 if `LIBXML2_STATIC` is set - if env::var("LIBXML2_STATIC").is_ok() { - let _libxml2_dst = build_libxml2(&deps_dir, &out_dir); - } else { - // Using pkg-config to find system libxml2 - pkg_config::probe_library("libxml-2.0").unwrap(); - } - - // Using pkg-config to find system deps - pkg_config::probe_library("zlib").unwrap(); - if target_os() == "macos" { - pkg_config::probe_library("gnutls").unwrap(); - } - - if target_os() != "macos" { - pkg_config::probe_library("liblz4").unwrap(); - pkg_config::probe_library("gnutls").unwrap(); - - // Below are required by gnutls - pkg_config::probe_library("p11-kit-1").unwrap(); - pkg_config::probe_library("hogweed").unwrap(); - pkg_config::probe_library("nettle").unwrap(); - pkg_config::probe_library("gmp").unwrap(); - } - - // Compile the vpn.c file - println!("cargo:rerun-if-changed=src/ffi/vpn.c"); - println!("cargo:rerun-if-changed=src/ffi/vpn.h"); - - if matches!(target_os().as_str(), "freebsd" | "openbsd") { - println!("cargo:rustc-link-search=native=/usr/local/lib"); - println!("cargo:rustc-link-lib=iconv"); - } - - // Prevent silent fallback to dynamic libraries - if target_os() == "linux" { - println!("cargo:rustc-link-arg=-Wl,-Bstatic"); - println!("cargo:rustc-link-arg=-Wl,-Bdynamic"); - } - - cc::Build::new() - .file("src/ffi/vpn.c") - .include("src/ffi") - .include(&oc_dst.join("include")) - .compile("vpn"); -} - -fn target_os() -> String { - env::var("CARGO_CFG_TARGET_OS").expect("Cargo target OS") -} diff --git a/crates/openconnect/build/ios.rs b/crates/openconnect/build/ios.rs deleted file mode 100644 index 6064acf..0000000 --- a/crates/openconnect/build/ios.rs +++ /dev/null @@ -1,36 +0,0 @@ -use std::{env, path::PathBuf}; - -pub fn build() { - println!("cargo:rerun-if-env-changed=GP_IOS_NATIVE_PREFIX"); - let prefix = PathBuf::from(env::var_os("GP_IOS_NATIVE_PREFIX").expect( - "Set GP_IOS_NATIVE_PREFIX to target-built OpenConnect/GnuTLS libraries with an aarch64-apple-ios target.txt receipt", - )); - let target = std::fs::read_to_string(prefix.join("target.txt")).expect("Missing iOS native target receipt"); - assert_eq!( - target.trim(), - env::var("TARGET").unwrap(), - "Native library target mismatch" - ); - for name in ["openconnect", "gnutls", "hogweed", "nettle", "gmp"] { - let archive = prefix.join(format!("lib/lib{name}.a")); - assert!(archive.is_file(), "Missing {}", archive.display()); - println!("cargo:rerun-if-changed={}", archive.display()); - } - println!("cargo:rerun-if-changed=src/ffi/vpn.c"); - println!("cargo:rerun-if-changed=src/ffi/vpn.h"); - cc::Build::new() - .file("src/ffi/vpn.c") - .include("src/ffi") - .include(prefix.join("include")) - .flag("-fapplication-extension") - .compile("vpn"); - println!("cargo:rustc-link-search=native={}", prefix.join("lib").display()); - for name in ["openconnect", "gnutls", "hogweed", "nettle", "gmp"] { - println!("cargo:rustc-link-lib=static={name}"); - } - for name in ["xml2", "z", "iconv", "resolv"] { - println!("cargo:rustc-link-lib={name}"); - } - println!("cargo:rustc-link-lib=framework=Security"); - println!("cargo:rustc-link-lib=framework=CoreFoundation"); -} diff --git a/crates/openconnect/src/ffi/mod.rs b/crates/openconnect/src/ffi/mod.rs index cfd44b7..26d3512 100644 --- a/crates/openconnect/src/ffi/mod.rs +++ b/crates/openconnect/src/ffi/mod.rs @@ -44,7 +44,6 @@ pub(crate) struct ConnectOptions { pub interface: *const c_char, pub script_tun: u32, pub script_tun_launch: *const ScriptTunLaunchRaw, - pub packet_fd: c_int, pub certificate: *const c_char, pub sslkey: *const c_char, diff --git a/crates/openconnect/src/ffi/vpn.c b/crates/openconnect/src/ffi/vpn.c index 0023344..d7d6483 100644 --- a/crates/openconnect/src/ffi/vpn.c +++ b/crates/openconnect/src/ffi/vpn.c @@ -86,10 +86,7 @@ static void setup_tun_handler(void *private_data) struct openconnect_info *_vpninfo = context->vpninfo; const vpn_options *options = context->options; int ret; - if (options->packet_fd >= 0) { - int fd = dup(options->packet_fd); - ret = fd < 0 ? -errno : openconnect_setup_tun_fd_with_config(_vpninfo, fd); - } else if (options->script_tun) { + if (options->script_tun) { const struct openconnect_script_tun_launch *launch = options->script_tun_launch; if (launch) { ret = openconnect_setup_tun_script_exec(_vpninfo, launch); diff --git a/crates/openconnect/src/ffi/vpn.h b/crates/openconnect/src/ffi/vpn.h index 6ec44e8..e159a76 100644 --- a/crates/openconnect/src/ffi/vpn.h +++ b/crates/openconnect/src/ffi/vpn.h @@ -48,7 +48,6 @@ typedef struct vpn_options { const char *interface; const int script_tun; const struct openconnect_script_tun_launch *script_tun_launch; - const int packet_fd; const char *certificate; const char *sslkey; diff --git a/crates/openconnect/src/vpn.rs b/crates/openconnect/src/vpn.rs index e2c87f3..c38110b 100644 --- a/crates/openconnect/src/vpn.rs +++ b/crates/openconnect/src/vpn.rs @@ -151,7 +151,6 @@ pub struct Vpn { interface: Option, script_tun: bool, script_tun_launch: Option, - packet_endpoint: Option, certificate: Option, sslkey: Option, @@ -315,7 +314,6 @@ impl Vpn { interface: Self::option_to_ptr(&self.interface), script_tun: self.script_tun as u32, script_tun_launch: std::ptr::null(), - packet_fd: self.packet_endpoint.as_ref().map_or(-1, AsRawFd::as_raw_fd), certificate: Self::option_to_ptr(&self.certificate), sslkey: Self::option_to_ptr(&self.sslkey), @@ -384,7 +382,6 @@ pub struct VpnBuilder { interface: Option, script_tun: bool, script_tun_launch: Option, - packet_endpoint: Option, user_agent: Option, os: Option, @@ -396,7 +393,6 @@ pub struct VpnBuilder { certificate: Option, sslkey: Option, key_password: Option, - servercert: Option, hip_source: Arc, @@ -421,7 +417,6 @@ impl VpnBuilder { interface: None, script_tun: false, script_tun_launch: None, - packet_endpoint: None, user_agent: None, os: None, @@ -433,7 +428,6 @@ impl VpnBuilder { certificate: None, sslkey: None, key_password: None, - servercert: None, hip_source: Arc::new(HipSource::Disabled), @@ -447,16 +441,6 @@ impl VpnBuilder { } } - /// Use an application-owned packet descriptor. OpenConnect borrows a duplicate - /// during connect; this owner remains alive until the Vpn is dropped. Apple/BSD - /// endpoints use the native four-byte, network-order address-family prefix. - /// Requires callback configuration and a SHA-256 server public-key pin. - pub fn packet_endpoint(mut self, endpoint: OwnedFd, server_pin: String) -> Self { - self.packet_endpoint = Some(endpoint); - self.servercert = Some(server_pin); - self - } - pub fn script>>(mut self, script: T) -> Self { self.script = script.into(); self.script_is_path = false; @@ -634,24 +618,6 @@ impl VpnBuilder { } pub fn build(self) -> Result { - if self.packet_endpoint.is_some() { - let pin = self.servercert.as_deref().unwrap_or_default(); - if self.network_configuration_handler.is_none() - || self.interface.is_some() - || self.script.is_some() - || self.script_tun - || self.script_tun_launch.is_some() - { - return Err(VpnError::new( - "Packet endpoint requires callback configuration and no device/script options".into(), - )); - } - if !pin.starts_with("pin-sha256:") || pin.len() != 55 || pin.contains('\0') { - return Err(VpnError::new( - "Packet endpoint requires a pin-sha256 server public-key fingerprint".into(), - )); - } - } if self.script_tun_launch.is_some() && !self.script_tun { return Err(VpnError::new("Child identity requires script-tun".into())); } @@ -677,12 +643,11 @@ impl VpnBuilder { interface: self.interface.as_deref().map(Self::to_cstring), script_tun: self.script_tun, script_tun_launch: self.script_tun_launch, - packet_endpoint: self.packet_endpoint, certificate: self.certificate.as_deref().map(Self::to_cstring), sslkey: self.sslkey.as_deref().map(Self::to_cstring), key_password: self.key_password.as_deref().map(Self::to_cstring), - servercert: self.servercert.as_deref().map(Self::to_cstring), + servercert: None, hip_source: self.hip_source, @@ -810,7 +775,6 @@ mod tests { interface: None, script_tun: false, script_tun_launch: None, - packet_endpoint: None, certificate: None, sslkey: None, key_password: None,