Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMP: fix flag indicating the use of SSL/TLS for client-side HTTP connections #21176

Closed
wants to merge 5 commits into from

Conversation

DDvO
Copy link
Contributor

@DDvO DDvO commented Jun 11, 2023

  • CMP: fix OSSL_CMP_MSG_http_perform() by adding option OSSL_CMP_OPT_USE_TLS
  • OSSL_CMP_CTX_new.pod: remove overlap with OSSL_HTTP_transfer.pod; improve the latter
  • apps/cmp.c: -tls_used may be implied by -server https:...; improve related checks and doc

Fixes #21120

Checklist
  • documentation is added or updated
  • tests are added or updated

@DDvO DDvO added approval: review pending This pull request needs review by a committer approval: otc review pending This pull request needs review by an OTC member triaged: bug The issue/pr is/fixes a bug triaged: documentation The issue/pr deals with documentation (errors) branch: 3.0 Merge to openssl-3.0 branch branch: 3.1 Merge to openssl-3.1 tests: present The PR has suitable tests present labels Jun 11, 2023
@DDvO DDvO added this to the 3.2.0 milestone Jun 11, 2023
@DDvO
Copy link
Contributor Author

DDvO commented Jun 12, 2023

The two CI failures are unrelated.

@t8m
Copy link
Member

t8m commented Jun 12, 2023

The two CI failures are unrelated.

Although unrelated the CMS failure looks really suspicious.

@DDvO DDvO force-pushed the fix_CMP_indication_HTTPS branch from 6f1df38 to 05d5e91 Compare June 12, 2023 07:26
@DDvO
Copy link
Contributor Author

DDvO commented Jun 12, 2023

The two CI failures are unrelated.

Although unrelated the CMS failure looks really suspicious.

I agree the failing CMS consistency tests on buildbot/master:unix-ubuntu-aarch64 looked suspicious,
but luckily this disappeared after I rebased to the latest master half an hour ago.

doc/man1/openssl-cmp.pod.in Outdated Show resolved Hide resolved
@DDvO DDvO requested a review from mattcaswell June 12, 2023 08:31
@mattcaswell mattcaswell removed the approval: otc review pending This pull request needs review by an OTC member label Jun 12, 2023
@t8m
Copy link
Member

t8m commented Jun 12, 2023

I do not think this is a bug fix. Also what if anyone is already depending on the existing behavior of having the callback implying TLS?

@DDvO
Copy link
Contributor Author

DDvO commented Jun 12, 2023

I do not think this is a bug fix.

As witnessed by #21120, the existing code has at least unexpected and undocumented behavior.
I see it as a bug because the use of the callback and its optional argument is needlessly limited to adding TLS (to the given CMP HTTP transfer).
If it is used in the CMP context for anything else, as can be done for the general (non-CMP) HTTP client, things go wrong as it is falsely assumed that TLS is being used (if the argument is non-NULL) or not being used (if the arg is NULL).

Also what if anyone is already depending on the existing behavior of having the callback implying TLS?

This is indeed a problem, but I'd say the risk is small because it's an advanced feature and the existing behavior is weird and not documented.

@DDvO
Copy link
Contributor Author

DDvO commented Jun 12, 2023

Also what if anyone is already depending on the existing behavior of having the callback implying TLS?

With this argument, we couldn't do any bug fixes because there might be someone who - for whatever strange reason - started relying on wrong behavior.

Copy link
Contributor

@tmshort tmshort left a comment

Choose a reason for hiding this comment

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

Just a clarification needed on server vs client use of OSSL_CMP_OPT_USE_TLS.

@@ -49,6 +49,7 @@ struct ossl_cmp_ctx_st {
int keep_alive; /* persistent connection: 0=no, 1=prefer, 2=require */
int msg_timeout; /* max seconds to wait for each CMP message round trip */
int total_timeout; /* max number of seconds an enrollment may take, incl. */
int tls_used; /* whether to use TLS for client-side HTTP connections */
Copy link
Contributor

Choose a reason for hiding this comment

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

Presumably, this is not just for clients? In apps/cmp.c the flag is set regardless of opt_server

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So far, tls_used is implemented for the client side only.
And as now stated in openssl-cmp.h.in:

It is ignored if the B<-server> option is not given

apps/cmp.c Outdated
Comment on lines 1894 to 1895
if (opt_tls_used)
(void)OSSL_CMP_CTX_set_option(ctx, OSSL_CMP_OPT_USE_TLS, 1);
Copy link
Contributor

Choose a reason for hiding this comment

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

If this option is for clients only, should there be a && opt_server == NULL here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could do that, but the option is anyway ignored in this case (with a warning).

If/when we later add TLS support to the server side, we would have to revert adding && opt_server == NULL.

@t8m
Copy link
Member

t8m commented Jun 12, 2023

Also what if anyone is already depending on the existing behavior of having the callback implying TLS?

With this argument, we couldn't do any bug fixes because there might be someone who - for whatever strange reason - started relying on wrong behavior.

The app code already did this, what if someone just mimicked it? Can you please try harder to make this backwards compatible?

For example this could be a new feature for 3.2 where the OP is OSSL_CMP_OPT_NO_TLS and it switches off the tls if the callback is in use.

@DDvO
Copy link
Contributor Author

DDvO commented Jun 12, 2023

Also what if anyone is already depending on the existing behavior of having the callback implying TLS?

With this argument, we couldn't do any bug fixes because there might be someone who - for whatever strange reason - started relying on wrong behavior.

The app code already did this, what if someone just mimicked it? Can you please try harder to make this backwards compatible?

For example this could be a new feature for 3.2 where the OP is OSSL_CMP_OPT_NO_TLS and it switches off the tls if the callback is in use.

Hmm, such a OSSL_CMP_OPT_NO_TLS option would only solve half of the problem.

Here is my proposal for a backward compatible solution:
define for the new OSSL_CMP_OPT_USE_TLS option a third value, namely -1, which is assumed by the default and means the hitherto behavior, where the callback function arg being non-NULL determines whether to use TLS.
When the OSSL_CMP_OPT_USE_TLS option is used and explicitly set to 0, TLS is not used, and when set to 1, TLS is used.

This way, the old behavior is by default, and explicitly setting the TLS leads to the expected new behavior.
Ok?

@t8m
Copy link
Member

t8m commented Jun 12, 2023

OK, but for master branch only.

@DDvO
Copy link
Contributor Author

DDvO commented Jun 12, 2023

OK, but for master branch only.

Good, but why not also for at least 3.0?
As mentioned, the hitherto behavior is weird and not documented.
Doing the backport with the new solution does not harm existing code
and gives users of the 3.0 LTS version both a to-the-point doc and the chance to do the TLS (de-)selection in a proper way.

@t8m
Copy link
Member

t8m commented Jun 12, 2023

I would not block merging it to 3.1 and 3.0 if someone else approves it, but in my opinion this is clearly a new feature, not a bug fix.

@DDvO DDvO requested review from tmshort and mattcaswell June 12, 2023 15:57
@DDvO DDvO added the approval: otc review pending This pull request needs review by an OTC member label Jun 12, 2023
@DDvO DDvO changed the title CMP: fix flag requiring the use of SSL/TLS for client-side HTTP connections CMP: fix flag indicating the use of SSL/TLS for client-side HTTP connections Jun 12, 2023
Copy link
Contributor

@tmshort tmshort left a comment

Choose a reason for hiding this comment

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

I'm ok with a back port to 3.1/3.0. Should this also be in master (not labeled for master, but the PR is on master)?

@tmshort tmshort removed the approval: review pending This pull request needs review by a committer label Jun 20, 2023
@DDvO DDvO added the branch: master Merge to master branch label Jun 20, 2023
@DDvO
Copy link
Contributor Author

DDvO commented Jun 20, 2023

I'm ok with a back port to 3.1/3.0. Should this also be in master (not labeled for master, but the PR is on master)?

Pleased to hear.
I simply forgot to tick the master label - done now.

@openssl-machine
Copy link
Collaborator

This PR is in a state where it requires action by @openssl/otc but the last update was 30 days ago

@DDvO
Copy link
Contributor Author

DDvO commented Aug 13, 2023

Ping @openssl/committers for 2nd review

@hlandau hlandau removed this from the 3.2.0 milestone Aug 31, 2023
@openssl-machine
Copy link
Collaborator

This PR is in a state where it requires action by @openssl/otc but the last update was 30 days ago

@DDvO
Copy link
Contributor Author

DDvO commented Oct 7, 2023

Pinging again @openssl/committers for 2nd review.

Copy link
Member

@t8m t8m left a comment

Choose a reason for hiding this comment

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

OK for the master branch only.

@t8m t8m added approval: done This pull request has the required number of approvals and removed approval: otc review pending This pull request needs review by an OTC member branch: 3.0 Merge to openssl-3.0 branch branch: 3.1 Merge to openssl-3.1 labels Oct 9, 2023
@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 Oct 10, 2023
@openssl-machine
Copy link
Collaborator

This pull request is ready to merge

@t8m
Copy link
Member

t8m commented Oct 10, 2023

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

@t8m t8m closed this Oct 10, 2023
openssl-machine pushed a commit that referenced this pull request Oct 10, 2023
…lated checks and doc

Reviewed-by: Todd Short <todd.short@me.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from #21176)
openssl-machine pushed a commit that referenced this pull request Oct 10, 2023
…rove the latter

Reviewed-by: Todd Short <todd.short@me.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from #21176)
openssl-machine pushed a commit that referenced this pull request Oct 10, 2023
…E_TLS

Fixes #21120

Reviewed-by: Todd Short <todd.short@me.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from #21176)
wanghao75 pushed a commit to openeuler-mirror/openssl that referenced this pull request Oct 16, 2023
…lated checks and doc

Reviewed-by: Todd Short <todd.short@me.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from openssl/openssl#21176)

Signed-off-by: fly2x <fly2x@hitls.org>
wanghao75 pushed a commit to openeuler-mirror/openssl that referenced this pull request Oct 16, 2023
…rove the latter

Reviewed-by: Todd Short <todd.short@me.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from openssl/openssl#21176)

Signed-off-by: fly2x <fly2x@hitls.org>
wanghao75 pushed a commit to openeuler-mirror/openssl that referenced this pull request Oct 16, 2023
…E_TLS

Fixes #21120

Reviewed-by: Todd Short <todd.short@me.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from openssl/openssl#21176)

Signed-off-by: fly2x <fly2x@hitls.org>
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 Merge to master branch tests: present The PR has suitable tests present triaged: bug The issue/pr is/fixes a bug triaged: documentation The issue/pr deals with documentation (errors)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Why is http_cb_arg used to determine whether to use tls in the CMP?
6 participants