Skip to content

Simplify X.509 extension handling code#1855

Merged
alex merged 2 commits intomasterfrom
alex-patch-1
Jun 6, 2017
Merged

Simplify X.509 extension handling code#1855
alex merged 2 commits intomasterfrom
alex-patch-1

Conversation

@alex
Copy link
Copy Markdown
Member

@alex alex commented May 29, 2017

The previous implementation had grown organically over time, as OpenSSL's API evolved.

The previous implementation had grown organically over time, as OpenSSL's API evolved.
@mention-bot
Copy link
Copy Markdown

@alex, thanks for your PR! By analyzing the history of the files in this pull request, we identified @serhiy-storchaka, @tiran and @giampaolo to be potential reviewers.

@alex alex added the trivial label May 29, 2017
@alex
Copy link
Copy Markdown
Member Author

alex commented May 29, 2017

Windows failures don't appear to be relevant.

@serhiy-storchaka serhiy-storchaka requested a review from tiran May 29, 2017 15:58
Comment thread Modules/_ssl.c
certificate, NID_subject_alt_name, i)) >= 0) {

names = (GENERAL_NAMES *)X509_get_ext_d2i(
certificate, NID_subject_alt_name, NULL, NULL);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Do we care about handling the case where there is > 1 SAN extension? Right now this will return the first one found and use it, but if there is > 1 we should really just error out.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

None of the other X.509 extension handlers attempt to handle this; we just defer to OpenSSL's behavior.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I think this actually Does The Right Thing, the docs are just profoundly awful:

"If idx is NULL then only one occurrence of an extension is permissible otherwise the first extension after index *idx is returned and *idx updated to the location of the extension. If crit is not NULL then *crit is set to a status value: -2 if the extension occurs multiple times (this is only returned if idx is NULL), -1 if the extension could not be found, 0 if the extension is found and is not critical and 1 if critical. A pointer to an extension specific structure or NULL is returned."

@tiran
Copy link
Copy Markdown
Member

tiran commented Jun 4, 2017

@alex is your patch compatible with historic versions of OpenSSL? Or should we wait until we officially drop support for 1.0.1 and 0.9.8?

@alex
Copy link
Copy Markdown
Member Author

alex commented Jun 4, 2017

@tiran yes, this works with all supported versions of OpenSSL -- we use this same API in the other extension parsing code.

Copy link
Copy Markdown
Member

@tiran tiran left a comment

Choose a reason for hiding this comment

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

You know what you are doing.

@alex alex merged commit b87c0df into master Jun 6, 2017
@alex alex deleted the alex-patch-1 branch June 6, 2017 11:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants