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

feat(pgwire): expose SSL functionality via RW_SSL_CERT and RW_SSL_KEY #14062

Merged
merged 3 commits into from
Dec 19, 2023

Conversation

chenzl25
Copy link
Contributor

I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.

What's changed and what's your intention?

  • Expose SSL functionality via RW_SSL_CERT and RW_SSL_KEY

Checklist

  • I have written necessary rustdoc comments
  • I have added necessary unit tests and integration tests
  • I have added test labels as necessary. See details.
  • I have added fuzzing tests or opened an issue to track them. (Optional, recommended for new SQL features Sqlsmith: Sql feature generation #7934).
  • My PR contains breaking changes. (If it deprecates some features, please create a tracking issue to remove them in the future).
  • All checks passed in ./risedev check (or alias, ./risedev c)
  • My PR changes performance-critical code. (Please run macro/micro-benchmarks and show the results.)
  • My PR contains critical fixes that are necessary to be merged into the latest release. (Please check out the details)

Documentation

  • My PR needs documentation updates. (Please use the Release note section below to summarize the impact on users)

Release note

If this PR includes changes that directly affect users or other significant modifications relevant to the community, kindly draft a release note to provide a concise summary of these changes. Please prioritize highlighting the impact these changes will have on users.

  • expose SSL functionality via RW_SSL_CERT and RW_SSL_KEY
  • Users can configure SSL cert and key file location via setting environment variables RW_SSL_CERT and RW_SSL_KEY for frontend nodes.

Copy link
Member

@fuyufjh fuyufjh left a comment

Choose a reason for hiding this comment

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

After this PR, SSL can work?

@chenzl25
Copy link
Contributor Author

After this PR, SSL can work?

With a certificate with a localhost sign, I used psql to test it and it works. For on-prem users, they need to configure these environment variables by themselves. However, for cloud users, we have a proxy to provide TLS/SSL functionality.

psql "postgresql://root:@localhost:4566/dev?sslmode=verify-full"
psql (14.8 (Homebrew), server 9.5.0)
SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, bits: 256, compression: off)
Type "help" for help.

dev=>

@chenzl25 chenzl25 requested a review from cloudcarver December 19, 2023 08:54
@chenzl25
Copy link
Contributor Author

cc @mikechesterwang Could you please take a look based on your experience on SSL proxy?

let cert = if let Ok(cert) = std::env::var("RW_SSL_CERT") {
PathBuf::from(cert)
} else {
PathBuf::new().join("src/utils/pgwire").join("tests/ssl/demo.crt")
Copy link
Member

Choose a reason for hiding this comment

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

Should this be test-only? If so, should we instead pass None here if they're unset?

pg_serve(&listen_addr, session_mgr, Some(TlsConfig::new_default()))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

According to #5775 @wangrunji0408 do you know whether we still use SSL in deterministic tests?

Copy link
Member

@BugenZhao BugenZhao Dec 19, 2023

Choose a reason for hiding this comment

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

If it's believed okay to use "demo" cert in production, then we may consider embedding the contents with include_bytes and create a temp file at runtime. Specifying a relative path towards the source code directory sounds too fragile to me. 😕

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we don't use it anymore, I will remove those test purpose codes.

Copy link
Contributor

Choose a reason for hiding this comment

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

According to #5775 @wangrunji0408 do you know whether we still use SSL in deterministic tests?

I remember SSL is always disabled in deterministic tests.

Copy link

gitguardian bot commented Dec 19, 2023

⚠️ GitGuardian has uncovered 1 secret following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secret in your pull request
GitGuardian id Secret Commit Filename
7648819 Generic Private Key 717e7bb src/utils/pgwire/tests/ssl/demo.key View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secret safely. Learn here the best practices.
  3. Revoke and rotate this secret.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

Our GitHub checks need improvements? Share your feedbacks!

@chenzl25 chenzl25 requested a review from BugenZhao December 19, 2023 10:19
Copy link

codecov bot commented Dec 19, 2023

Codecov Report

Attention: 6 lines in your changes are missing coverage. Please review.

Comparison is base (03cd054) 68.06% compared to head (717e7bb) 68.05%.
Report is 5 commits behind head on main.

Files Patch % Lines
src/utils/pgwire/src/pg_protocol.rs 0.00% 5 Missing ⚠️
src/frontend/src/lib.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #14062      +/-   ##
==========================================
- Coverage   68.06%   68.05%   -0.01%     
==========================================
  Files        1548     1548              
  Lines      267489   267482       -7     
==========================================
- Hits       182064   182033      -31     
- Misses      85425    85449      +24     
Flag Coverage Δ
rust 68.05% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@chenzl25 chenzl25 added this pull request to the merge queue Dec 19, 2023
Merged via the queue into main with commit 4c8d94e Dec 19, 2023
25 of 27 checks passed
@chenzl25 chenzl25 deleted the dylan/expose_ssl_functionality branch December 19, 2023 12:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants