Skip to content

DOC: improve X509_VERIFY_PARAM_set_flags.pod - #29150

Closed
DDvO wants to merge 7 commits into
openssl:masterfrom
siemens:improve_X509_VERIFY_PARAM_set_flags.pod
Closed

DDvO wants to merge 7 commits into
openssl:masterfrom
siemens:improve_X509_VERIFY_PARAM_set_flags.pod

Conversation

@DDvO

@DDvO DDvO commented Nov 14, 2025

Copy link
Copy Markdown
Contributor

Three doc-only commits carved out from #27357.

  • Add recommendation that TLS clients should use SSL_set_tlsext_host_name() for SNI
    and that this should be done jointly with using {SSL,X509_VERIFY_PARAM}_{set1,add1}_host().
  • fix doc of NULL param to X509_VERIFY_PARAM_set1_email() and X509_VERIFY_PARAM_set1{,_ip}()
  • remove heavily outdated texts on X509_V_FLAG_NO_ALT_CHAINS; other small fixes

@DDvO
DDvO requested a review from Copilot November 14, 2025 19:04
@DDvO DDvO added branch: master Applies to master branch approval: review pending This pull request needs review by a committer triaged: documentation The issue/pr deals with documentation (errors) tests: exempted The PR is exempt from requirements for testing labels Nov 14, 2025

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull Request Overview

This PR improves the documentation for X509_VERIFY_PARAM_set_flags.pod with three main enhancements:

  • Adds guidance on using X509_VERIFY_PARAM_set1_host() with SSL_set_tlsext_host_name() for TLS clients
  • Clarifies NULL parameter behavior for email, IP address, and hostname validation functions
  • Removes outdated information about X509_V_FLAG_NO_ALT_CHAINS from pre-OpenSSL 1.1.0

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread doc/man3/X509_VERIFY_PARAM_set_flags.pod Outdated

@esyr esyr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please review the notes about empty strings for email/ip/ipasc; the rest is just formatting nits and can be ignored.

Comment thread doc/man3/X509_VERIFY_PARAM_set_flags.pod Outdated
Comment thread doc/man3/X509_VERIFY_PARAM_set_flags.pod Outdated
Comment thread doc/man3/X509_VERIFY_PARAM_set_flags.pod Outdated
Comment on lines -314 to -322
The B<X509_V_FLAG_NO_ALT_CHAINS> flag could have been used before OpenSSL 1.1.0
to suppress checking for alternative chains.
By default, unless B<X509_V_FLAG_TRUSTED_FIRST> is set, when building a
certificate chain, if the first certificate chain found is not trusted, then
OpenSSL will attempt to replace untrusted certificates supplied by the peer
with certificates from the trust store to see if an alternative chain can be
found that is trusted.
As of OpenSSL 1.1.0, with B<X509_V_FLAG_TRUSTED_FIRST> always set, this option
has no effect.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would move this to a history section, so it's still possible to figure out what the code written against ancient OpenSSL version was trying to do.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point, done.

And restored the original doc line for X509_V_FLAG_NO_ALT_CHAINS, which I had changed in a wrong way due to a misunderstanding when doing commit ade0873.

X509_VERIFY_PARAM_set1_email() sets the expected RFC822 email address to
I<email>. If I<email> is NUL-terminated, I<emaillen> may be zero, otherwise
I<email>.
If I<email> is NULL or the empty string, email checking is disabled.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It doesn't seem to me that the current code sets the email field to NULL if an empty string is passed, and I don't see where a check is skipped against an empty e-mail, are you sure about this statement?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oh, right, email checking is disabled (by int_x509_param_set1() in crypto/x509/x509_vpn.c) only if email is NULL.

On this occasion, found and fixed a bug in the doc of the emaillen parameter
and for the namelen parameter of X509_VERIFY_PARAM_set1_host() .


X509_VERIFY_PARAM_set1_ip() sets the expected IP address to I<ip>.
The I<ip> argument is in binary format, in network byte-order and
If I<ip> is NULL or the empty string, IP address checking is disabled. Otherwise,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ditto here wrt empty string case.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yep, did the same fixes as above.

X509_VERIFY_PARAM_set1_ip_asc() sets the expected IP address to
I<ipasc>. The I<ipasc> argument is a NUL-terminal ASCII string:
X509_VERIFY_PARAM_set1_ip_asc() sets the expected IP address to I<ipasc>.
If I<ipasc> is NULL or the empty string, IP address checking is disabled.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ditto here; moreover, it is impossible to specify an incorrectly-formatted IP-address here (which, in accordance with ossl_a2i_ipadd(), empty string is).

@DDvO DDvO Dec 3, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Very true - here ipasc must not be NULL nor the empty string. Sorry for my mistakes.
Removed again the new sentence.

@DDvO
DDvO requested a review from esyr December 3, 2025 16:57
@DDvO

DDvO commented Dec 5, 2025

Copy link
Copy Markdown
Contributor Author

@esyr thank you for your helpful review.
I've recently handled all your comments.

Comment on lines +405 to +411
Until OpenSSL 1.1.0, by default (unless B<X509_V_FLAG_TRUSTED_FIRST> is set), when building a
certificate chain, if the first certificate chain found is not trusted, then
OpenSSL will attempt to replace untrusted certificates supplied by the peer
with certificates from the trust store to see if an alternative chain can be
found that is trusted.
As of OpenSSL 1.1.0, with B<X509_V_FLAG_TRUSTED_FIRST> always set, this option
has no effect.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The X509_V_FLAG_TRUSTED_FIRST can be still cleared, cannot it?

Suggested change
Until OpenSSL 1.1.0, by default (unless B<X509_V_FLAG_TRUSTED_FIRST> is set), when building a
certificate chain, if the first certificate chain found is not trusted, then
OpenSSL will attempt to replace untrusted certificates supplied by the peer
with certificates from the trust store to see if an alternative chain can be
found that is trusted.
As of OpenSSL 1.1.0, with B<X509_V_FLAG_TRUSTED_FIRST> always set, this option
has no effect.
Until OpenSSL 1.1.0, by default (unless B<X509_V_FLAG_TRUSTED_FIRST> was set), when building a
certificate chain, if the first certificate chain found was not trusted,
OpenSSL would attempt to replace untrusted certificates supplied by the peer
with certificates from the trust store to see if an alternative chain can be
found that is trusted.
Since OpenSSL 1.1.0 version, the B<X509_V_FLAG_TRUSTED_FIRST> is set by default.

@DDvO DDvO Dec 5, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point - here I did not question the contents of the existing doc but just aimed at handling outdated version references, moving text to the history section where appropriate.

Yet I just had a look at the commit history:
Since commit 0daccd4, X509_V_FLAG_TRUSTED_FIRST is on by default, and it was documented that it cannot be disabled, but in commit f517911 this latter part was removed. I also see no reason why it should be impossible to clear it.

So changed this part as you suggested, and also did a similar change further up,
from
When B<X509_V_FLAG_TRUSTED_FIRST> is set, which is always the case
to
When B<X509_V_FLAG_TRUSTED_FIRST> is set, which is the default

@DDvO
DDvO requested a review from t8m December 5, 2025 21:22
DDvO added 6 commits December 22, 2025 19:25
…_PARAM_set1_host() and SSL_set_tlsext_host_name()
… on X509_V_FLAG_NO_ALT_CHAINS; other small fixes
…d texts on X509_V_FLAG_NO_ALT_CHAINS; other small fixes
…_PARAM_set1_email() and X509_VERIFY_PARAM_set1{,_ip}()
…_VERIFY_PARAM_set1_email() and X509_VERIFY_PARAM_set1{,_ip}()
@DDvO
DDvO force-pushed the improve_X509_VERIFY_PARAM_set_flags.pod branch from 7288aec to 5b32bc1 Compare December 22, 2025 18:25
@DDvO

DDvO commented Dec 22, 2025

Copy link
Copy Markdown
Contributor Author

Rebased on latest master

@DDvO

DDvO commented Jan 2, 2026

Copy link
Copy Markdown
Contributor Author

@esyr @t8m ok now?

esyr
esyr previously approved these changes Jan 5, 2026

@esyr esyr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, thank you!

Comment thread doc/man3/X509_VERIFY_PARAM_set_flags.pod Outdated
…to X509_VERIFY_PARAM_set1_email() and X509_VERIFY_PARAM_set1{,_ip}()
@t8m t8m 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 Jan 6, 2026
@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 Jan 7, 2026
@openssl-machine

Copy link
Copy Markdown
Collaborator

This pull request is ready to merge

openssl-machine pushed a commit that referenced this pull request Jan 8, 2026
…_PARAM_set1_host() and SSL_set_tlsext_host_name()

Reviewed-by: Eugene Syromiatnikov <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
MergeDate: Thu Jan  8 09:56:12 2026
(Merged from #29150)
openssl-machine pushed a commit that referenced this pull request Jan 8, 2026
…9_V_FLAG_NO_ALT_CHAINS; other small fixes

Reviewed-by: Eugene Syromiatnikov <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
MergeDate: Thu Jan  8 09:56:14 2026
(Merged from #29150)
openssl-machine pushed a commit that referenced this pull request Jan 8, 2026
…_PARAM_set1_email() and X509_VERIFY_PARAM_set1{,_ip}()

Reviewed-by: Eugene Syromiatnikov <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
MergeDate: Thu Jan  8 09:56:15 2026
(Merged from #29150)
@t8m

t8m commented Jan 8, 2026

Copy link
Copy Markdown
Member

Merged to the master branch. Thank you for your contribution.

@t8m t8m closed this Jan 8, 2026
bob-beck pushed a commit to bob-beck/openssl that referenced this pull request Feb 24, 2026
…_PARAM_set1_host() and SSL_set_tlsext_host_name()

Reviewed-by: Eugene Syromiatnikov <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
MergeDate: Thu Jan  8 09:56:12 2026
(Merged from openssl#29150)
bob-beck pushed a commit to bob-beck/openssl that referenced this pull request Feb 24, 2026
…9_V_FLAG_NO_ALT_CHAINS; other small fixes

Reviewed-by: Eugene Syromiatnikov <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
MergeDate: Thu Jan  8 09:56:14 2026
(Merged from openssl#29150)
bob-beck pushed a commit to bob-beck/openssl that referenced this pull request Feb 24, 2026
…_PARAM_set1_email() and X509_VERIFY_PARAM_set1{,_ip}()

Reviewed-by: Eugene Syromiatnikov <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
MergeDate: Thu Jan  8 09:56:15 2026
(Merged from openssl#29150)
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 tests: exempted The PR is exempt from requirements for testing triaged: documentation The issue/pr deals with documentation (errors)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants