scep: set keyUsage on the self-signed enrollee certificate - #19
Open
yosuke-wolfssl wants to merge 1 commit into
Open
scep: set keyUsage on the self-signed enrollee certificate#19yosuke-wolfssl wants to merge 1 commit into
yosuke-wolfssl wants to merge 1 commit into
Conversation
- wolfcert_scep_self_signed_rsa() calls wc_SetKeyUsage() with digitalSignature,keyEncipherment before wc_MakeSelfCert(), and returns WOLFCERT_ERR_WC on failure after freeing the Cert. - tests/unit/test_scep_msg.c gains test_signer_key_usage(), which builds a CSR, generates the signer certificate and requires the parsed certificate to carry the keyUsage extension with both the digitalSignature and keyEncipherment bits. Issue: F-9799
There was a problem hiding this comment.
Pull request overview
Updates SCEP self-signed enrollee certificates to include RFC 8894-required key usages.
Changes:
- Sets
digitalSignatureandkeyEnciphermentbefore signing. - Adds unit coverage for both key-usage bits.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
tests/unit/test_scep_msg.c |
Tests the generated certificate’s key usages. |
src/scep/scep_msg.c |
Adds the required key-usage extension and error handling. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
wolfSSL-Fenrir-bot
approved these changes
Aug 21, 2026
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #19
Scan targets checked: wolfcert-bugs, wolfcert-src
No new issues found in the changed files. ✅
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.
Problem
RFC 8894 §1 requires that a SCEP client with no existing certificate sign its
pkiMessage with a self-signed certificate carrying a
keyUsageextensionasserting
digitalSignatureandkeyEncipherment.wolfcert_scep_self_signed_rsa()insrc/scep/scep_msg.cbuilt thatcertificate without one: it set
selfSigned,sigTypeanddaysValid,copied the CSR subject, then called
wc_MakeSelfCert()directly. Thecertificate goes on the wire in the SignedData
certificatesfield viawc_PKCS7_InitWithCert(), so every enrollment presented a non-conformantsigner identity to the CA. Reached from four call sites in
src/scep/scep_client.c— the blocking and non-blocking PKCSReq paths andthe GetCertInitial fallback signer — so it affected all SCEP enrollments,
and a CA that enforces the requirement rejects them. Standards conformance;
no memory-safety impact.
Fix (
src/scep/scep_msg.c)Set the usage before the certificate is signed:
Reuses the function's existing
rclocal and itswc_CertFree()+early-return cleanup style. No
#ifdef WOLFSSL_CERT_EXTguard is needed —wolfcert/check_config.halready hard-errors when wolfSSL lacks it.Closes f-9799.
Tests
test_signer_key_usage()intests/unit/test_scep_msg.cbuilds a CSR,generates the signer certificate, parses it, and requires
extKeyUsageSetplus both the
KEYUSE_DIGITAL_SIGandKEYUSE_KEY_ENCIPHERbits.Verification
extKeyUsageSetassertion, passes after the fix.scep_roundtrip,scep_poll_roundtrip,scep_async_roundtripandparse_negative, whichdrive the real signer path end to end.