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

Basic server support #7

Merged
merged 19 commits into from
Apr 15, 2024
Merged

Basic server support #7

merged 19 commits into from
Apr 15, 2024

Conversation

ctz
Copy link
Member

@ctz ctz commented Apr 10, 2024

This is a collection of bug-fixes and server groundwork from the nginx branch. Along the way, client auth starts to work & is tested.

At the end of this branch the basic test of server behaviour tests/server.c is passing.

Requiring use of `Bio::new_pair(Some(a), Some(a))` to donate
two refs of `a` is not what is required by `SSL_set_bio`.
Instead make an object backed by `BIO_s_null()`, and then call
`update()` on it.
@ctz ctz force-pushed the jbp-basic-server-support branch from ebed86a to 9c13e8e Compare April 10, 2024 16:21
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.

Here's some initial feedback. I started my review later in the day and lost steam by around "Implement SSL_accept and associated server support". I'll come back and do a second pass starting from there in the next day or so.

rustls-libssl/src/bio.rs Show resolved Hide resolved
rustls-libssl/src/bio.rs Show resolved Hide resolved
rustls-libssl/src/entry.rs Outdated Show resolved Hide resolved
rustls-libssl/src/entry.rs Outdated Show resolved Hide resolved
rustls-libssl/src/entry.rs Show resolved Hide resolved
rustls-libssl/src/x509.rs Outdated Show resolved Hide resolved
rustls-libssl/src/x509.rs Outdated Show resolved Hide resolved
rustls-libssl/src/error.rs Outdated Show resolved Hide resolved
rustls-libssl/src/entry.rs Outdated Show resolved Hide resolved
rustls-libssl/src/lib.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.

Finishing up where I left off in the first pass. Thanks!

rustls-libssl/src/lib.rs Outdated Show resolved Hide resolved
rustls-libssl/src/lib.rs Outdated Show resolved Hide resolved
rustls-libssl/src/lib.rs Outdated Show resolved Hide resolved
rustls-libssl/src/lib.rs Outdated Show resolved Hide resolved
rustls-libssl/src/verifier.rs Outdated Show resolved Hide resolved
rustls-libssl/src/verifier.rs Outdated Show resolved Hide resolved
rustls-libssl/tests/runner.rs Show resolved Hide resolved
rustls-libssl/tests/server.c Outdated Show resolved Hide resolved
rustls-libssl/src/entry.rs Show resolved Hide resolved
ctz added 2 commits April 12, 2024 15:22
We mishandled non-blocking writes in several respects:

- `SSL_get_error()` would say to retry the read if the write BIO
  was the same as the read BIO.
- raise the correct `io::Error` in `impl io::Write for Bio`.
- the current IO `Want` was was ignored: give `Want::write` primacy
  because rustls tends to always want to read in idle conditions
  (for alert receipt).
@ctz ctz force-pushed the jbp-basic-server-support branch from 9c13e8e to 0b6fc8b Compare April 12, 2024 17:04
ctz added 15 commits April 15, 2024 13:55
Because `SSL_CTX_use_PrivateKey` implies we have to use an `EVP_PKEY` as-is,
`evp_pkey.rs` implements a wrapper over OpenSSL `EVP_PKEY`s, and `sign.rs`
uses that wrapper to implement `rustls::sign::SigningKey` and `Signer` traits.
These should not be put on the openssl error stack, and should not
be logged either.
Engineer a typical case: the server requires auth, but the client
has no credentials.

To make this work:

- match `SSL_read` return code (docs say <= 0, implementation does 0,
  we chose -1 previously).
- print (and therefore validate against openssl) ERR_peek_error().
- ensure the error from rustls is the one that is propagated
  (by retrieving it from `process_new_packets()`) rather than one
  already wrapped in `std::io::Error`.
"SSL_set_SSL_CTX is a bad idea" says the openssl issue tracker :)
This is for new APIs around alerts from server `Acceptor`.
@ctz ctz force-pushed the jbp-basic-server-support branch from 0b6fc8b to 0a50edf Compare April 15, 2024 12:55
@ctz ctz merged commit d942be0 into main Apr 15, 2024
20 checks passed
@ctz ctz deleted the jbp-basic-server-support branch April 15, 2024 14:41
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