Fix: CSR version field must be 0 (v1), not 1, per RFC 2986#46
Open
poofygummy wants to merge 1 commit into
Open
Fix: CSR version field must be 0 (v1), not 1, per RFC 2986#46poofygummy wants to merge 1 commit into
poofygummy wants to merge 1 commit into
Conversation
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.
generateRequest:privateKey: in ALTCertificateRequest.m calls X509_REQ_set_version(request, 1). Per RFC 2986, the CSR version field is defined as INTEGER { v1(0) } — the only version ever standardized is named "v1," but its actual encoded value is 0, not 1. There's no version numbered 1 in the spec at all.
This passed unnoticed because X509_REQ_set_version's return value only confirms the field was set, not that the value was correct — so the existing != 1 success check still passes even with the wrong version number written in. The malformed CSR gets built successfully and signs fine locally; it's only rejected later, server-side, when actually submitted.
We hit this directly: a certificate renewal flow that revokes an old cert and requests a new one in the same pass was consistently failing with Apple's submitDevelopmentCSR endpoint returning "The certificate request is invalid," with no other indication of what was wrong. Changing the value to 0 fixed it immediately — the same request that failed with resultCode nonzero now returns resultCode = 0 and statusString = "Approved".
It's a one-character change, but it took a while to track down since the failure only ever shows up on Apple's side, well after local CSR generation reports success.
Helped by Claude Sonnet 5