Skip to content

feat: Implement remote signing for CAWG X509CredentialHolder#1865

Open
BadrTad wants to merge 19 commits intocontentauth:mainfrom
Security4Media:feat/cawg-remote-signing
Open

feat: Implement remote signing for CAWG X509CredentialHolder#1865
BadrTad wants to merge 19 commits intocontentauth:mainfrom
Security4Media:feat/cawg-remote-signing

Conversation

@BadrTad
Copy link
Copy Markdown

@BadrTad BadrTad commented Feb 18, 2026

Changes in this pull request

This PR implements CAWG remote signing (as requested in #1777 ) by introducing a new type raw_signer:: RemoteRawSigner

The feature could be tested by enabling the "remote_signing" feature during compilation. and remote signers created with this new method create_signer::from_remote_url

The remote_signing is supported only for openssl crypto provider.

The code snippet that converts X509 certificates from PEM to DER in raw_signature::openssl crate was also refactored as a macro under raw_signature::openssl::cert_chain::cert_chain_to_der!

The remote signer could be created by providing a setting configuration to Context struct or by instantiating X509CredentialHolder from a openssl::signers::remote_signer::RemoteRawSigner.

Tests use the httpmock crate to create mock servers that responds with valid signature using a (local) signer instantiated with create_signer::from_keys.

Checklist

  • This PR represents a single feature, fix, or change.
  • All applicable changes have been documented.
  • Any TO DO items (or similar) have been entered as GitHub issues and the link to that issue has been included in a comment.

@BadrTad BadrTad force-pushed the feat/cawg-remote-signing branch from 496acb6 to fa6bec5 Compare February 19, 2026 15:40
Comment thread sdk/src/crypto/raw_signature/openssl/cert_chain.rs Outdated
Copy link
Copy Markdown
Collaborator

@scouten-adobe scouten-adobe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm leaving on vacation shortly and won't have time to do a full review before I go. I've asked @gpeacock to review it hopefully next week.

@BadrTad
Copy link
Copy Markdown
Author

BadrTad commented Mar 12, 2026

The remote_signing crate feature requires the openssl crypto provider and lacks support for rust_native crypto provider.
In this case the crypro providers are used mainly to verify and parse the certificate chain.
Issue #1926 documents the lack of support for the remote_signing feature with rust_native crypto provider.

@BadrTad BadrTad marked this pull request as ready for review March 12, 2026 00:06
@scouten-adobe scouten-adobe changed the title feat(cawg): Implement remote signing for X509CredentialHolder feat: Implement remote signing for CAWG X509CredentialHolder Mar 12, 2026
Copy link
Copy Markdown
Collaborator

@scouten-adobe scouten-adobe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great. A few tweaks I'd like to see, but I'm eager to see this land.

Ok(self.cert_chain.clone())
}

fn reserve_size(&self) -> usize {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind putting this back where it was? I'd prefer to keep the diffs as minimal as possible. (Applies to other signer implementations also.)

BTW, please consider ticking the box that says "Allow maintainers to edit this PR." I'd have made this change already if that was enabled.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, the "Allow maintainers to edit this PR" is not supported for an organization repos type (see https://github.com/orgs/community/discussions/5634). Next time, I will make sure to make PRs from my personal repo.

As for the diffs, my intention was to make sure the implementing structs of a trait follow the same method definition order as that trait.

I understand that you want to keep the diffs minimal. I reverted these changes back.

BoxedSigner, Error, Result, Signer, SigningAlg,
};

/// Enum representing the CAWG X.509 signing mode: local (with private key) or remote (via URL).
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gpeacock @ok-nick would one of you please review this part for settings API changes?

self.0.reserve_size()
}

async fn ocsp_val(&self) -> Option<Vec<u8>> {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as on the RawSigner implementations earlier: Please avoid adding refactoring diffs.

@scouten-adobe
Copy link
Copy Markdown
Collaborator

@BadrTad I see Clippy has some warnings. Please add the necessary #[allow(clippy:...)] declarations, assuming the unwrap and expect calls are in test code.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Mar 12, 2026

Merging this PR will improve performance by 10.24%

⚡ 1 improved benchmark
✅ 15 untouched benchmarks
⏩ 2 skipped benchmarks1

Performance Changes

Benchmark BASE HEAD Efficiency
sign 100kb jpeg 5 ms 4.5 ms +10.24%

Comparing Security4Media:feat/cawg-remote-signing (f298d15) with main (455683f)

Open in CodSpeed

Footnotes

  1. 2 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@BadrTad
Copy link
Copy Markdown
Author

BadrTad commented Mar 12, 2026

Thank you @scouten-adobe once again for your review. I have made the requested changes. And looking forward for @gpeacock and @ok-nick 's reviews.

Copy link
Copy Markdown
Collaborator

@scouten-adobe scouten-adobe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved pending review from @gpeacock or @ok-nick and fixing the remaining Clippy warning and unit test failures.

@BadrTad
Copy link
Copy Markdown
Author

BadrTad commented Mar 13, 2026

Hi @scouten-adobe @gpeacock, to fix the tests I had to add a utility method to create context::Context directly from settings::Settings for the remote signing test cases. Combining compilation flags: test and feature=remote_signing in Context::default() cannot satisfy both settings::signer::test_make_cawg_c2pa_remote_signers test and builder::tests test cases.

Why not use Context::new().with_settings(...)?

Testing remote signers created from contexts requires SignerState::FromSettings as a state, this is not satisfied with Context::new().with_settings(...) which yields SignerState::Custom. Changing this behavior is not possible as other builder::tests cases requires it.

I will be curious to learn from you if we can do this in a better way.

@scouten-adobe
Copy link
Copy Markdown
Collaborator

@ok-nick is asking why this is specific to OpenSSL.

@BadrTad
Copy link
Copy Markdown
Author

BadrTad commented Mar 30, 2026

@scouten-adobe @gpeacock @ok-nick I am working on supporting rust native crypto provider and fix the failling tests

- use certificate parsing and validation according to crypto provider
- updates unit tests
- fix cfg for wasm unittests
@BadrTad
Copy link
Copy Markdown
Author

BadrTad commented Mar 30, 2026

@scouten-adobe @gpeacock @ok-nick , raw remote signer now supports both rust native crypto and openssl providers. As stated in #1995, we are missing tests for wasm build because httpmock is not supported yet for wasm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants