Skip to content

Comments

Generalize and improve the HTTP client#10667

Merged
openssl-machine merged 2 commits intoopenssl:masterfrom
mpeylo:http_client_generalized
Feb 11, 2020
Merged

Generalize and improve the HTTP client#10667
openssl-machine merged 2 commits intoopenssl:masterfrom
mpeylo:http_client_generalized

Conversation

@DDvO
Copy link
Contributor

@DDvO DDvO commented Dec 20, 2019

This PR solves/implements #10271 as discussed there by
generalizing the HTTP client so far implemented mostly in crypto/ocsp/ocsp_ht.c.

The new HTTP client has become an independent libcrpyto module in crypto/http/ and

  • can handle any types of requests and responses (both ASN.1-encoded and plain)
  • does not include potentially busy loops when waiting for responses but
  • makes use of a new timeout mechanism integrated with socket-based BIO
  • supports the use of HTTP proxies and TLS, including HTTPS over proxies, via a callback
  • supports HTTP redirection via codes 301 and 302 for GET requests
  • returns more useful diagnostics in various error situations

I had to adapt - and was able to simplify and improve - hitherto uses of HTTP in
crypto/ocsp/, crypto/x509/x_all.c, apps/lib/apps.c, and apps/{ocsp,s_client,s_server}.c.
The new features will be used heavily by chunk 10 of the CMP contribution.
The various documentation, header, and meta files are updated accordingly.

@DDvO
Copy link
Contributor Author

DDvO commented Dec 20, 2019

I've aimed at not changing the existing OCSP-centric HTTP API, which was a challenge in itself.
I think/hope to have managed to keep the API of those functions documented so far,
yet I took the liberty to adapt the types of those functions that have been undocumented.
See the respective comments towards the end of include/openssl/http.h for details.

@DDvO DDvO changed the title Generalize the HTTP client Generalize and extend the HTTP client Dec 20, 2019
@DDvO DDvO changed the title Generalize and extend the HTTP client Generalize and improve the HTTP client Dec 20, 2019
@DDvO DDvO force-pushed the http_client_generalized branch from 96f66fa to cc8e700 Compare December 21, 2019 20:03
@kroeckx
Copy link
Member

kroeckx commented Dec 22, 2019 via email

Copy link
Contributor

@FdaSilvaYY FdaSilvaYY left a comment

Choose a reason for hiding this comment

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

Quick review, impressive work, IMHO. 👍

@DDvO DDvO force-pushed the http_client_generalized branch from 4de53ed to 81153fa Compare December 23, 2019 07:02
@DDvO
Copy link
Contributor Author

DDvO commented Dec 23, 2019

  • supports the use of HTTP proxies and TLS, including HTTPS over proxies
    Does that mean libcrypto now depends on libssl?

No (and if it did, this would mean a mutual dependency).
I solved this challenge via the callback OSSL_HTTP_bio_cb_t bio_update_fn.
See the new doc (https://github.com/mpeylo/cmpossl/blob/http_client_generalized/doc/man3/OSSL_HTTP_transfer.pod) for details.
An instance of the callback is defined, e.g., in apps/lib/apps.c, where libssl is available.

Does that work on all platforms?

I believe so (but haven't tried this out).
The adapted/extended code does not make (new) use of platform-specific facilities.

@DDvO
Copy link
Contributor Author

DDvO commented Dec 23, 2019

Quick review, impressive work, IMHO. +1

Thanks!

This PR is the result of a really large amount of work that stretched over 2+ years.

@DDvO
Copy link
Contributor Author

DDvO commented Dec 23, 2019

BTW, part of this work dates back to an issue I brought up in late Aug 2017:
https://mta.openssl.org/pipermail/openssl-dev/2017-August/009629.html

@DDvO
Copy link
Contributor Author

DDvO commented Dec 23, 2019

Does that mean libcrypto now depends on libssl?

As a side note: this touches a long-standing structural deficiency in the OpenSSL libs.
The crypto lib includes various modules that do not really belong there but
should be part of a more application-level library that should be above libssl.

See also #4992 and my original report and solution suggestion dating back to May 2016:
https://mta.openssl.org/pipermail/openssl-dev/2017-September/009712.html

This PR does not attempt to solve that fundamental issue but needs to work around it.

@DDvO
Copy link
Contributor Author

DDvO commented Jan 8, 2020

Thanks for the initial comments on this generalized HTTP implementation given more than two weeks ago, which I answered.

Ping - can someone please do a formal review?

@DDvO DDvO force-pushed the http_client_generalized branch from 7a70ce6 to abd6ffa Compare January 15, 2020 17:13
@DDvO
Copy link
Contributor Author

DDvO commented Jan 15, 2020

@levitte, in early November you had given some initial remarks on a preview of this PR and showed interest in having a closer look at this code: #10271 (comment)
When do you think you can do a review?

@DDvO
Copy link
Contributor Author

DDvO commented Jan 16, 2020

@mattcaswell, very pleased to receive your comments!
I've addressed all of them.

@DDvO DDvO force-pushed the http_client_generalized branch 2 times, most recently from 6d71759 to a333fdf Compare January 20, 2020 16:08
@DDvO
Copy link
Contributor Author

DDvO commented Jan 21, 2020

I've meanwhile rebased this PR and Travis has recovered from an intermittent timeout issue that occurred yesterday, so it's is up and running again.

@DDvO
Copy link
Contributor Author

DDvO commented Jan 21, 2020

@mattcaswell, when can you check if the changes I did on your request are acceptable for you,
and do you plan to provide further comments for this PR?

Copy link
Member

@mattcaswell mattcaswell left a comment

Choose a reason for hiding this comment

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

A couple of questions and a minor nit. Otherwise this looks good.

@DDvO
Copy link
Contributor Author

DDvO commented Jan 23, 2020

A couple of questions and a minor nit. Otherwise this looks good.

@mattcaswell, pleased to hear!
I've fulfilled also the new change request(s).

@DDvO
Copy link
Contributor Author

DDvO commented Feb 11, 2020

I'd also have a few additions / corrections to two README files there.

@mattcaswell
Copy link
Member

Can I do a PR to [email protected]:tools.git instead?

Yes, that's the preferred way to do things.

And how is the review process for adaptations to the tools repo?

At the moment its an OMC owned repo, so reviews/pushes can only be done by OMC members.

@mattcaswell
Copy link
Member

At the moment its an OMC owned repo, so reviews/pushes can only be done by OMC members.

BTW, I see no reason why tools like ghmerge and addrev shouldn't be owned by OTC rather than OMC...but at the moment they're not.

@paulidale
Copy link
Contributor

Anyone can make a pull request against the tools repository.
The review process requires two OMC approvers currently.

@paulidale
Copy link
Contributor

BTW, I see no reason why tools like ghmerge and addrev shouldn't be owned by OTC rather than OMC...but at the moment they're not.

Agreed.

@DDvO
Copy link
Contributor Author

DDvO commented Feb 11, 2020

@mattcaswell
Copy link
Member

Oops. Looks like this broke Travis:

https://travis-ci.org/openssl/openssl/jobs/648882003

This is actually the new travis job introduced by #9982. Since that job went into master slightly after this PR went in, but this PR was committed after the last travis run for #9982 was performed this problem didn't show up in either PRs.

@DDvO
Copy link
Contributor Author

DDvO commented Feb 11, 2020

I'm trying to reproduce and fix this...

@DDvO
Copy link
Contributor Author

DDvO commented Feb 11, 2020

I found this happens due to configuration options no-cmp and no-ocsp.
The former was trivial to fix, now I'm looking for a good solution for the latter...

@DDvO
Copy link
Contributor Author

DDvO commented Feb 11, 2020

Luckily, also the fix for no-ocsp was not difficult.

@DDvO
Copy link
Contributor Author

DDvO commented Feb 12, 2020

Fixup PR #11058 has been merged.

DDvO added a commit to siemens/openssl that referenced this pull request Mar 23, 2020
openssl-machine pushed a commit that referenced this pull request Apr 20, 2020
…since #10667

Reviewed-by: Dmitry Belyavskiy <[email protected]>
Reviewed-by: Matt Caswell <[email protected]>
(Merged from #11273)
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants