-
Notifications
You must be signed in to change notification settings - Fork 80
Remove /usr/lib/ssl/cert.pem symlink #344
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
Remove /usr/lib/ssl/cert.pem symlink #344
Conversation
In Ubuntu 24.04, maintainers added the `SSL_CERT_FILE` symlink for OpenSSL to, correctly, point `/usr/lib/ss/cert.pem` to the `ca-certificates` bundle: ``` $ ls -lah /usr/lib/ssl/cert.pem lrwxrwxrwx. 1 root root 34 Aug 20 2024 /usr/lib/ssl/cert.pem -> /etc/ssl/certs/ca-certificates.crt ``` The downside to this is that OpenSSL prefers loading this file first if found when calling `X509_STORE_set_default_paths`: https://github.com/openssl/openssl/blob/a1c6e2d1b590dc6a3d2e1c7bd1bf61ffcf854104/crypto/x509/x509_d2.c#L15 This is fine for small bundles, but with large bundles, this materially degrades performance of the `set_default_paths` call: ``` $ hyperfine -w10 "ruby --disable='gems,did_you_mean,rubyopt' -ropenssl -e 'OpenSSL::X509::Store.new.set_default_paths'" "SSL_CERT_FILE=/dev/null ruby --disable='gems,did_you_mean,rubyopt' -ropenssl -e 'OpenSSL::X509::Store.new.set_default_paths'" Benchmark 1: ruby --disable='gems,did_you_mean,rubyopt' -ropenssl -e 'OpenSSL::X509::Store.new.set_default_paths' Time (mean ± σ): 63.4 ms ± 1.4 ms [User: 58.3 ms, System: 4.6 ms] Range (min … max): 61.0 ms … 68.8 ms 47 runs Benchmark 2: SSL_CERT_FILE=/dev/null ruby --disable='gems,did_you_mean,rubyopt' -ropenssl -e 'OpenSSL::X509::Store.new.set_default_paths' Time (mean ± σ): 13.9 ms ± 0.6 ms [User: 10.7 ms, System: 3.1 ms] Range (min … max): 12.3 ms … 15.4 ms 212 runs Summary SSL_CERT_FILE=/dev/null ruby --disable='gems,did_you_mean,rubyopt' -ropenssl -e 'OpenSSL::X509::Store.new.set_default_paths' ran 4.55 ± 0.21 times faster than ruby --disable='gems,did_you_mean,rubyopt' -ropenssl -e 'OpenSSL::X509::Store.new.set_default_paths' ``` As a result, all cases that do not cache the result have this lookup latency added. This is especially apparent in libraries connecting to databases etc that are not using a connection pool, paying the penalty per connection setup. Ref: W-17566700
9ad33c4 to
0268798
Compare
|
(Capturing context for future reference)
See: |
|
Misc notes copied from an internal document: loads:
Cert counts calculated using: |
|
To summarise my understanding of the situation:
|
|
@edmorley something worth noting that setting |
|
@mble-sfdc Ah I didn't know - yet another reason that workaround isn't really viable. Thanks! |
|
Upstream OpenSSL perf issue: Related issues/PRs against languages and clients:
|
edmorley
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the PR!
In general we try to deviate as little as possible from stock Ubuntu, however, in this case given:
(a) the severity of the impact (for apps that don't reuse clients, which will be a fair number of them),
(b) the fact that as a PaaS we don't control end user app design,
(c) users that run into this may struggle to debug the issue and may miss the Heroku-24 docs explaining it (and think it's a Heroku issue, rather than a wider Ubuntu/Debian/OpenSSL issue)
(d) the fact that even if we get upstream Ubuntu/Debian to fix this, it's presumably unlikely they'll backport it to Ubuntu 24.04 given how long ago it landed upstream (2022)
...then I don't see much alternative to us overriding the Ubuntu defaults here and removing the symlink.
There is a risk that some Heroku-24 using apps are relying on this new behaviour, however:
- I think that the risk of removing the symlink is small given how many years Ubuntu hasn't had this symlink,
- Any affected apps could presumably set
SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crtto restore the equivalent of the behaviour when the symlink is present - We don't really have much other choice (ie: removing the symlink is the least worst option)
As such, I agree we should make this change.
Signed-off-by: Ed Morley <501702+edmorley@users.noreply.github.com>
|
Release started (currently only on staging cloud, and Docker images): Testing the old vs new Docker image on my local machine (MacBook Pro laptop with M4 Max): |
|
Interestingly, I just came across https://fedoraproject.org/wiki/Changes/dropingOfCertPemFile which describes how newer Fedora versions will be removing their So it seems perhaps this is the direction distros should be moving, and Debian/Ubuntu's addition of the symlink was indeed a step backwards. |
|
If anyone encounters errors like In general the CA certificates file and directory locations shouldn’t be hardcoded at the application level, and instead the default library/OS settings used instead. |

In Ubuntu 24.04, maintainers added the
SSL_CERT_FILEsymlink for OpenSSL to, correctly, point/usr/lib/ss/cert.pemto theca-certificatesbundle:The downside to this is that OpenSSL prefers loading this file first if found when calling
X509_STORE_set_default_paths: https://github.com/openssl/openssl/blob/a1c6e2d1b590dc6a3d2e1c7bd1bf61ffcf854104/crypto/x509/x509_d2.c#L15This is fine for small bundles, but with large bundles, this materially degrades performance of the
set_default_pathscall:As a result, all cases that do not cache the result have this lookup latency added. This is especially apparent in libraries connecting to databases etc that are not using a connection pool, paying the penalty per connection setup.
Ref: GUS-W-17566700 and an internal Slack thread.