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

Add support for server certificate validation #13

Open
lulf opened this issue Jun 30, 2021 · 6 comments
Open

Add support for server certificate validation #13

lulf opened this issue Jun 30, 2021 · 6 comments
Assignees
Labels
enhancement New feature or request

Comments

@lulf
Copy link
Member

lulf commented Jun 30, 2021

Add support for supplying a CA trust in the TlsConfig and use this to validate the Certificate presented by the server.

@lulf lulf added the enhancement New feature or request label Jun 30, 2021
@lulf lulf self-assigned this Jul 8, 2021
@lulf lulf added this to the 0.3.0 milestone Jul 8, 2021
lulf added a commit that referenced this issue Oct 13, 2021
* Add support for validating server certificates and signatures
* Add 'alloc' feature to support RSA-based certificate validation
* Support elliptic curve-based certificates without alloc
* Add configuration options for enabling/disabling cert and hostname validation
* Add TlsClock trait that if enabled will ensure cert validation check

Fixes #13
lulf added a commit that referenced this issue Oct 13, 2021
* Add support for validating server certificates and signatures
* Add 'alloc' feature to support RSA-based certificate validation
* Support elliptic curve-based certificates without alloc
* Add configuration options for enabling/disabling cert and hostname validation
* Add TlsClock trait that if enabled will ensure cert validation check

Fixes #13
@lulf lulf closed this as completed in 634b0fe Oct 21, 2021
@lulf lulf reopened this Nov 1, 2021
@lulf lulf removed this from the 0.3.0 milestone Nov 1, 2021
@lulf
Copy link
Member Author

lulf commented Nov 5, 2021

Status update on this feature:

At present, the webpki crate is a compile time option for enabling certificate validation. However,
the webpki crate does not work on embedded devices and has a few issues:

  1. C library dependencies and custom assembly code that makes supporting new targets very slow
  2. Random number generation is "owned" by webpki. This doesn't work well with the embedded ecosystem, because there are many different random number generators, and implementing them all in webpki is not feasible.

Therefore, I think it is useful to take a look at alternatives.

IMO the minimal feature set drogue-tls should support are:

  • Validating server certificate. One exception is the expiry range: most embedded devices does not
    have a clock, so this must be ignorable (This is done already for the webpki implementation, but requires a webpki patch)
  • Validating signature if the key exchange using the server certificate.

In the first instance I think supporting the elliptic curve signature algorithms should be
sufficient:

  • EcdsaSecp256r1Sha256 (0x0403)
  • EcdsaSecp384r1Sha384 (0x0503)
  • EcdsaSecp521r1Sha512 (0x0603)
  • Ed25519 (0x0807)

RSA would be nice, but I don't know of any crates being able to do RSA without allocator.

There are several crates not requiring any allocators that could be used for this task (most developed under RustCrypto:

@yaoxin1995
Copy link

yaoxin1995 commented Mar 23, 2023

Hey @lulf , I wonder what is the status of this feature? Is embedded-tls client support server certificate validation if the server provides a self-signed certificate?

@lulf
Copy link
Member Author

lulf commented Mar 23, 2023

It's the same as the last status I'm afraid. Whether the server certificate is self-signed or not doesn't matter, the only difference would be that you'd have to use your own CA as the trust root.

@bugadani
Copy link
Collaborator

bugadani commented Apr 19, 2023

I feel like we should extract the webpki verifier to its own crate. rust-analyzer doesn't like that it's gated behind a feature (won't really work with the webpki.rs file), and we might want to encourage developing additional verifier backends if there is a standalone example of how to do it.

rustls has forked webpki. Since they also build on ring, I don't expect this fork would be any more useful for us, but it's something worth knowing about, and might be a good idea to support, too.

@lulf
Copy link
Member Author

lulf commented Apr 19, 2023

I think we should just kill the webpki verifier, I don't think it's useful the way it is, and would rather see one that uses rust-only crates.

@bugadani
Copy link
Collaborator

bugadani commented Apr 19, 2023

A rust-only solution is a good idea, but killing webpki is harsh IMO. I'm considering using it myself in one form or another, though I haven't started yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants