Add legacy SCEP PKCS7 compatibility - #63
Open
ArtWachowski wants to merge 1 commit into
Open
Conversation
|
Artur Wachowski seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
ArtWachowski
force-pushed
the
legacy-scep-signed-attributes-bug1723
branch
from
August 26, 2026 17:35
ca69ab8 to
a19350f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Name of feature:
Opt-in legacy PKCS#7 compatibility for SCEP clients.
Pain or issue this feature alleviates:
This change addresses two PKCS#7 interoperability problems encountered with legacy SCEP implementations:
Some legacy clients sign authenticated attributes in their original encoded order instead of the DER SET-sorted order normally used during PKCS#7 signature verification. This results in crypto/rsa: verification error even though the original PKCS#7 signature is valid for the encoded attribute order.
SignedData.SetEncryptionAlgorithm() is currently honored by SignWithoutAttr(), but ignored by AddSignerChain(), which always derives the DigestEncryptionAlgorithm from the key and digest algorithm. This prevents callers from generating legacy-compatible SignerInfo values such as rsaEncryption when using RSA/SHA-1.
The changes add an opt-in verification fallback for the first case and make AddSignerChain() honor an explicitly configured encryption algorithm for the second.
Why is this important to the project (if not answered above):
This improves interoperability with older SCEP/PKCS#7 implementations while preserving the existing PKCS#7 behavior by default.
The legacy authenticated-attribute verification path is explicitly disabled unless requested by the caller.
The AddSignerChain() change also makes its behavior consistent with the existing SetEncryptionAlgorithm() API and with SignWithoutAttr().
This forms part of the fix for smallstep/certificates#1723.
Is there documentation on how to use this feature? If so, where?
The authenticated-attribute compatibility behavior is exposed through:
VerifyWithOptions(VerifyOptions{AllowUnsortedAuthenticatedAttributes: true})
and:
VerifyWithChainAndOptions(...)
For signing, the existing API is used:
SignedData.SetEncryptionAlgorithm(...)
before calling AddSigner() / AddSignerChain().
Existing Verify(), VerifyWithChain(), and signing behavior remain unchanged when these options are not used.
In what environments or workflows is this feature supported?
PKCS#7 signature verification where compatibility with legacy authenticated-attribute encoding is explicitly enabled.
PKCS#7 SignedData generation where callers explicitly select a DigestEncryptionAlgorithm through SetEncryptionAlgorithm().
The changes were tested as part of SCEP enrollment interoperability with a legacy client based on strongSwan 5.0.2.
In what environments or workflows is this feature explicitly NOT supported (if any)?
The legacy authenticated-attribute fallback is not enabled globally and does not alter the default verification path.
If AllowUnsortedAuthenticatedAttributes is false or omitted, verification continues to use the existing DER SET-sorted representation only.
No encryption algorithm is forced by this change. If SetEncryptionAlgorithm() is not called, AddSignerChain() continues to infer the algorithm exactly as before.
Supporting links/other PRs/issues:
Part of the fix for smallstep/certificates#1723 — SCEP enrollment failing with crypto/rsa: verification error.
Related legacy SCEP/PKCS#7 interoperability discussion: strongswan/strongswan#2753.
Corresponding smallstep/scep PR adds the SCEP-level opt-in for legacy authenticated-attribute verification.
Corresponding smallstep/certificates PR exposes both compatibility behaviors through SCEP provisioner configuration.
💔Thank you!