Skip to content

Comments

Clear the extension list when removing the last extension#28398

Closed
davidben wants to merge 2 commits intoopenssl:masterfrom
davidben:delete-ext
Closed

Clear the extension list when removing the last extension#28398
davidben wants to merge 2 commits intoopenssl:masterfrom
davidben:delete-ext

Conversation

@davidben
Copy link
Contributor

The extensions list in a certificate, CRL, and CRL entry is defined as:

... extensions      [3]  EXPLICIT Extensions OPTIONAL ...
... crlEntryExtensions      Extensions OPTIONAL ...
... crlExtensions           [0]  EXPLICIT Extensions OPTIONAL ...

Extensions  ::=  SEQUENCE SIZE (1..MAX) OF Extension

This means that a present but empty extensions list is actually invalid. Rather, if you have no extensions to encode, you are meant to omit the list altogether. Fix the delete_ext functions to handle this correctly.

This would mostly be moot, as an application adding extensions only to delete them all would be unusual. However, #13658 implemented a slightly roundabout design where, to omit SKID/AKID, the library first puts them in and then the command-line tool detects some placeholder values and deletes the extensino again.

Fixes #28397

Checklist
  • tests are added or updated

paulidale
paulidale previously approved these changes Aug 31, 2025
Copy link
Contributor

@paulidale paulidale left a comment

Choose a reason for hiding this comment

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

Just some formatting nits. Approved once these are addressed.

Is it worthwhile factoring the repeated code into a function?
Or even defining a new delete function that does the additional work?

@paulidale paulidale added branch: master Applies to master branch approval: review pending This pull request needs review by a committer triaged: bug The issue/pr is/fixes a bug tests: present The PR has suitable tests present labels Aug 31, 2025
@paulidale
Copy link
Contributor

Happy for this to be back–ported to any relevant branches too.

The extensions list in a certificate, CRL, and CRL entry is defined as:

    ... extensions      [3]  EXPLICIT Extensions OPTIONAL ...
    ... crlEntryExtensions      Extensions OPTIONAL ...
    ... crlExtensions           [0]  EXPLICIT Extensions OPTIONAL ...

    Extensions  ::=  SEQUENCE SIZE (1..MAX) OF Extension

This means that a present but empty extensions list is actually invalid.
Rather, if you have no extensions to encode, you are meant to omit the
list altogether. Fix the delete_ext functions to handle this correctly.

This would mostly be moot, as an application adding extensions only to
delete them all would be unusual. However, openssl#13658 implemented a slightly
roundabout design where, to omit SKID/AKID, the library first puts them
in and then the command-line tool detects some placeholder values and
deletes the extension again.

Fixes openssl#28397
paulidale
paulidale previously approved these changes Aug 31, 2025
@davidben
Copy link
Contributor Author

(Alright, hopefully that version works? Embarrassing type errors. 😳 In my defense, it looks like the default macOS build doesn't check them, which is a little odd.)

Is it worthwhile factoring the repeated code into a function?

Ah sure, done.

Or even defining a new delete function that does the additional work?

You mean whether to export the helper publicly? I figure that can probably be left to when/if someone needs it, but no strong feelings either way. 🤷

Copy link
Contributor

@paulidale paulidale left a comment

Choose a reason for hiding this comment

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

Much neater, thanks.

Yes, I did mean exporting it but to the rest of libcrypto rather than publicly.
I agree, that can happen when someone needs it.

Copy link
Member

@t-j-h t-j-h left a comment

Choose a reason for hiding this comment

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

Nice fix. Thanks.

Ok for backfit.

@t-j-h t-j-h added approval: done This pull request has the required number of approvals and removed approval: review pending This pull request needs review by a committer labels Aug 31, 2025
@t8m t8m added branch: 3.0 Applies to openssl-3.0 branch branch: 3.2 Applies to openssl-3.2 (EOL) branch: 3.3 Applies to openssl-3.3 branch: 3.4 Applies to openssl-3.4 branch: 3.5 Applies to openssl-3.5 labels Sep 1, 2025
@t8m t8m closed this Sep 1, 2025
@t8m t8m reopened this Sep 1, 2025
@t8m t8m removed the branch: 3.0 Applies to openssl-3.0 branch label Sep 1, 2025
@openssl-machine openssl-machine added approval: ready to merge The 24 hour grace period has passed, ready to merge and removed approval: done This pull request has the required number of approvals labels Sep 1, 2025
openssl-machine pushed a commit that referenced this pull request Sep 9, 2025
The extensions list in a certificate, CRL, and CRL entry is defined as:

    ... extensions      [3]  EXPLICIT Extensions OPTIONAL ...
    ... crlEntryExtensions      Extensions OPTIONAL ...
    ... crlExtensions           [0]  EXPLICIT Extensions OPTIONAL ...

    Extensions  ::=  SEQUENCE SIZE (1..MAX) OF Extension

This means that a present but empty extensions list is actually invalid.
Rather, if you have no extensions to encode, you are meant to omit the
list altogether. Fix the delete_ext functions to handle this correctly.

This would mostly be moot, as an application adding extensions only to
delete them all would be unusual. However, #13658 implemented a slightly
roundabout design where, to omit SKID/AKID, the library first puts them
in and then the command-line tool detects some placeholder values and
deletes the extension again.

Fixes #28397

Reviewed-by: Paul Dale <[email protected]>
Reviewed-by: Tim Hudson <[email protected]>
Reviewed-by: Matt Caswell <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
(Merged from #28398)

(cherry picked from commit 9a8d7dc)
openssl-machine pushed a commit that referenced this pull request Sep 9, 2025
Reviewed-by: Paul Dale <[email protected]>
Reviewed-by: Tim Hudson <[email protected]>
Reviewed-by: Matt Caswell <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
(Merged from #28398)

(cherry picked from commit 9e8898b)
@t8m
Copy link
Member

t8m commented Sep 9, 2025

Merged to all the active branches. Thank you for your contribution.

@t8m t8m closed this Sep 9, 2025
openssl-machine pushed a commit that referenced this pull request Sep 9, 2025
The extensions list in a certificate, CRL, and CRL entry is defined as:

    ... extensions      [3]  EXPLICIT Extensions OPTIONAL ...
    ... crlEntryExtensions      Extensions OPTIONAL ...
    ... crlExtensions           [0]  EXPLICIT Extensions OPTIONAL ...

    Extensions  ::=  SEQUENCE SIZE (1..MAX) OF Extension

This means that a present but empty extensions list is actually invalid.
Rather, if you have no extensions to encode, you are meant to omit the
list altogether. Fix the delete_ext functions to handle this correctly.

This would mostly be moot, as an application adding extensions only to
delete them all would be unusual. However, #13658 implemented a slightly
roundabout design where, to omit SKID/AKID, the library first puts them
in and then the command-line tool detects some placeholder values and
deletes the extension again.

Fixes #28397

Reviewed-by: Paul Dale <[email protected]>
Reviewed-by: Tim Hudson <[email protected]>
Reviewed-by: Matt Caswell <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
(Merged from #28398)

(cherry picked from commit 9a8d7dc)
openssl-machine pushed a commit that referenced this pull request Sep 9, 2025
Reviewed-by: Paul Dale <[email protected]>
Reviewed-by: Tim Hudson <[email protected]>
Reviewed-by: Matt Caswell <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
(Merged from #28398)

(cherry picked from commit 9e8898b)
esyr added a commit to esyr/openssl that referenced this pull request Sep 11, 2025
CHANGES.md:
 * openssl#28398
 * openssl#28411
 * openssl#28447
 * openssl#28449

NEWS.md:
 * openssl#28447

Release: yes
Signed-off-by: Eugene Syromiatnikov <[email protected]>
esyr added a commit to esyr/openssl that referenced this pull request Sep 11, 2025
CHANGES.md:
 * openssl#28398
 * openssl#28411
 * openssl#28447
 * openssl#28449

NEWS.md:
 * openssl#28447

Release: yes
Signed-off-by: Eugene Syromiatnikov <[email protected]>
esyr added a commit to esyr/openssl that referenced this pull request Sep 11, 2025
CHANGES.md:
 * openssl#28398
 * openssl#28411
 * openssl#28447
 * openssl#28449

NEWS.md:
 * openssl#28447

Release: yes
Signed-off-by: Eugene Syromiatnikov <[email protected]>
openssl-machine pushed a commit that referenced this pull request Sep 13, 2025
CHANGES.md:
 * #28398
 * #28411
 * #28447
 * #28449

NEWS.md:
 * #28447

Release: yes
Signed-off-by: Eugene Syromiatnikov <[email protected]>

Reviewed-by: Neil Horman <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
Reviewed-by: Matt Caswell <[email protected]>
(Merged from #28521)
esyr added a commit to esyr/openssl that referenced this pull request Sep 15, 2025
CHANGES.md:
 * openssl#28398
 * openssl#28411
 * openssl#28447
 * openssl#28449

NEWS.md:
 * openssl#28447

Release: yes
Signed-off-by: Eugene Syromiatnikov <[email protected]>
esyr added a commit to esyr/openssl that referenced this pull request Sep 15, 2025
CHANGES.md:
 * openssl#28198
 * openssl#28398
 * openssl#28411
 * openssl#28447
 * openssl#28449

NEWS.md:
 * openssl#28447

Release: Yes
Signed-off-by: Eugene Syromiatnikov <[email protected]>
esyr added a commit to esyr/openssl that referenced this pull request Sep 16, 2025
CHANGES.md:
 * openssl#28198
 * openssl#28398
 * openssl#28411
 * openssl#28447
 * openssl#28449

NEWS.md:
 * openssl#28447

Release: Yes
Signed-off-by: Eugene Syromiatnikov <[email protected]>
openssl-machine pushed a commit that referenced this pull request Sep 16, 2025
CHANGES.md:
 * #28198
 * #28398
 * #28411
 * #28447
 * #28449

NEWS.md:
 * #28447

Release: Yes
Signed-off-by: Eugene Syromiatnikov <[email protected]>

Reviewed-by: Neil Horman <[email protected]>
Reviewed-by: Paul Dale <[email protected]>
(Merged from #28558)
openssl-machine pushed a commit that referenced this pull request Sep 16, 2025
CHANGES.md:
 * #28398
 * #28411
 * #28447
 * #28449

NEWS.md:
 * #28447

Release: yes
Signed-off-by: Eugene Syromiatnikov <[email protected]>

Reviewed-by: Neil Horman <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
(Merged from #28547)
esyr added a commit to esyr/openssl that referenced this pull request Sep 30, 2025
3.0.18 CHANGES.md includes the following:
 * openssl#28098
 * openssl#28198
 * openssl#28398
 * openssl#28411
 * openssl#28449
 * openssl#28504
 * openssl#28535
 * openssl#28591
 * openssl#28624

Release: Yes
Signed-off-by: Eugene Syromiatnikov <[email protected]>
esyr added a commit to esyr/openssl that referenced this pull request Sep 30, 2025
3.2.6 CHANGES.md includes the following:
 * openssl#28098
 * openssl#28198
 * openssl#28398
 * openssl#28411
 * openssl#28449
 * openssl#28504
 * openssl#28535
 * openssl#28591
 * openssl#28603
 * openssl#28624
 * openssl#28642

3.2.6 NEWS.md do not have any updates.

Updated the changes and news in the previous branches.

Release: Yes
Signed-off-by: Eugene Syromiatnikov <[email protected]>
esyr added a commit to esyr/openssl that referenced this pull request Sep 30, 2025
3.3.5 CHANGES.md includes the following:
 * openssl#28098
 * openssl#28198
 * openssl#28398
 * openssl#28411
 * openssl#28449
 * openssl#28504
 * openssl#28535
 * openssl#28591
 * openssl#28603
 * openssl#28624
 * openssl#28642

3.3.5 NEWS.md do not have any updates.

Updated the changes and news in the previous branches.

Release: Yes
Signed-off-by: Eugene Syromiatnikov <[email protected]>
esyr added a commit to esyr/openssl that referenced this pull request Sep 30, 2025
3.4.3 CHANGES.md includes the following:
 * openssl#28098
 * openssl#28198
 * openssl#28398
 * openssl#28411
 * openssl#28415
 * openssl#28449
 * openssl#28504
 * openssl#28535
 * openssl#28591
 * openssl#28603
 * openssl#28624
 * openssl#28642

3.4.3 NEWS.md do not have any updates.

Updated the changes and news in the previous branches.

Release: Yes
Signed-off-by: Eugene Syromiatnikov <[email protected]>
esyr added a commit to esyr/openssl that referenced this pull request Sep 30, 2025
3.3.5 CHANGES.md includes the following:
 * openssl#28098
 * openssl#28198
 * openssl#28398
 * openssl#28411
 * openssl#28449
 * openssl#28504
 * openssl#28535
 * openssl#28591
 * openssl#28603
 * openssl#28624
 * openssl#28642

3.3.5 NEWS.md do not have any updates.

Updated the changes and news in the previous branches.

Release: Yes
Signed-off-by: Eugene Syromiatnikov <[email protected]>
esyr added a commit to esyr/openssl that referenced this pull request Sep 30, 2025
3.4.3 CHANGES.md includes the following:
 * openssl#28098
 * openssl#28198
 * openssl#28398
 * openssl#28411
 * openssl#28415
 * openssl#28449
 * openssl#28504
 * openssl#28535
 * openssl#28591
 * openssl#28603
 * openssl#28624
 * openssl#28642

3.4.3 NEWS.md do not have any updates.

Updated the changes and news in the previous branches.

Release: Yes
Signed-off-by: Eugene Syromiatnikov <[email protected]>
esyr added a commit to esyr/openssl that referenced this pull request Sep 30, 2025
3.2.6 CHANGES.md includes the following:
 * openssl#28098
 * openssl#28198
 * openssl#28398
 * openssl#28411
 * openssl#28449
 * openssl#28504
 * openssl#28535
 * openssl#28591
 * openssl#28603
 * openssl#28624
 * openssl#28642

3.2.6 NEWS.md do not have any updates.

Updated the changes and news in the previous branches.

Release: Yes
Signed-off-by: Eugene Syromiatnikov <[email protected]>
esyr added a commit to esyr/openssl that referenced this pull request Sep 30, 2025
3.0.18 CHANGES.md includes the following:
 * openssl#28098
 * openssl#28198
 * openssl#28398
 * openssl#28411
 * openssl#28449
 * openssl#28504
 * openssl#28535
 * openssl#28591
 * openssl#28624

Release: Yes
Signed-off-by: Eugene Syromiatnikov <[email protected]>
openssl-machine pushed a commit that referenced this pull request Sep 30, 2025
3.4.3 CHANGES.md includes the following:
 * #28198
 * #28398
 * #28411
 * #28415
 * #28449

Release: Yes
Signed-off-by: Eugene Syromiatnikov <[email protected]>

Reviewed-by: Neil Horman <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
openssl-machine pushed a commit that referenced this pull request Sep 30, 2025
3.3.5 CHANGES.md includes the following:
 * #28198
 * #28398
 * #28411
 * #28449

Release: Yes
Signed-off-by: Eugene Syromiatnikov <[email protected]>

Reviewed-by: Neil Horman <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
openssl-machine pushed a commit that referenced this pull request Sep 30, 2025
3.2.6 CHANGES.md includes the following:
 * #28198
 * #28398
 * #28411
 * #28449

Release: Yes
Signed-off-by: Eugene Syromiatnikov <[email protected]>

Reviewed-by: Neil Horman <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
openssl-machine pushed a commit that referenced this pull request Sep 30, 2025
3.0.18 CHANGES.md includes the following:
 * #28198
 * #28398
 * #28411
 * #28449

Release: Yes
Signed-off-by: Eugene Syromiatnikov <[email protected]>

Reviewed-by: Neil Horman <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approval: ready to merge The 24 hour grace period has passed, ready to merge branch: master Applies to master branch branch: 3.2 Applies to openssl-3.2 (EOL) branch: 3.3 Applies to openssl-3.3 branch: 3.4 Applies to openssl-3.4 branch: 3.5 Applies to openssl-3.5 branch: 3.6 Applies to openssl-3.6 tests: present The PR has suitable tests present triaged: bug The issue/pr is/fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Setting SKID/AKID to "none" in command-line tool gives invalid certificates

7 participants