8000 Use client certs in QUIC to get peer's stake by pgarg66 · Pull Request #26477 · solana-labs/solana · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.

Use client certs in QUIC to get peer's stake #26477

Merged
merged 8 commits into from
Jul 11, 2022

Conversation

pgarg66
Copy link
Contributor
@pgarg66 pgarg66 commented Jul 7, 2022

Problem

The QUIC streamer is using peer's IP address to compute the stake. If multiple clients are behind the NAT, they will have the same IP address. So the client's stake may not be accurately computed.

Summary of Changes

This PR adds provisions for clients to add certificates signed by their corresponding identity keypair. The QUIC streamer can fetch the client's public key from the cert, and use that to lookup its stake.

Fixes #26363

@pgarg66 pgarg66 marked this pull request as ready for review July 8, 2022 13:35
@pgarg66 pgarg66 requested a review from sakridge July 8, 2022 15:31
// Generate a self-signed cert from client's identity key
let cert_params = new_cert_params(identity_keypair, san);
let cert = rcgen::Certificate::from_params(cert_params)?;
let cert_der = cert.serialize_der().unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kind of looks similar to the server-side cert code, is there anything that could be shared?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the new_certs and its dependencies can be moved to a separate file that can be shared between client and server. Maybe in a follow on PR?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea, sounds good

cert.public_key().parsed().ok().and_then(|key| match key {
PublicKey::Unknown(inner_key) => {
let pubkey = Pubkey::new(inner_key);
info!("Peer public key is {:?}", pubkey);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably shouldn't be info! level. This would be printed on every connection, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll change it to debug.

let server_tls_config = rustls::ServerConfig::builder()
.with_safe_defaults()
.with_client_cert_verifier(SkipClientVerification::new())
.with_single_cert(cert_chain, priv_key)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so we need this because the self-signed client cert is not in the trust chain?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's correct.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The client is also skipping the server certificate verification. Maybe we should look if there is some additional verification needed/possible on both sides.

Copy link
Contributor
@sakridge sakridge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@pgarg66 pgarg66 added the automerge Merge this Pull Request automatically once CI passes label Jul 11, 2022
@mergify mergify bot merged commit ea7448c into solana-labs:master Jul 11, 2022
@pgarg66 pgarg66 deleted the client-certs branch July 11, 2022 18:06
mergify bot pushed a commit that referenced this pull request Jul 11, 2022
* Use client certs in QUIC to get peer's stake

* fixes to cert processing

* integrate the code

* clippy

* more cleanup

* sort cargo deps

* test fixes

* info -> debug

(cherry picked from commit ea7448c)

# Conflicts:
#	Cargo.lock
#	client/Cargo.toml
#	programs/bpf/Cargo.lock
mergify bot added a commit that referenced this pull request Jul 12, 2022
* Use client certs in QUIC to get peer's stake (#26477)

* Use client certs in QUIC to get peer's stake

* fixes to cert processing

* integrate the code

* clippy

* more cleanup

* sort cargo deps

* test fixes

* info -> debug

(cherry picked from commit ea7448c)

# Conflicts:
#	Cargo.lock
#	client/Cargo.toml
#	programs/bpf/Cargo.lock

* resolve conflicts

* resolve conflicts

* cargo.lock

Co-authored-by: Pankaj Garg <pankaj@solana.com>
jeffwashington pushed a commit to jeffwashington/solana that referenced this pull request Jul 12, 2022
* Use client certs in QUIC to get peer's stake

* fixes to cert processing

* integrate the code

* clippy

* more cleanup

* sort cargo deps

* test fixes

* info -> debug
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
automerge Merge this Pull Request automatically once CI passes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

StakedNodes mapping of stakes to nodes could be incorrect
2 participants
0