Repository navigation
Conversation
added 2 commits
October 30, 2026 14:59
…abase server certificate and hostname verification.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Adds opt-in TLS for database connections via three new environment variables, mirroring the existing
REDIS_USE_TLS:MYSQL_USE_TLS(bool, defaultfalse)MYSQL_TLS_CA(path, default/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem)MYSQL_TLS_VERIFY(bool, defaulttrue)When enabled, both database clients in the image connect over TLS. By default the server certificate and hostname are verified.
Motivation
The image cannot currently be used with a database that enforces encryption (
require_secure_transport=ONon MariaDB/MySQL), for example RDS on AWS: the startup check inmisp_create_database.pyconnects without TLS and the container never gets pastThe PHP side could in theory be configured through
MYSQL_FLAGS, but only with raw PDO integer constants, and there was no way to make the startup check use TLS at all.Changes
bin/misp_create_database.py– whenMYSQL_USE_TLSis set, connects with TLS. With verification on (default), passesssl={"ca": MYSQL_TLS_CA}to PyMySQL, which requires TLS and verifies the certificate and hostname; withMYSQL_TLS_VERIFY=false, the connection is encrypted without certificate checks. Thessldict form is used for compatibility with older PyMySQL versions. Bool parsing mirrorsmisp_redis_ready.py.Config/database.php– emits'ssl_ca' => MYSQL_TLS_CAwhen TLS is enabled. CakePHP's MySQL datasource maps this toPDO::MYSQL_ATTR_SSL_CA; with a CA set, mysqlnd enablesverify_peerandverify_peer_nameby default. WithMYSQL_TLS_VERIFY=false, also emitsPDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT => falseinflags, merged with anyMYSQL_FLAGS.bin/misp_create_configs.py– registers the variables; fails fast at startup if TLS is enabled but the CA file is missing or unreadable; prints a warning when certificate verification is disabled.README.md– documents the variables.Backwards compatibility
The default is off. With the new variables unset, the rendered
database.phpis byte-identical to the current one (checked with and withoutMYSQL_FLAGS/MYSQL_SETTINGS) and the startup connection is unchanged.Usage
The server certificate must contain
MYSQL_HOSTin its subjectAltName.Testing
Against MariaDB with
require_secure_transport=ON:MYSQL_TLS_VERIFY=falseMYSQL_TLS_VERIFY=falsecombined withMYSQL_FLAGSAlso verified:
database.phprenders viamisp_create_configs.pyand passesphp -lin all combinations above.create()rejects a missing CA file and non-booleanMYSQL_USE_TLS/MYSQL_TLS_VERIFYwith a clear error.