Skip to content

Add signature verification plugin from conda.trust#245

Open
jezdez wants to merge 6 commits intomainfrom
add-signature-verification-plugin
Open

Add signature verification plugin from conda.trust#245
jezdez wants to merge 6 commits intomainfrom
add-signature-verification-plugin

Conversation

@jezdez
Copy link
Member

@jezdez jezdez commented Jan 29, 2026

Summary

Migrates the signature verification functionality from conda.trust module to conda-content-trust as a proper plugin.

Fixes conda/conda#14847

  • Adds verification.py with _SignatureVerification class
  • Adds constants.py with KEY_MGR_FILE constant
  • Registers CondaPostSolve hook for signature-verification
  • Adds comprehensive tests migrated from conda
  • Updates plugin.py to export both subcommand and post-solve hook

The verification requires a trust root to be installed (e.g., via conda-anaconda-trust-root) to $CONDA_PREFIX/etc/conda/. Without a trust root, signature verification is disabled.

Related

Part of conda/conda#14797

Related PRs:

Test plan

  • New verification tests pass
  • Plugin registers correctly with conda
  • Signature verification works when trust root is installed

Migrates the signature verification functionality from conda.trust module
to conda-content-trust as a proper plugin. This change:

- Adds verification.py with _SignatureVerification class
- Adds constants.py with KEY_MGR_FILE constant
- Registers CondaPostSolve hook for signature-verification
- Adds comprehensive tests migrated from conda
- Updates plugin.py to export both subcommand and post-solve hook

The verification requires a trust root to be installed (e.g., via
conda-anaconda-trust-root) to $CONDA_PREFIX/etc/conda/. Without a
trust root, signature verification is disabled.

Part of: conda/conda#14797
@jezdez jezdez force-pushed the add-signature-verification-plugin branch from 411ee31 to 5c9d3c7 Compare January 29, 2026 19:22
jezdez added 3 commits March 3, 2026 09:22
- Fix av_data_dir mocking: use PropertyMock on Context class instead of
  patching the instance attribute (which fails because av_data_dir is a
  read-only property)
- Fix error handling in verification.py to match original conda code:
  catch HTTPError specifically instead of broad Exception in key_mgr
  (which was swallowing SignatureError)
- Import HTTPError from conda.gateways.connection
- Add key_mgr_verify.json with the correct pkg_mgr key matching the
  repodata.json test signatures
- Mock _fetch_channel_signing_data in test_signature_verification to
  avoid real network requests during tests
- Use http:// instead of https:// for test signing metadata URL
Use stdlib monkeypatch fixtures instead of pytest-mock for all test
patching in test_verification.py. This removes the pytest-mock
dependency from the test suite.

- Replace mocker.patch PropertyMock with monkeypatch.setattr on class
  properties for Context.av_data_dir and SubdirData.cache_path_base
- Replace mock_fetch_channel_signing_data fixture with a simpler
  mock_fetch fixture using monkeypatch.setattr and a plain list for
  call tracking
- Replace mock .call_count assertions with len(calls)
Three tests in test_root.py were missing the SSLIB_AVAILABLE skip
guard that other GPG tests already had, causing failures in CI
environments without securesystemslib installed.
@jezdez
Copy link
Member Author

jezdez commented Mar 3, 2026

pre-commit.ci autofix

@jezdez jezdez marked this pull request as ready for review March 4, 2026 11:42
@jezdez jezdez requested a review from kenodegard March 4, 2026 11:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed [bot] added once the contributor has signed the CLA

Projects

Status: 🆕 New

Development

Successfully merging this pull request may close these issues.

Port signature verification code to conda-content-trust

2 participants