Commit Graph

2096 Commits

Author SHA1 Message Date
Dirkjan Ochtman ad9cbd337a Change DistinguishedName data 2023-04-28 22:53:52 +02:00
Dirkjan Ochtman 2920b4584c Inline newtype macro for DistinguishedName 2023-04-28 22:34:09 +02:00
Daniel McCarney 60cfb9b4cf conn: ensure complete_io flushes pending writes.
Previously, calls to `complete_io()` may return as if handshaking has
completed, but leave pending TLS writes queued that won't be sent until
a subsequent call to `complete_io()` is made.

This happens because `is_handshaking()` can begin to return false after
calls to `process_new_packets()` while there are final handshake packets
put in the connection's buffers, but not yet extracted to be sent to the
peer.

The end result is that calling `complete_io()` once is not
sufficient to fully complete a handshake with a peer. A second call
was required to flush the pending packets.

In this commit the `complete_io()` logic is updated to continue
processing IO when calling `process_new_packets()` has queued TLS
writes, only returning to the caller when all pending IO has been dealt
with and the handshake truly completed.

We can test this behaviour by updating the
`client_complete_io_for_handshake` and
`server_complete_io_for_handshake` unit tests to assert there are no
pending TLS writes after calling `complete_io()`. Prior to this commit
these assertions would fail, and with the updated logic they pass as
expected.
2023-04-17 17:20:39 +02:00
Daniel McCarney ce933bb3c1 docs: replace dead Ring link from README.
Previously we linked to the *ring* README to describe Ring's supported
architectures in more detail. Unfortunately that section of the upstream
README was removed without a replacement.

This commit emphasizes that while Rustls is platform independent, *ring*
is not. To replace the detailed platform support information we now link
directly to the relevant *ring* CI configuration for the version in use
by Rustls.
2023-04-14 15:41:54 +02:00
Dirkjan Ochtman 4c973b6b10 Drop log messages on error paths 2023-04-13 22:37:25 +02:00
Dirkjan Ochtman 86719f80ae Inline trivial alert helper functions 2023-04-13 22:37:25 +02:00
Dirkjan Ochtman aecd933af7 Clarify that sending a fatal alert always yields an error 2023-04-13 22:37:25 +02:00
Daniel McCarney 5c81497d79
docs: fix broken link in ClientCertVerifier docs. (#1270)
Previously the `ClientCertVerifier` rust docs had a broken link to the
`Error::InvalidCertificate(CertificateError::BadEncoding)` type.

This commit breaks up the link into two parts, one for the
`Error::InvalidCertificate` variant and one for the
`CertificateError::BadEncoding` variant.
2023-04-03 10:56:58 -04:00
Steven Fackler b0d5766a25 Update PrivateKey docs to note Sec1 support
Sec1 has been supported since #998.
2023-04-03 09:34:51 +02:00
dependabot[bot] 462eaeafe5 build(deps): update webpki-roots requirement from 0.22 to 0.23
Updates the requirements on [webpki-roots](https://github.com/rustls/webpki-roots) to permit the latest version.
- [Release notes](https://github.com/rustls/webpki-roots/releases)
- [Commits](https://github.com/rustls/webpki-roots/commits)

---
updated-dependencies:
- dependency-name: webpki-roots
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-03 08:57:39 +02:00
Daniel McCarney 5105cc29ac handshake: show illegal SNI hostname as lossy str.
Previously when an illegal SNI hostname was received rustls would
`warn!` the received value as a raw `Vec<u8>`, making it hard for
a human to read the value received.

This commit changes to `warn!` the `from_utf8_lossy` string version of
the hostname. This will make it easier for end users to diagnose the
root cause.
2023-03-30 22:16:43 +02:00
Dennis Collinson a0501e492a Document 1.57 as min supported version in README 2023-03-30 06:40:54 +02:00
Daniel McCarney 0b380942ca
docs: remove future release notes. (#1265)
This commit removes two "Future release" items from the release history
section of the README.

It seems clearer to have this section dedicated to the release history,
not upcoming work. I also think the two described pieces of work might
not be what the project is currently prioritizing.
2023-03-29 14:22:55 -04:00
Daniel McCarney 13e4390906
docs: tidy README for 0.21.0 release. (#1264)
* docs: fix 0.21.0 description

* docs: move 0.20.x notes to RELEASE_NOTES.md
2023-03-29 13:57:16 -04:00
Dirkjan Ochtman 45197b807c Bump version number to 0.21.0 2023-03-29 18:32:10 +01:00
Dirkjan Ochtman 785675b8c7 Update note regarding stability 2023-03-29 18:32:10 +01:00
Dirkjan Ochtman d7be326b76 Update changelog in preparation for 0.21.0 2023-03-29 18:32:10 +01:00
Dirkjan Ochtman 8a2a87b240 client: use type + builder pattern for resumption config API
Originally developed in #1259.

Co-authored-by: Daniel McCarney <daniel@binaryparadox.net>
Co-authored-by: Jacob Hoffman-Andrews <github@hoffman-andrews.com>
2023-03-29 18:08:27 +01:00
Dirkjan Ochtman 2ac21fb684 bench: remove Resumption to ResumptionParam 2023-03-29 18:08:27 +01:00
Dirkjan Ochtman 39402e1564 client: replace enable_tickets option with tls12_resumption 2023-03-29 18:08:27 +01:00
Dirkjan Ochtman 326122c9ff client: format comment to make it more readable 2023-03-29 18:08:27 +01:00
Dirkjan Ochtman 759ecfa5dd client: avoid passing duplicate state to prepare_resumption() 2023-03-29 18:08:27 +01:00
Dirkjan Ochtman 0b748d4b9d client: encapsulate client hello input state 2023-03-29 18:08:27 +01:00
Dirkjan Ochtman d83a6e7ea1 Rename SessionID to SessionId 2023-03-29 18:08:27 +01:00
Dirkjan Ochtman af90cf93e5 client: simplify and centralize SessionID setup 2023-03-29 18:08:27 +01:00
Dirkjan Ochtman 4945e4cd43 client: inline single-use expression 2023-03-29 18:08:27 +01:00
Dirkjan Ochtman e826a2dc0f Reduce CIFuzz timeout to 300s
In #862, we added CIFuzz integration. This is great, but it runs until a
specific timeout (currently 600s), in addition to needing about 6 minutes
of setup time. This is more than 3 times as long as the next longest CI job
(coverage took about 4m in #1242 just now). Given that we already have
OSS-Fuzz spending quite a bit of time running fuzzing for us and that (as
far as I remember) we have yet to find any issues from the CIFuzz integration,
I feel safe reducing the runtime for CIFuzz to 150s. This should still cover
quite a bit of ground given that we're executing pretty fast Rust code.
2023-03-29 15:02:59 +02:00
Dirkjan Ochtman 8a553cdc94 Remove deprecated type aliases 2023-03-29 11:00:31 +02:00
Jacob Hoffman-Andrews 171a3431f7 document secret_extraction feature flag 2023-03-29 09:56:43 +02:00
Daniel McCarney 572992fbf6 client/hs: ignore some aggressive clippy warnings.
This commit adds two `allow` directives for clippy warnings present when
building with `--no-default-features`:

1. Ignore `clippy::unnecessary_lazy_evaluations` for `find_session`. The
   suggestion to use `or` instead of `or_else` to avoid unnecessary lazy
   evaluation breaks a unit test
   (`test_client_tls12_no_resume_after_server_downgrade`).

2. Ignore `clippy::bind_instead_of_map` for `handle`. The suggestion to
   use `map` doesn't play well with the inner `match` that has a `None`
   arm for TLS 1.2 feature builds.
2023-03-29 09:20:33 +02:00
Daniel McCarney 770fefe749 CI: clippy coverage for `--no-default-features`.
Previously we ran clippy (both stable and nightly) only for
`--all-features` builds. This allows warnings specific to
`--no-default-features` to slip by.

This commit adds clippy invocations that build w/
`--no-default-features` so we can catch warnings specific to this
configuration during CI.
2023-03-29 09:20:33 +02:00
Daniel McCarney aaa3e46974 msgs: gate `ClientSessionCommon` on "tls12".
The `common` field of the `Tls12ClientSessionValue` type is only used
when the "tls12" feature is enabled.

To avoid an unused clippy err and to reduce the size of the struct when
not using TLS1.2 this commit feature-gates the field on "tls12".
2023-03-29 09:20:33 +02:00
Jacob Hoffman-Andrews 4692efddde OwnedTrustAnchor: subject is a DistinguishedName
Store the subject field as the DistinguishedName type, and also return
&DistinguishedName from subject().
2023-03-29 09:18:40 +02:00
Jacob Hoffman-Andrews 68175636b9 RootCertStore: remove deprecated subjects() 2023-03-29 09:18:40 +02:00
Jacob Hoffman-Andrews 9f7df8bd61 ClientCertVerifier: return &[DistinguishedNames]
This removes a requirement that an implementation of ClientCertVerifier
produce a fresh Vec of acceptable root Subjects on each call. Instead,
the ClientCertVerifier can store a list of acceptable root subjects and
return references to it, which seems like the most common use case by far.
2023-03-29 09:18:40 +02:00
Jacob Hoffman-Andrews 871a4c7f98 ClientCertVerifier: remove "abort connection" return values
For client_auth_mandatory and client_auth_root_subjects, it was possible
to return None to abort the connection. With the removal of the `sni`
input parameter, this no longer makes sense, so remove the
Option-wrapping of these return values.
2023-03-29 09:18:40 +02:00
Daniel McCarney 6d77d0220f anchors: tweak rustdoc comment about malformed roots.
The previous comment added to `RootCertStore.add` pointing out the
existence of `add_parsable_certificates` didn't offer enough clarity
around when to prefer `add` vs `add_parsable_certificates`. This commit
tweaks the language further based on review feedback.
2023-03-29 08:54:59 +02:00
Daniel McCarney 4d0c0dfbbb CI: test examples with --no-default-features.
Previously the example directories weren't being tested with
`--no-default-features`, letting bitrot affect those configurations.

This commit includes those directories in the `--no-default-features`
task that run `cargo test`.
2023-03-28 20:44:06 +02:00
Daniel McCarney cc80bebb64 examples: make logging mandatory.
This commit simplifies the examples sub project to make logging
mandatory instead of an optional feature flag.

In general this is easier to reason about for small example code, and it
resolves a build error that was present when building w/
`--no-default-features` due to the unconditional use of the `log` crate.
2023-03-28 20:44:06 +02:00
Jacob Hoffman-Andrews cad6b729ba error: restore PartialEq implementation
Previously this was removed when adding `Arc<dyn StdError>` as an enum
field for CertificateError, which made it impossible to automatically
derive PartialEq for the whole enum. Trait objects (dyn Trait) don't
implement PartialEq.

However, we can get back PartialEq on the whole Error struct by manually
implementing it for CertificateError, considering `Other` values to
never be equal.
2023-03-28 09:26:47 +02:00
Jacob Hoffman-Andrews 0892d019f9 Revert "Remove `PartialEq` from `rustls::Error`"
This reverts commit 00d7ac50f9.
2023-03-28 09:26:47 +02:00
Dirkjan Ochtman b415ebd014 client: stricter logic for resuming protocol versions 2023-03-27 10:07:52 +02:00
Dirkjan Ochtman c93ef1ad04 client: extract check for cipher suite match 2023-03-27 10:07:52 +02:00
Dirkjan Ochtman 92872f16d7 client: extract check for TLS 1.2 cipher suite 2023-03-27 10:07:52 +02:00
Dirkjan Ochtman a61e492447 client: extract check for 1.3 resumption 2023-03-27 10:07:52 +02:00
Dirkjan Ochtman 6906958210 client: check for empty tickets up front 2023-03-27 10:07:52 +02:00
Dirkjan Ochtman 0f5feb1335 client: check enabled_tickets up front 2023-03-27 10:07:52 +02:00
Dirkjan Ochtman 90a9fcbf5c client: extract resumption logic into function 2023-03-27 10:07:52 +02:00
Dirkjan Ochtman 9ab016742c client: rename fill_in_binder to tls13_session 2023-03-27 10:07:52 +02:00
Dirkjan Ochtman 66a7da9821 client: simplify ClientSessionValue API 2023-03-27 10:07:52 +02:00