Remove openssl#1700
Conversation
|
I strongly request that we not do potentially dangerous changes which are not intended to be API breaks within the 0.12 release window. This can, and therefore should, wait. |
|
Changed to draft so we don't merge yet |
40c7d9d to
1f9c3d8
Compare
|
Btw, this adds cmake as a requirement on Windows. |
Sigh. It's somewhat unfortunate to replace one external dependency for Windows devs (Perl or prebuilt OpenSSL) with another (CMake). |
|
Is now good time to change this from |
f48a869 to
97a1c00
Compare
|
closes #1504 |
# Description of Changes Closes [#2686](#2686). Add support for listening using the [PG wire protocol](https://www.postgresql.org/docs/current/protocol.html) so `pg` clients could be used against the database. # API and ABI breaking changes The output of `duration` is changed to `rfc3339`, instead of the way is made with `sats` because is what is done in `pg`, see note below. # Expected complexity level and risk 2 ~~There is open questions that are in the [ticket #2686](#2686). Also the crate used here require `RustTls`, so it could be good idea to decide if~~: * ~~Rewrite a big chunk of code to use `OpenSSL`~~ * ~~Move to `RustTls` #1700 * ~~Pay for the extra compilation cost~~. I open another port(`5433`) to listen for `pg` connections using `ssl`. Need to be decided if this is the way or instead try to multi-plex the current port for both protocols. # Testing Only manual testing so far. Solving the above questions allow me to implement some unit tests. Also, not yet integrated into cloud for the same reasons. - [x] Adding some test for the binary encoding of special and primitive types - [x] Smoke test using `psql` that connect to the db instance and run some queries - [x] Manually inspect using a UI database explorer how infer the types, some of this tools generate special widgets when displaying `json, duration, etc` --------- Co-authored-by: Noa <coolreader18@gmail.com>
|
master: This branch: So a meaningful improvement for me! I don't really love that this swaps one outside-of-cargo dependency for another on Windows, but I can't speak to which one is more imposing for Windows users. |
248f51f to
f3d8ccc
Compare
f3d8ccc to
be9fc55
Compare
be9fc55 to
546bcf3
Compare
… into mamcx/openssl_no_more
clockwork-labs-bot
left a comment
There was a problem hiding this comment.
Review: Remove openssl (#1700)
Summary: Replaces the openssl crate (with vendored openssl-src) with rcgen + p256 for key generation, and switches tokio-tungstenite/reqwest from native-tls to rustls. The motivation is clear: vendored OpenSSL is slow to compile, especially on Windows.
PEM Format Compatibility ✅
The critical question: do the new PEM outputs match what jsonwebtoken::DecodingKey::from_ec_pem() / EncodingKey::from_ec_pem() expect?
- Public key: Both old (
openssl::EcKey::public_key_to_pem()viaPEM_write_bio_EC_PUBKEY) and new (rcgen::KeyPair::public_key_pem()) produce-----BEGIN PUBLIC KEY-----(SPKI format). ✅ - Private key: Both old (
PKey::private_key_to_pem_pkcs8()) and new (rcgen::KeyPair::serialize_pem()) produce-----BEGIN PRIVATE KEY-----(PKCS#8 format). ✅ - Backward compatibility: Existing key files on disk are read by the unchanged
JwtKeys::new()path, which passes PEM bytes directly tojsonwebtoken. Since the PEM tags are identical, existing keys will continue to work. ✅ - Curve: Both use P-256 (
Nid::X9_62_PRIME256V1==PKCS_ECDSA_P256_SHA256). ✅
Swapped comments (cosmetic)
// Get the private key in PKCS#8 PEM format & write it. // <-- says "private"
let public_key_bytes = key_pair.public_key_pem().into_bytes(); // <-- assigns public
// Get the public key in PEM format & write it. // <-- says "public"
let private_key_bytes = key_pair.serialize_pem().into_bytes(); // <-- assigns privateThe assignment is correct but the comments are swapped from the original and now misleading. Please swap them.
TLS backend change
tokio-tungstenite:native-tls→rustls✅reqwest: Addedrustls-tlsfeature, butnative-tlsis still a transitive dependency (viareqwest's default features). Consider whether you want to disable default features and use onlyrustls-tlsto fully remove thenative-tlsdependency.
Test changes ✅
The to_jwk_json helper in token_validation.rs tests was updated from openssl to p256 for extracting EC point coordinates. The logic is equivalent and cleaner.
Missing test coverage
There are no tests for EcKeyPair::generate() or the roundtrip of generating keys → creating JwtKeys → signing a JWT → verifying the JWT. The existing tests in token_validation.rs exercise JwtKeys::generate() (which calls EcKeyPair::generate()) indirectly, but a direct unit test would be valuable. Suggested tests:
- Key generation roundtrip: Generate an
EcKeyPair, convert toJwtKeys, sign a JWT, verify it with the public key. - PEM format assertions: Generate keys and verify the PEM headers (
BEGIN PUBLIC KEY,BEGIN PRIVATE KEY). - Cross-library compatibility: Generate keys with the new code, verify the PEM can be parsed by
jsonwebtoken(this is essentially what test 1 does). - Write/read roundtrip: Write keys to temp files, read them back, verify they produce valid JwtKeys.
I can add these tests if you'd like.
Verdict
The core change is sound. PEM formats are compatible, the curve is correct, and existing key files will continue to work. The swapped comments should be fixed. The TLS backend change is a nice bonus.
- Fix misleading comments on public/private key generation - Add 5 unit tests covering the key generation change: - PEM format headers are correct (BEGIN PUBLIC KEY / BEGIN PRIVATE KEY) - Sign/verify roundtrip with generated keys - Two generated key pairs are distinct - Cross-verification with wrong key fails - Write to disk / read back roundtrip
…ub.com:clockworklabs/SpacetimeDB into mamcx/openssl_no_more
- Set default-features = false for reqwest in workspace Cargo.toml, keeping stream, json, rustls-tls, and http2 features - Fix xtask-llm-benchmark to also disable reqwest default features (was re-enabling native-tls via Cargo feature unification) - Remove native-tls version pin from Rust SDK (no longer needed since nothing depends on native-tls anymore) This fully removes the native-tls -> openssl-sys dependency chain from reqwest 0.12. The only remaining openssl-sys dependency is from git2/libgit2-sys (unrelated to TLS).
| cargo build -p v8 | ||
| fi | ||
|
|
||
| # This step shouldn't be needed, but somehow we end up with caches that are missing librusty_v8.a. |
There was a problem hiding this comment.
I added this since we now build in release mode here, and we started hitting this issue again.
I still have no idea why this happens since we no longer cache-on-failure, but.. /shrug.
|
Closing this stale PR in favor of #4833, which tracks reimplementing the work on top of current |
Description of Changes
Using the
opensslcrate significantly increases the build times on Windows. Switching torustlsimproves it:Expected complexity level and risk
*How complicated do you think these changes are? Grade on a scale from 1 to 5,
3
It looks correct to me the generation and reading of keys. However, even if trivial, changing libraries that do crypto requires careful eyes.
Testing
openssl.*quickstartand re-read the keys