Commit Graph

39 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
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 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
Dirkjan Ochtman 861e76d599 msgs: yield Result instead of Option from Reader/Codec 2023-03-06 22:17:08 +01:00
ComplexSpaces fe94dec981 Improve error reporting for corrupt messages 2023-02-28 10:51:19 +01:00
Joseph Birr-Pixton aea27248fd Include underlying error in `CertificateError::Other` 2023-01-25 12:24:25 +00:00
Joseph Birr-Pixton 00d7ac50f9 Remove `PartialEq` from `rustls::Error`
This can still be matched against, so move simple tests
from `assert_eq!(..,)` to `assert!(matches!(...))`.

In complex tests, prefer to have test failures that quote the
stringified errors; there's a helper function `assert_debug_eq` that
does that.
2023-01-25 12:24:25 +00:00
Joseph Birr-Pixton a1ee6d28ac Rework certificate errors
rustls now has its own `CertificateError` type that aims to cover
most common errors with certificate validation.
2023-01-25 12:24:25 +00:00
Joseph Birr-Pixton 39a26cdd47 Remove string content from `PeerIncompatibleError`
This also:

- corrects use of hs::incompatible for client certificate verification
  failure.
- moves sni varying across hello retries to be a PeerMisbehaved, since
  that is explicitly disallowed by the standard.
2023-01-23 15:16:31 +00:00
Joseph Birr-Pixton 88ea3966b7 Remove string content from `PeerMisbehavedError` 2023-01-23 15:16:31 +00:00
Dirkjan Ochtman 2f154643e5 Revert #1016 (attach location context to corrupt message errors)
This is a breaking change in the Error type.
2022-05-18 09:52:33 +02:00
ComplexSpaces c42c53e13d Attach location context to corrupt message errors 2022-03-31 10:23:46 +02:00
Jerome Gravel-Niquet 3f5eee91f4 fix clippy nightly errors 2022-03-18 10:44:18 -07:00
Dirkjan Ochtman a17ca17194 quic: internalize PacketKey methods from Quinn 2021-08-03 20:03:30 +02:00
Dirkjan Ochtman e9afee00de Flatten PKI error variants 2021-07-31 09:36:57 +01:00
ComplexSpaces 98d087e793 Add UnsupportedNameType error for certificate validation routines 2021-06-28 22:20:06 +02:00
Joseph Birr-Pixton 430c692f95 Privatise contents of rustls::Error::WebPkIError 2021-06-20 17:03:42 +01:00
RS 76c294fde4 Fix up formatting on main. 2021-05-16 21:36:52 +01:00
Joseph Birr-Pixton fa580b469f Stop misusing "MTU" terminology
Instead, let the user configure the max TLS fragment size directly.

Report errors from ServerConnection::new like ClientConnection::new, so we
can report out of range fragment sizes.
2021-05-16 11:17:32 +01:00
RS 0484cb00d3 Address review comments. 2021-05-15 20:15:02 +02:00
RS e4517b28b1 Test the MtuError message. 2021-05-15 20:15:02 +02:00
RS 79b0d35b9a Use Result<> for set_mtu. 2021-05-15 20:15:02 +02:00
Brian Smith cc10643018 Avoid panicking in the unlikely case that the time is set very wrong.
If the system time is set to before the Unix epoch (probably not possible on
most operating systems) then computing the duration since the Unix epoch will
fail. Avoid that very unlikely case.

Add the time of retrieval (storage) to `ClientSessionValueWithResolvedCipherSuite`
since the lifetime of the needed time is exactly the lifetime of the value of that
type. (Perhaps `ClientSessionValueWithResolvedCipherSuite` could be given a better
name.)

In the future, if we were to refactor the `Ticekter` API to accept the current time
then we could probably reduce the number of times the current time is retrieved by
adding a `TimeBase` parameter to each of `encrypt()` and `decrypt()`.

Also stengthen the type used to represent the current time from `u64` to a new
`TimeBase` type.
2021-04-18 14:34:43 +01:00
Joseph Birr-Pixton ed7256a316 Take newer sct/ct-logs 2021-04-10 18:25:36 +01:00
Joseph Birr-Pixton 24db3df0dd Cleanups and readme for renames
- Fix docs mentions of things that were renamed.
- Ditto mentions in tests.
2021-04-09 11:30:39 +01:00
Dirkjan Ochtman 7c9c3244c0 Align type and variant names with naming conventions 2021-04-09 08:41:25 +01:00
Dirkjan Ochtman 77fecf25b5 Remove redundant imports 2021-04-09 08:41:25 +01:00
Dirkjan Ochtman 5453eccf57 Rename TlsError to Error (see #541) 2021-04-01 20:13:38 +01:00
Dirkjan Ochtman eacc251a27 Fix formatting with cargo fmt 2021-03-16 20:12:06 +00:00
Dirkjan Ochtman eb39623eb9 Rename public API types to conform to API guidelines 2021-03-14 17:09:06 +00:00
Dirkjan Ochtman cc4ed5fc57 Make randomness acquisition fallible (fixes #441) 2021-03-11 19:43:41 +00:00
Stiopa Koltsov 138bf01c15 What is the reason webpki operation failed?
I don't know if it's me or everyone, but debugging TLS setup issues
is usually non-trivial.

For example, right now I'm fighting with this issue:
an `openssl s_client` works fine, but a client implemented with
rustls fails with an error:

```
Custom { kind: InvalidData, error: WebPKIError(UnknownIssuer) }
```

`WebPKIError` can be emitted for several reasons. This PR adds the
operation name to the error. I have identified five operations:
* validate server certificate
* validate client certificate
* validate certificate for DNS name
* parse the certificate
* verify message signature

The error can be expanded further later, but even this basic list
will provide some clue where to look.
2021-02-21 09:50:19 +00:00
Joseph Birr-Pixton f5467c15ee cargo fmt
Requires rustfmt v2.x
2020-11-22 12:42:12 +00:00
Joseph Birr-Pixton 3882b3886a Delete std::error::Error::description impl
It's deprecated.
2020-01-01 10:52:50 +00:00
Alexander Krotov cad0305cad Remove unused TLSError::InvalidDNS variant 2019-12-11 20:15:37 +00:00
Benjamin Saunders cd76b8ee9a Send an alert on ALPN mismatch under QUIC 2019-10-08 20:45:40 +01:00
Joseph Birr-Pixton 1d70e45af6 Move to using cargo workspaces
- rustls (the library) now lives in rustls/
- the mio examples/tests continue to live in rustls-mio, but
  are built by (eg) `cargo test` in the root of the repo.
2019-08-24 20:55:20 +01:00