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

rustls transport module certificate verifier improvement #6

Open
csyJoy opened this issue Oct 12, 2024 · 0 comments
Open

rustls transport module certificate verifier improvement #6

csyJoy opened this issue Oct 12, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@csyJoy
Copy link
Contributor

csyJoy commented Oct 12, 2024

rats-rs uses tokio-rustls as a dependency to support async tls and tokio-rustls uses rustls as its underlying implementation for certificate verification functionality. In rats-rs, we use custom certificate verifying functionality to verify TEE evidence, this is done by adding RatsClientVerifier/RatsServerVerifier struct instance which has implemented ClientCertVerifier/ClientCertVerifier trait to client/server configuration while building tls.

.set_certificate_verifier(Arc::new(RatsServerVerifier {
default_server_verifier: WebPkiServerVerifier::builder(Arc::new({
//XXX: only to bypass empty test of WebPkiServerVerifier
let mut root = rustls::RootCertStore::empty();
let privkey =
DefaultCrypto::gen_private_key(crate::crypto::AsymmetricAlgo::Rsa2048)?;
let cert = CertBuilder::new(AutoAttester::new(), HashAlgo::Sha256)
.build_with_private_key(&privkey)
.await?
.cert_to_der()?;
root.add(cert.into())?;
root
}))
.build()?,
}));

.with_client_cert_verifier(Arc::new(RatsClientVerifier {
default_client_verifier: WebPkiClientVerifier::builder(Arc::new({
//XXX: only to bypass empty test of WebPkiClientVerifier
let mut root = rustls::RootCertStore::empty();
let privkey =
DefaultCrypto::gen_private_key(crate::crypto::AsymmetricAlgo::Rsa2048)?;
let cert = CertBuilder::new(AutoAttester::new(), HashAlgo::Sha256)
.build_with_private_key(&privkey)
.await?
.cert_to_der()?;
root.add(cert.into())?;
root
}))
.build()?,
}))

The current RatsClientVerifier/RatsServerVerifier wrapper a WebPkiClientVerifier/WebPkiServerVerifier as the default certificate verify logic, but actually there is no need to add such default certificate verify logic since rats-rs cert module has already implemented this. Things get complicated because ClientCertVerifier/ClientCertVerifier trait not only needs a certificate verifying method, but also other methods like message signature which aren't implemented in rats-rs.

The next step to improve RatsClientVerifier/RatsServerVerifier is trying to implement ClientCertVerifier/ClientCertVerifier trait without WebPkiClientVerifier/WebPkiServerVerifier.

@imlk0 imlk0 added the enhancement New feature or request label Oct 17, 2024
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

2 participants