Commit Graph

2012 Commits

Author SHA1 Message Date
Dirkjan Ochtman 0bcdf119c5 Bring back support for encoding/decoding client session values 2023-03-21 21:03:29 +01:00
Jacob Hoffman-Andrews a44d1669fd Move internal enums to public API
These enums (AlertDescription, ContentType, and HandshakeType) were
previously only available as part of the private API.  Eight months ago
we added a public reexport of their names, but did not remove the
private version to avoid semver breakage.

Now that we have a semver-incompatible version coming up we can move
these fully to the public API.
2023-03-21 19:45:18 +00:00
Dirkjan Ochtman 1538c460b8 Make ClientSessionValue private 2023-03-21 16:32:53 +01:00
Dirkjan Ochtman 0b0c7b7a9d Move persistence tests into persist module 2023-03-21 16:32:53 +01:00
Dirkjan Ochtman 67964a7deb Make Tls12ClientSessionValue::session_id private 2023-03-21 14:55:45 +01:00
Dirkjan Ochtman 8c7e9edde6 Make ClientSessionStore trait definition independent of Cargo features 2023-03-21 14:55:45 +01:00
Daniel McCarney fb9e181a1a CI: add fmt and clippy coverage for fuzz workspace.
The `fuzz` subdirectory is set up as a separate workspace from the main
workspace that contains `rustls` and `examples`. Because of this running
`cargo fmt --all` and other similar tooling doesn't include the `fuzz`
directory. This can lead to formatting/clippy drift over time.

In this commit the `build.yml` config is extended to also run `clippy`
and `fmt` on the `fuzz` subdirectory using `--manifest-path`.
2023-03-20 16:08:55 +01:00
Daniel McCarney 18f42bba16 fuzz: fix unused Result clippy finding.
```
warning: unused `std::result::Result` that must be used
  --> fuzzers/persist.rs:14:5
   |
14 |     T::read(&mut rdr);
   |     ^^^^^^^^^^^^^^^^^^
   |
   = note: `#[warn(unused_must_use)]` on by default
   = note: this `Result` may be an `Err` variant, which should be handled
```
2023-03-20 16:08:55 +01:00
Daniel McCarney ca5725747a fuzz: cargo fmt updates 2023-03-20 16:08:55 +01:00
dependabot[bot] bfe2f16c5a build(deps): bump actions/setup-go from 3 to 4
Bumps [actions/setup-go](https://github.com/actions/setup-go) from 3 to 4.
- [Release notes](https://github.com/actions/setup-go/releases)
- [Commits](https://github.com/actions/setup-go/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/setup-go
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-20 10:47:44 +01:00
Valeriy V. Vorotyntsev da6aeb7685 CONTRIBUTING.md: fix a broken link 2023-03-16 11:09:05 +01:00
Tomasz Pietrek 127b604f26 Bump webpki to 0.100.0
Signed-off-by: Tomasz Pietrek <tomasz@nats.io>
2023-03-16 11:08:51 +01:00
Daniel McCarney 1c22e6ff55 CI: configure Dependabot to monitor GitHub actions.
This commit updates the existing `.github/dependabot.yml` config that
monitors Cargo dependencies to also monitor GitHub actions (on a weekly
cadence).
2023-03-13 14:39:54 +01:00
Daniel McCarney ea64cc4f96 CI: update workflow actions, Go tooling.
To address a pending deprecation[0], and to remove CI warnings, this
commit:

* Updates `actions/checkout` from v2 -> v3.
* Updates `codecov/codecov-action` from v1.0.10 -> v3.
* Updates `actions/upload-artifact` from v1 -> v3.
* Updates `actions/setup-go` from v2 -> v3.

For the `setup-go` workflows in particular the Go version is also
updated 1.17.1 -> 1.20.

Additionally, since the `actions-rs` upstream workflows are
unmaintained[1] this commit replaces `actions-rs/toolchain` with
`dtolnay/rust-toolchain`, a well maintained alternative. Similarly,
usages of `actions-rs/cargo` are replaced with direct invocation of
`cargo`.

[0]: https://github.blog/changelog/2022-09-22-github-actions-all-actions-will-begin-running-on-node16-instead-of-node12/
[1]: https://github.com/actions-rs/toolchain/issues/216
2023-03-13 14:39:54 +01:00
zkonge 608b9ec3d6 Add more CertificateError, allow raise more detailed TLS alert.
* Revoked: raise CertificateRevoked alert
* InvalidPurpose: raise UnsupportedCertificate alert
* ApplicationVerificationFailure: raise AccessDenied alert
2023-03-11 13:36:57 +01:00
zkonge d196ef952a Add comment for puzzling error mapping. 2023-03-11 09:23:46 +01:00
zkonge 3d93300fda Avoid send TLS Alert twice in client verification 2023-03-11 09:23:46 +01:00
zkonge 044364aab8 Make server start using send_cert_verify_alert_error 2023-03-11 09:23:46 +01:00
zkonge 58b6774fca Provide more detailed alert from CertificateError
The new CertificateError to AlertDescription mapping is chosen based on:

* [rfc5246#A.3](https://www.rfc-editor.org/rfc/rfc5246#appendix-A.3)
* [RFC8446#B.2](https://www.rfc-editor.org/rfc/rfc8446#appendix-B.2)
* [OpenSSL Implementation](45bb98bfa2/ssl/statem/statem_lib.c (L1434))
* [BoringSSL Implementation](583c60bd4b/ssl/ssl_x509.cc (L1323))
2023-03-11 09:23:46 +01:00
zkonge 006d646e30 use HandshakeFailure by default in verification
Verification error is not always raised by bad certificate, especially
in user provided verifier. For example, they may raise HSM connection
error or dynamic certificate resolve error.

All of them is not about bad certificate. So send BadCertificateAlert is
not appropriate.
2023-03-11 09:23:46 +01:00
zkonge 843e6fc02a Move send_cert_error_alert from hs mod to conn mod
send_cert_error_alert could be shared between tls server and tls client.
2023-03-11 09:23:46 +01:00
bebecue 383c96afa4 ci: add test case `no default features; tls12` 2023-03-10 09:23:57 +01:00
bebecue 612ca38a99 fix: fail to compile with logging feature disabled 2023-03-10 09:23:57 +01:00
Daniel McCarney 38fdd952be feat: impl safer export_keyring_material interface.
Prior to this commit the `export_keyring_material` function used
a mutable out buffer for writing exported key material, and returned an
empty Ok result when there was no error doing so.

This commit updates the function such that the ownership of the output
buffer passes through the export function and is returned as the Ok
result when there is no error.

Doing this makes for a safer interface for end users: the output buffer
will be dropped if `export_keyring_material` errors. Callers can only
access the buffer again using the OK result.

All credit due to davidv1992 for the implementation idea and initial
code that was extended in this commit.
2023-03-08 16:26:38 +01:00
Dirkjan Ochtman 861e76d599 msgs: yield Result instead of Option from Reader/Codec 2023-03-06 22:17:08 +01:00
Dirkjan Ochtman 09260d8700 Clean up import style regressions from #1172 2023-03-06 22:17:08 +01:00
Dirkjan Ochtman 282d009d9e Revert incorrect rename in changelog 2023-03-06 22:17:08 +01:00
Daniel McCarney 25bc1b3ecd chore: delete admin/format-bench.
The `admin/format-bench` script has bitrot so that it no longer
functions with the current output produced by the benchmark tooling.

It's not clear that this tool is still needed, so rather than fix it or
port it to Rust, we choose to remove it outright.

If it turns out there is a need for formatting benchmarking output we
should consider building that into the benchmark tool itself to avoid
needing to deal with a Python tool-chain and associated versioning
challenges.
2023-03-03 22:08:14 +01:00
Daniel McCarney da19f2b069 docs: add small README for fuzz testing suite.
This commit adds a README to the `fuzz` subdirectory of the project
root. The README has a few small pointers to help a developer get
started running the fuzz tests locally, and a link to the upstream
cargo-fuzz docs for more information.
2023-03-03 19:08:13 +01:00
Daniel McCarney 841a374d64 chore: remove trytls shim and helper script.
The `trytls/runme` script has bitrot and doesn't function on systems
with up to date Python installations. The upstream project has Python
3.8+ compatibility issues and hasn't seen new commits in ~7 years.

Rustls has easier to maintain test coverage through
`examples/tests/badssl.rs` and the bogo test suite. For that reason this
commit removes the `trytls` scaffolding in favour of continuing to
maintain it.
2023-03-03 11:12:21 +01:00
Daniel McCarney 21244d736f docs: add rustdoc for DigitallySignedStruct.
The front-page index for the Rustls lib includes a list of re-exported
structs comprising the public API. Prior to this commit the
`handskae::DigitallySignedStruct` type was included in this list, but
lacked a rustdoc comment.

This commit adds a simple rustdoc comment for this type. Now all of the
structs mentioned in the front-page index have some documentation.
2023-03-02 23:30:59 +01:00
Daniel McCarney 0b3167dfdb docs: fix broken x509-parser FromDer trait links.
The upstream `x509-parser` crate moved the `FromDer` trait from
a `traits` submodule to a `prelude` submodule, breaking the docs
link/example in the Rustls `DistinguishedName` and
`OwnedTrustAnchor.subject` doc strings.

This commit fixes the links/examples to use the current location of the
`FromDer` trait.
2023-03-02 21:10:41 +01:00
Daniel McCarney 1ee4a2ba92 chore: set initial branch name for bogo checkout.
Prior to this commit the `fetch-and-build` script with newer `git`
versions would spit out an ANSI coloured warning about choosing an
initial branch name for the bogo test-suite checkout.

This commit simply specifies the `--initial-branch` to be `main` to
silence the unnecessary output.
2023-03-02 10:28:10 +01:00
Daniel McCarney 2149288539 fix: avoid hardcoded python3 path, fix prints.
Prior to this commit the admin `bench-range`, `capture-certdata` and
`format-bench` Python helpers used a hardcoded path to Python3 in their
shebang. This commit updates each to use `/usr/bin/env` to find
`python3` in the `$PATH`.

These helpers also used Python2 style `print` statements instead of the
Python3 style `print` function. This commit adds the required braces to
fix Python3 usage.
2023-03-02 10:28:10 +01:00
Daniel McCarney 44bac99c6e fix: avoid hardcoded (ba)sh path in helper scripts.
Prior to this commit some helper scripts used hardcoded paths to
`/bin/sh` and `/bin/bash` in script shebangs. This will error on systems
that don't place `bash` in `/bin/` (e.g. NixOS).

This commit updates the scripts to use `/usr/bin/env` to find `bash`
based on the user's `$PATH`. This has better portability and allows the
scripts to run without err (or specifying an interpreter explicitly) on
systems with atypical `bash` installs.
2023-03-02 10:28:10 +01:00
Daniel McCarney 8e319df43d chore: update .gitignore.
Running the `admin/coverage` script produces a `default.profraw` in the
project root. Prior to this commit that file was not ignored by git.
This commit adds it to the ignore list since we don't want this file to
be accidentally submitted upstream.

This commit also adds the JetBrains IDE state dir (`.idea`) to the
gitignore. This is a small quality of life improvement for users of
CLion.
2023-03-02 10:28:10 +01:00
ComplexSpaces 0a0bc5fa64 Clarify Message reading ordering
Co-authored-by: Dirkjan Ochtman <dirkjan@ochtman.nl>
2023-02-28 10:51:19 +01:00
ComplexSpaces b6f8c2048f Improve error fusing inside message deframer 2023-02-28 10:51:19 +01:00
ComplexSpaces fe94dec981 Improve error reporting for corrupt messages 2023-02-28 10:51:19 +01:00
Thales cd4f5c90ca
Harmonize certificate verifiers construction API (#1189)
* Harmonize certificate verifiers construction API

Signed-off-by: Thales Fragoso <thales.fragosoz@gmail.com>
2023-02-26 09:51:59 +01:00
Jacob Rothstein a2fd30c05d tls13: Immediate key update 2023-02-10 11:46:45 +01:00
Yuri Astrakhan 4448de424f Lints: use Self and fix missing semicolons
* fix [semicolon_if_nothing_returned](https://rust-lang.github.io/rust-clippy/master/index.html#semicolon_if_nothing_returned) clippy lint
* fix [use_self](https://rust-lang.github.io/rust-clippy/master/index.html#use_self) clippy lint

This makes the code a bit cleaner, esp the self lint, when browsing the code in an IDE

Other minor fixes:
* remove non-needed `use log;`
* remove a few unneeded `&`
2023-02-10 09:48:45 +01:00
Christopher J. Brody 3d7c25079d improve & test ServerName debug output - workaround
(quick workaround solution)

The root cause seems to lie in the difference between the standard
debug formatting of tuples vs enums in Rust.
2023-02-09 11:41:58 +01:00
Joseph Birr-Pixton 411a65d736 Changelog items for alpha1 2023-01-30 09:05:15 +00:00
Joseph Birr-Pixton 8a29ee4d33 Stop processing when we send a fatal alert
In this edge case (not specified by RFC8446) we send a fatal
invalid_parameter alert, but then keep processing incoming messages.

This led to a debug assert failure when a later message also sent
an alert.
2023-01-27 11:19:29 +00:00
Joseph Birr-Pixton 4ad8b1f432 fuzzer client/server: process packets 2023-01-27 11:19:29 +00:00
Joseph Birr-Pixton 6e0aea5768 Fix outdated commentary in `rand.rs` 2023-01-26 09:18:29 +00:00
ctz 8c75101878
Merge pull request #1182 from rustls/jbp-certificate-errors
Rework certificate errors
2023-01-25 16:52:48 +00:00
larsfillmore 646abf699d Auto-shrink `MessageDeframer::buf` while at rest 2023-01-25 17:00:48 +01:00
Joseph Birr-Pixton aea27248fd Include underlying error in `CertificateError::Other` 2023-01-25 12:24:25 +00:00