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

Working towards nginx support #12

Merged
merged 29 commits into from
Apr 25, 2024
Merged

Working towards nginx support #12

merged 29 commits into from
Apr 25, 2024

Conversation

ctz
Copy link
Member

@ctz ctz commented Apr 23, 2024

This PR demonstrates nginx (1.18.0-6ubuntu14.4) support working.

The testing is very light; there is notably zero coverage of TLS downstreams (ie, nginx acting as a TLS client). The ideal for testing would be to get the nginx test suite (at least suites with names starting ssl) to pass. However, that seems a few steps away from here.

Things this PR leaves undone:

  • the "external" session resumption interface (with callbacks) that nginx uses to support session storage in shared memory between worker processes
  • client auth

@ctz ctz force-pushed the jbp-nginx-support branch from fdb585d to 03bf984 Compare April 23, 2024 16:41
@ctz ctz marked this pull request as ready for review April 23, 2024 16:44
Copy link
Member

@cpu cpu left a comment

Choose a reason for hiding this comment

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

I'll pick this up again tomorrow but thought I might as well share the comments I had from the first small chunk (I stopped after the first 5 commits this go).

rustls-libssl/src/entry.rs Outdated Show resolved Hide resolved
rustls-libssl/src/entry.rs Outdated Show resolved Hide resolved
Comment on lines 1084 to 1086
OPENSSL_NPN_NO_OVERLAP
} else {
0
Copy link
Member

@cpu cpu Apr 23, 2024

Choose a reason for hiding this comment

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

This feels like it should be NPN_NO_OVERLAP in both cases 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

I have changed these all to NPN_NO_OVERLAP, and also cleared out and out_len for cases we can't write something sensible.

Entertainingly OpenSSL's versions explodes in the error cases we're dealing with here:

==281210== Invalid read of size 1
==281210==    at 0x48A1C8D: SSL_select_next_proto (in /usr/lib/x86_64-linux-gnu/libssl.so.3)

Copy link
Member

Choose a reason for hiding this comment

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

😨

rustls-libssl/src/entry.rs Show resolved Hide resolved
rustls-libssl/src/lib.rs Outdated Show resolved Hide resolved
rustls-libssl/src/callbacks.rs Outdated Show resolved Hide resolved
rustls-libssl/src/entry.rs Show resolved Hide resolved
Copy link
Member

@cpu cpu left a comment

Choose a reason for hiding this comment

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

Finished a pass through the rest of the commits. Nice work! A lot of the intermediate commits were stubs that were quick reviews.

I'm a little fuzzy on the ex_data portions and feel least confident in my review of that area, but I didn't see anything that gave me particular pause: just want to call that out as an area that could use more scrutiny in the future.

rustls-libssl/src/lib.rs Show resolved Hide resolved
rustls-libssl/src/entry.rs Show resolved Hide resolved
rustls-libssl/src/entry.rs Show resolved Hide resolved
rustls-libssl/src/error.rs Show resolved Hide resolved
rustls-libssl/MATRIX.md Show resolved Hide resolved
rustls-libssl/src/entry.rs Show resolved Hide resolved
rustls-libssl/src/lib.rs Outdated Show resolved Hide resolved
rustls-libssl/tests/runner.rs Outdated Show resolved Hide resolved
ctz added 26 commits April 25, 2024 15:22
Rework ALPN parsing to use an iterator.
Future callbacks will be necessary from rustls trait
implementations (like certificate verifier & session store callbacks).
For this reason, this commit introduces an indirect storage style for
obtaining the original *SSL object pointer.  This uses thread-local
storage.
(NPN was abandoned in 2011 and replaced with ALPN.)
`SSL_CTX_set_tlsext_servername_callback` is a define to
`SSL_CTX_callback_ctrl`.

`SSL_CTX_set_tlsext_servername_arg` is a define to
`SSL_CTX_ctrl`.
But don't actually implement the limit.

Justification: verifiers limiting the chain length is best
accomplished by _issuer_ certs instead specifying a path
length constraint, and/or not issuing valid but long chains.

Theoretically we could implement this inside `webpki`, or even
do it ourselves by supplying a `verify_path` callback to it.
We can definitely do these, but not for an MVP.
rustls currently could support these with stateless resumption.
Definitely could implement this with some conversions:
it is the same concept as `ClientCertVerifier::root_hint_subjects()`
This one seems unlikely.
We could implement this.
This just returns NULL forever, because rustls does not
do compression.  That's the same behaviour as OpenSSL built
with OPENSSL_NO_COMP.
Will be needed for verify callback support.
This provides:

- `SSL_CTX_set_min_proto_version`
- `SSL_CTX_set_max_proto_version`
- `SSL_CTX_get_min_proto_version`
- `SSL_CTX_get_max_proto_version`
- `SSL_set_min_proto_version`
- `SSL_set_max_proto_version`
- `SSL_get_min_proto_version`
- `SSL_get_max_proto_version`

(All of those functions are routed into `SSL_CTX_ctrl` & `SSL_ctrl`.)
ctz added 2 commits April 25, 2024 16:29
Later commits will implement this, and session resumption more
generally.
@ctz ctz force-pushed the jbp-nginx-support branch from 03bf984 to d345b47 Compare April 25, 2024 15:32
This uses the system nginx (assumed to be available) to start a
server, then grabs a small html file and a larger 5MB download
with the system curl (using system openssl).
@ctz ctz force-pushed the jbp-nginx-support branch from d345b47 to faff689 Compare April 25, 2024 15:35
@ctz ctz merged commit 2a089cb into main Apr 25, 2024
20 checks passed
@ctz ctz deleted the jbp-nginx-support branch April 25, 2024 15:50
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.

2 participants