Skip to content

fix: improve openssl crypto backend#98

Merged
jkcoxson merged 2 commits into
jkcoxson:masterfrom
maxslarsson:fix/openssl-feature-parity
May 7, 2026
Merged

fix: improve openssl crypto backend#98
jkcoxson merged 2 commits into
jkcoxson:masterfrom
maxslarsson:fix/openssl-feature-parity

Conversation

@maxslarsson
Copy link
Copy Markdown
Contributor

@maxslarsson maxslarsson commented May 7, 2026

Improve the openssl crypto backend, matching rustls in functionality.

The main issue was that ca.rs and pair() were gated on rustls even though they only use pure Rust crates (rsa, x509-cert, sha2, web-time) — no rustls APIs at all. This meant device pairing was completely unavailable when building with openssl.

Changes:

  • Un-gate ca.rs module from rustls — now only requires pair feature
  • Un-gate pair() in LockdownClient — same, just needs pair
  • LockdownClient::start_session now returns the legacy flag (Result<bool, IdeviceError>) instead of Result<(), _>. Four callers were each querying ProductVersion separately before calling start_session, which also queries it internally — that's two round-trips to the device for the same value. Now the callers just use the returned flag.
  • Add openssl feature to the FFI crate alongside aws-lc and ring
  • Fix the SNI server name in the openssl start_session from a placeholder to "Device" (matching the rustls path)
  • Gate ensure_pem_headers/is_pem_formatted/is_base64 helpers behind rustls feature since they're only used by the rustls PairingFile impl — removes dead code warnings on openssl builds

Un-gate `ca.rs` and `pair()` from rustls — they only use pure Rust
crates (rsa, x509-cert, sha2) so pairing now works with openssl.
Always detect legacy devices instead of only with openssl feature.
Add openssl feature to FFI crate. Clean up SNI string and gate
rustls-only PEM helpers to fix dead code warnings.
@maxslarsson maxslarsson changed the title fix: make openssl crypto path a first-class backend fix: imrpove openssl crypto backend May 7, 2026
@maxslarsson maxslarsson changed the title fix: imrpove openssl crypto backend fix: improve openssl crypto backend May 7, 2026
…ection

`LockdownClient::start_session` already queries ProductVersion to
detect legacy devices. Four callers were making the same query
beforehand. Now `start_session` returns the legacy bool so callers
reuse it instead of round-tripping to the device twice.
@maxslarsson maxslarsson force-pushed the fix/openssl-feature-parity branch from e573f49 to be3c393 Compare May 7, 2026 16:14
@maxslarsson maxslarsson changed the title fix: improve openssl crypto backend refactor: improve openssl crypto backend May 7, 2026
@maxslarsson maxslarsson changed the title refactor: improve openssl crypto backend fix: improve openssl crypto backend May 7, 2026
@jkcoxson jkcoxson merged commit 80d2cd9 into jkcoxson:master May 7, 2026
3 checks passed
maxslarsson added a commit to maxslarsson/idevice that referenced this pull request May 7, 2026
* fix: make openssl crypto path a first-class backend

Un-gate `ca.rs` and `pair()` from rustls — they only use pure Rust
crates (rsa, x509-cert, sha2) so pairing now works with openssl.
Always detect legacy devices instead of only with openssl feature.
Add openssl feature to FFI crate. Clean up SNI string and gate
rustls-only PEM helpers to fix dead code warnings.

* refactor: return legacy flag from start_session, remove duplicate detection

`LockdownClient::start_session` already queries ProductVersion to
detect legacy devices. Four callers were making the same query
beforehand. Now `start_session` returns the legacy bool so callers
reuse it instead of round-tripping to the device twice.
jkcoxson pushed a commit that referenced this pull request May 8, 2026
…gClient (#96)

* refactor: remove pairing_file field and state param from RemotePairingClient

Move pairing_file from a struct field (&'a mut borrow) to a parameter
on connect() and its callees. This removes the lifetime parameter from
the struct and scopes the mutable borrow to the function call.

Also remove the unused state: S generic from connect/pair/request_pair_consent,
since every caller passed 0u8 and ignored it. Callers can capture state
via move closures instead.

* fix: feature gating for error conversions and dead deps (#95)

- Add internal _serde_json and _reqwest features to gate From impls
- Remove unused json and byteorder optional dependencies
- Add missing xpc dependency to remote_pairing feature
- Simplify map_err workarounds in tunnel code to use ? directly

* fix: make openssl PairingFile escrow_bag field Optional (#97)

The openssl variant of PairingFile had escrow_bag as Vec<u8> while
RawPairingFile has it as Option<Data> (it's None on Apple Watch).
This caused compile errors in the From/TryFrom impls when building
with the openssl feature. The rustls variant already had the correct
Option<Vec<u8>> type.

* fix: improve openssl crypto backend (#98)

* fix: make openssl crypto path a first-class backend

Un-gate `ca.rs` and `pair()` from rustls — they only use pure Rust
crates (rsa, x509-cert, sha2) so pairing now works with openssl.
Always detect legacy devices instead of only with openssl feature.
Add openssl feature to FFI crate. Clean up SNI string and gate
rustls-only PEM helpers to fix dead code warnings.

* refactor: return legacy flag from start_session, remove duplicate detection

`LockdownClient::start_session` already queries ProductVersion to
detect legacy devices. Four callers were making the same query
beforehand. Now `start_session` returns the legacy bool so callers
reuse it instead of round-tripping to the device twice.

* Remove rt-multi-thread dependency from AFC file descriptor drop (#93)

AFC's close-on-drop used block_in_place + block_on to synchronously send
a FileClose packet, requiring tokio's rt-multi-thread feature. This is
heavyweight for a best-effort cleanup that already did nothing on wasm
and single-threaded runtimes.

Replace with a simple no-op drop that warns (debug_assert + println) if
.close().await wasn't called. The device reclaims FDs when the AFC
session ends regardless. Also fix the afc tool to explicitly close file
descriptors after use.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants