Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What problem does this pull request address?
This pull request solves the issue of unencrypted database traffic to an external MariaDB/MySQL database for the Uptime-Kuma back-end database.
Please provide a detailed explanation here.
When connecting to an external MariaDB database as the back-end database, SSL is not an option. This isn't an issue if the database is on the host, but if the database server is not local then best practice would dictate encryption be used.
I'm not a Node programmer, and I didn't have a wealth of time to invest into the functionality, so hopefully this is good enough.
My changes allow for SSL encryption between Uptime-Kuma and a MariaDB database, with the option of providing a CA certificate to verify the server. I did not implement sending client certificates, though my code could easily be expanded to include this in the function to generate the sslOptions.
The change adds two new environment variable options -
UPTIME_KUMA_DB_SSLwhich should betrueto enable ssl, and optionallyUPTIME_KUMA_DB_SSL_CAwhich should be the path to the trusted CA certificate for verification. If a CA is not provided or cannot be opened, but SSL is toggled on, thenrejectUnauthorized = falseis set by default, which will not validate the server certificate.I was torn between failing to connect if a CA is provided but unavailable (i.e. can't open file), and ended up settling on logging an error and turning off verification. I'm still torn on whether this is the right method, but it's what the code says right now, and it can be changed if someone disagrees.
The change also adds two entries to the dbConfig.json file:
ssl:boolean, ssl_ca:envString.If those options are false or not set, then the database connection happens as normal.
require_secure_transportcondition.🛠️ Type of change
📄 Checklist
I couldn't get ESLint working. If this is a critical step I'll try to carve out some time for it.
I have only tested in my environment, which is bare metal Debian 13 running Node 24.11.0
I don't use Docker, but I can't think of a reason why this wouldn't work in the Docker deployment.
Documentation changes will need to be in the wiki after the PR is merged. Not sure where to include them