Encrypting OpenEMR database connections with TLS

Encrypting OpenEMR's connection to MySQL or MariaDB matters once the database leaves the application host. This page covers the options, certificate decisions, least-privilege accounts and how to verify the link.

On this page

Why encrypt the OpenEMR database connection with TLS

Once the OpenEMR database runs on another host, every patient record query crosses a network segment, and TLS is the control that keeps that traffic from being read or altered in transit. OpenEMR runs on a MySQL- or MariaDB-compatible database, so the database server is where the clinical data actually lives. When the application and the database share one machine, the connection never leaves that host. When they are split, whether across a dedicated database server, a Docker network with a separate database container, or a shared or cloud network, the credentials, query results and patient identifiers travel between hosts that other workloads may also reach. TLS encrypts that link and lets the database client verify the server it connects to, which addresses interception and tampering on the wire. It does not protect data sitting on disk, stop a stolen password from working, or limit what an authenticated account can read.

The OpenEMR project's own security guidance focuses on the web-facing side of the system, such as allowing only HTTPS and restricting admin scripts, so database link encryption is a control your team has to design and verify itself. Before you choose settings, confirm the exact connection options your OpenEMR version and deployment method expect, including how the Docker image passes SSL and X.509 options to the database client, because these details differ between releases and between the Docker and package installs. Recent OpenEMR releases require PHP 8.3 or later, so check that your PHP MySQL driver supports the TLS options you plan to use. The MariaDB Server documentation also lists TLS as a supported capability, but the server side must be configured and the certificate chain must be trusted by the OpenEMR host.

Treat this as a decision for any deployment where the database leaves the web server's host or passes through a network segment you do not fully control. Ask who can reach the database port on that network, whether other applications share it, and whether an internal certificate authority is available for signing the database certificate. Then record which connection settings you chose, how the certificate is rotated, and how you will confirm that the connection is actually encrypted, for example by checking the session's TLS status from the database side. Those answers feed directly into the least-privilege account design covered elsewhere on this page.

Which connection setup fits your deployment

When OpenEMR runs directly on a server or virtual machine and MariaDB or MySQL runs on a separate host, the PHP application is the client and the database server presents its certificate. The server certificate lives on the database host, and the CA bundle that verifies it lives on the web server. Your internal PKI usually issues these certificates, because internal hostnames rarely suit a public CA.

  • Server certificate: installed on the database host, with the exact hostname OpenEMR uses in its connection settings in the subject or subject alternative name.
  • CA bundle: copied to the web server, readable by the PHP process user and referenced in the PHP database driver's CA setting.
  • Verification behavior: confirm in your installed OpenEMR version whether the connection verifies the server certificate and hostname, or only encrypts the channel.
  • Versions to confirm: recent OpenEMR releases require PHP 8.3 or later, so check the PHP build's TLS support against the database client library it uses.
  • Network path: limit the database port in the firewall to the web server address only.

Before issuing certificates, confirm the OpenEMR version on the OpenEMR releases page and the database branch on the MariaDB release list.

TLS configuration options and when each fits

This table compares the main ways OpenEMR can encrypt its connection to MySQL or MariaDB, from encryption without server verification to full X.509 checks with client certificates. Read each row against the certificate authority you already run, the rotation effort you can sustain, and the exposure you accept if a certificate or path is compromised.

OptionWhat it verifiesCertificate authority neededWhen it fits and main trade-off
Encrypted, no server verificationTraffic is encrypted, but OpenEMR does not confirm the database server's identityNoneShort-term testing only. Traffic can be intercepted by anyone on the path who presents a certificate.
Verify against a private CAThe server certificate chains to the CA your team trustsYes, a private CA you already operate or a dedicated internal CAUsual baseline for a database on another host. Requires distributing the CA certificate to the OpenEMR container or host.
Verify server hostnameThe certificate names the host OpenEMR connects toYes, the same CA as the row aboveBlocks a valid certificate presented by the wrong host. Hostnames in the certificate must match the connection string exactly.
Verify client certificates (X.509 checks)The OpenEMR side presents a certificate the database accepts, tied to a specific accountYes, and a process to issue and revoke client certificatesStrongest binding of account to host. Adds issuance, storage and rotation work for each client identity.
Certificate rotationContinuity when server or client certificates expireDepends on the option chosen aboveAsk who renews certificates, how OpenEMR picks up the new CA or certificate, and whether the database restarts during rotation.
Docker SSL and X.509 settingsWhether the image enables TLS and which checks it appliesDepends on the option chosen aboveConfirm the variable names, accepted values and mount paths against the image documentation for your OpenEMR version before relying on them.
Database account scopeWhich accounts require TLS and what each can doDepends on the option chosen aboveRequire TLS on the OpenEMR account only and keep administrative accounts separate, following least privilege.

Set up encrypted database connections in order

This sequence moves a self-hosted OpenEMR installation from a plaintext connection to a database session that is encrypted, verified against a trusted certificate authority and limited to a dedicated account. Each step ends with a check so the team knows the previous step held before moving on.

  1. Confirm TLS support on the database server

    The database administrator checks that the MariaDB or MySQL server was built or packaged with TLS support and that the server certificate, private key and certificate authority file are in place, readable only by the database service account. The certificate subject or subject alternative name must match the hostname OpenEMR will use to connect, because verification fails on a mismatch. Run the server's status and variable queries to confirm TLS is available and that the certificate file paths load without error in the server log. Confirm exact variable names and file path settings in the MariaDB documentation for your server version before editing anything.

  2. Create or identify the certificate authority

    Decide whether the certificate comes from your existing internal certificate authority or from a CA you create for this database, and record who owns the signing key and how renewal works. The CA certificate is the file OpenEMR and any other client will use to verify the server, so it must be distributed to the web host that runs OpenEMR and kept out of the document store. Issue the server certificate from this CA and check the chain by verifying the server certificate against the CA file with a standard certificate tool. Done means the verification command returns OK and the expiry date is recorded in your certificate inventory.

  3. Require encryption for the OpenEMR database account

    The database administrator creates or alters the account OpenEMR uses so that it must connect over TLS, and grants it only the privileges the application needs for its schema rather than broad administrative rights. Requiring TLS at the account level means a client that offers a plaintext connection with that account is rejected, even if it knows the password. If you need to require certificate verification as well, configure the account's TLS requirement at the stricter level your version supports, and confirm the option names in the MariaDB account management documentation. Done means a test login from the OpenEMR host succeeds only when TLS is negotiated.

  4. Point OpenEMR at the CA and verification mode

    The OpenEMR administrator updates the database connection settings so the application passes the CA file path and the verification level the team chose, using the SSL and X.509 options your OpenEMR release and deployment method document. For Docker deployments, these options are set through the container environment or configuration files, so confirm the exact keys in the OpenEMR documentation for your version before changing them. Keep the verification mode at full certificate and hostname checking where possible, since a lower mode accepts a server certificate without confirming it came from your CA. Done means the configuration file or environment holds the new settings and the file permissions allow only the web service user to read the CA and client files.

  5. Restart the application and the database service

    The team restarts the database service first, then restarts the web server or OpenEMR container so new connections read the updated configuration, and schedules the change in a maintenance window that covers any running clinical sessions. Watch the database error log and the OpenEMR web server log during the restart for TLS handshake errors, certificate path errors and failed logins. Any error at this point means the change is not finished and should be rolled back to the previous settings. Done means OpenEMR loads its login page and the logs show no connection errors during a normal login.

  6. Verify the encrypted session from the database

    From the database side, the administrator queries the current session for the OpenEMR account and checks that the connection reports an active SSL or TLS cipher and the protocol version, as shown by the status variables for the connection. Confirm that the reported cipher and protocol match the server's supported settings and that the client identity is the dedicated OpenEMR account, not a shared administrative login. Record the query output and the date in the change record so an auditor can see the evidence. Done means every OpenEMR session in the process list shows an encrypted connection for that account.

  7. Test that plaintext and wrong-certificate connections fail

    The tester attempts a connection to the database from the OpenEMR host with TLS disabled and expects the server to refuse it for the OpenEMR account. The tester then attempts a verified connection using a CA file that does not match the server certificate, or a hostname that does not match, and expects the handshake to fail. Keep these negative tests as a repeatable script in your change records, because they show the controls work and catch future regressions after upgrades or certificate renewal. Done means both negative tests fail as designed and the results are filed with the positive test from the previous step.

Least-privilege database accounts that pair with TLS

Encrypting the connection only protects the data if the account using it is limited to what OpenEMR needs. Give the runtime application a dedicated database account that can reach only the OpenEMR schema, that is allowed to connect only over TLS, and that is not shared with administrative tools, reporting or backup jobs. If a credential leaks from the web tier, a shared administrative account would expose every database on the server, while a scoped account exposes one schema. Confirm in the MariaDB or MySQL documentation for your chosen version how the account's TLS requirement is set, since the option names and the way it is enforced in grants differ between server versions and between MariaDB and MySQL.

Keep the setup and upgrade account separate from the runtime account. Installing OpenEMR, running schema changes during an upgrade and creating tables for a new module can require broader privileges, such as the ability to create or alter objects, than the web application should hold day to day. Use a distinct account for those tasks, grant it only for the maintenance window, and revoke or disable it afterward. Record who holds it, when it was granted and when it was removed. Before an OpenEMR upgrade, check the release notes for any new database requirements, then plan the elevation as a time-limited step rather than a permanent change to the runtime user.

MariaDB supports role-based access control and pluggable authentication, which helps when you manage several accounts across environments. Roles can bundle the privileges the runtime account needs so they are granted in one place, and pluggable methods such as the ed25519 plugin, PAM or GSSAPI may fit your identity model. Confirm which authentication methods and role features your chosen MariaDB version supports before you design the account model around them, and test that the OpenEMR connection still works after each change. Verify the result by checking the grants on each account and confirming that a connection without TLS is refused.

Security and operational risks to manage

Database TLS fails in predictable ways: certificates expire, keys leak, teams quietly fall back to plaintext, and weak settings persist long after go-live. The cards below cover the risks that appear once OpenEMR and MariaDB talk across a network, and the checks that catch them before a clinic is affected.

Certificate expiry and rotation

A database server certificate that expires will cause OpenEMR connections to fail, often at a time nobody is watching, such as a weekend or a Docker image rebuild. Record the validity dates of the server certificate and the CA, assign an owner, and set alerts well before expiry. Rehearse a rotation in a test environment, confirming that the application container picks up the new certificate without a stale cached file. Ask whether rotation requires restarting the OpenEMR containers and the database service.

Private CA key protection

If you issue database certificates from an internal certificate authority, the CA private key is the most sensitive item in the chain. Anyone holding it can mint a certificate that OpenEMR will trust for the database hostname. Keep the CA offline or in a hardware-backed store, restrict who can sign, and log every issuance. Store only the CA certificate and the leaf certificate on the OpenEMR host, and confirm that no private key for the CA is copied into deployment repositories or backups.

Plaintext fallback during migration

During a move to a separate database host, teams often leave the connection unencrypted so the cutover works, then never enable TLS. Make the encrypted setting part of the cutover checklist rather than a follow-up task. Verify on the database side that the active session for the OpenEMR account reports an encrypted connection, and check that no configuration file retains a fallback option. Confirm that the database also refuses plaintext for the OpenEMR account if your server settings allow it.

Cipher and protocol choices

Default TLS settings change between MariaDB releases and between operating system packages, so a configuration that worked at install may allow older protocols later. Check the protocol versions and cipher suites your MariaDB version supports against current MariaDB documentation, and pin the minimum protocol where the server allows it. Retest after each database minor upgrade. Ask your vendor or internal security team to confirm the accepted list for your environment instead of copying settings from older guides.

MariaDB server README

Logging rejected connections

When certificates or hostnames mismatch, the failures show up as connection errors in the OpenEMR logs and as refused handshakes on the database host. Without monitoring, the first sign of a problem is often a clinician reporting that the chart will not load. Forward database error logs and connection failure counts to your central log platform, and alert on handshake failures for the OpenEMR account. Repeated failures from an unexpected source can also indicate someone probing the database.

Backup and restore after certificate changes

Backups and restore procedures can break when certificates change, because a restored database host may carry an old certificate, or a restore script may use connection settings that no longer match. Test a full restore after every certificate authority or hostname change, and confirm that the restored instance accepts encrypted connections from OpenEMR. Keep copies of the CA certificate needed to validate the restored server, and record which certificate version each backup set was taken under.

How the OpenEMR application, TLS listener and database trust boundary fit

The request starts at a clinician's browser and reaches the web server that runs OpenEMR. The application host then opens a database connection across the network boundary to the MySQL or MariaDB host, and that link is the one this page encrypts. The database certificate must chain to a CA the application host trusts, and the database listener must be configured to require TLS. Check each hand-off, not only the browser connection.

Browser to OpenEMR to database, with the encrypted hop and the signing CA shown.

Limits to confirm in your environment

Encrypting the link between OpenEMR and its database depends on several layers agreeing: the database release, the OpenEMR and PHP versions, the container image and the hosting model. The cards below list the points to confirm before you commit to a design, because a setting that works on one layer can be unavailable or overridden on another.

TLS versions and ciphers

Confirm which TLS protocol versions and cipher suites your chosen MariaDB or MySQL release accepts and which ones your client libraries negotiate with OpenEMR's PHP runtime. Older defaults may be disabled on the server while the client still offers them, or the reverse. Test the handshake from the actual OpenEMR host, not from a workstation, and record the negotiated version. The MariaDB Server README lists TLS among its supported features, but the exact protocol and cipher policy for your release is something to verify in its documentation.

MariaDB server README

OpenEMR and PHP version support

Confirm that the OpenEMR release you run, and the PHP version it requires, support the connection options you plan to use, such as requiring a verified server certificate or a specific CA file. Recent releases require PHP 8.3 or later, so check the PHP build's bundled MySQL extension and OpenSSL support before you rely on a setting. Record the versions in the design document so an upgrade can be checked against the same list.

PHP requirement
8.3+
OpenEMR releases

How the Docker image passes SSL settings

Confirm how the OpenEMR container accepts database SSL and X.509 options, whether through environment variables, a mounted configuration file or the setup flow, and whether those values survive a container restart or image update. Check whether the setup script writes the database connection settings once and then ignores later changes. Mount certificate files read-only and confirm their file permissions inside the container, because a file the web process cannot read will fail silently or fall back to an unencrypted connection.

Managed database service controls

If the database runs as a managed service, confirm whether it enforces TLS for all connections, lets you require client certificates and provides a CA bundle you can pin. Some services offer a single toggle that applies to all clients, while others leave the choice to each client. Confirm the service's certificate rotation process and whether OpenEMR must be restarted or reconfigured when the server certificate changes, since an expired or rotated certificate can stop the application from connecting.

Least-privilege account scope

Confirm that the database account OpenEMR uses has only the privileges the application needs, and that it can be restricted to the connection methods you intend, such as requiring SSL for that user. Account-level TLS requirements are only effective if the account is not also reachable through a plaintext path from another host. Review which account the setup and upgrade procedures use, since an administrative account used for upgrades may need a different connection policy from the runtime account.

Documented risk for addressable specifications

Confirm with your compliance lead whether the HIPAA encryption implementation specification for transmission security is treated as addressable in your program. Addressable does not mean optional: you must either implement the specification, implement an equivalent measure, or document why it is not reasonable and what alternative you chose. Record that decision, the review date and the owner. A compliance review may ask for this record for any database link that is not encrypted, so keep it with the configuration evidence.

Addressable specifications
22

Questions teams ask before encrypting OpenEMR database traffic

Does a database on the same host as OpenEMR still need TLS?

Not always, but the answer depends on what the traffic crosses. When OpenEMR and MariaDB share one host and talk over a local socket or the loopback interface, network encryption adds little because no traffic leaves the machine. Once the database runs on another host, container network, or virtual network segment, the connection crosses infrastructure you may not fully control, and TLS becomes the normal control. Your assessor will also ask how you justified the decision in writing, so record the topology, who can reach the database port, and why a plaintext local connection is acceptable. Review that record again whenever the database moves.

How much effort does OpenEMR database TLS setup take, and what drives it?

The effort is driven less by the OpenEMR side than by the database platform and the certificate process around it. The main drivers are the number of database hosts and replicas, whether you already run an internal certificate authority, how many clients and services connect to the database, and whether you must enforce encryption for every account or only for OpenEMR. Each database server needs a certificate with correct subject names, a trust chain the OpenEMR container or host can validate, and a tested reconnect after restarts. Ask any partner to break its quote into database configuration, certificate issuance, OpenEMR connection changes, testing and documentation so you can see which parts scale with your topology.

Can our team enable OpenEMR database TLS without a partner?

Yes, if your team already administers MariaDB or MySQL, manages certificates, and can test a change in a non-production copy of OpenEMR. The work is conceptually simple: issue a server certificate, configure the database to require or verify TLS, point OpenEMR's Docker or host configuration at the CA file and the SSL options, and confirm the connection is encrypted. The risks lie in the details: a certificate with the wrong host name, an account that still permits plaintext, or a container that silently falls back. Check the current OpenEMR and MariaDB documentation for the exact option names in your release, because these change between versions. Bring in a partner when the database is shared by several systems or the team lacks certificate operations experience.

What does the work need from our side: certificate authority, change window and test environment?

You need three things before work starts. First, a certificate authority your clients trust, either an internal CA you operate or a commercial CA, plus a decision on whether OpenEMR verifies the server certificate or only encrypts the channel. Second, a change window agreed with clinical and operations staff, because database restarts interrupt logins, scheduled jobs and any interface that writes to the database. Third, a test environment that mirrors the production database version, network path and OpenEMR deployment, so you can prove the connection works before cutover. Also name an owner for database accounts, since least-privilege grants and password changes are part of the same change.

How are database TLS certificates rotated and renewed before they expire?

Treat the certificate as an operational asset with a named owner, an expiry date in your monitoring, and a documented replacement procedure. Expired server certificates are a common cause of sudden outages, because OpenEMR fails to connect once verification is enforced. Rotation usually means issuing a new certificate, updating the database server configuration, restarting or reloading the service, and updating the CA file on each OpenEMR host or container, so plan the order carefully to avoid a window where one side trusts only the old chain. Test the procedure in the staging environment before the first real renewal. Ask your provider how the rotation runbook covers Docker and multisite deployments, because each adds a copy of the configuration to keep in step.

What will a security assessor look for in OpenEMR database encryption?

An assessor will usually check that encryption is enforced rather than merely available, that the database accepts only encrypted connections for the OpenEMR account, and that the certificate is valid, unexpired and issued by a trusted authority. They will look for evidence: configuration files, a query that shows the current connection is encrypted, and a record of who approved the topology decision. Under the HIPAA Security Rule, the transmission security standard in 45 CFR 164.312(e) contains an addressable encryption specification, which means you must document whether you implement it and why. Confirm the exact control mapping with your compliance lead and the current HHS guidance, because the rule itself does not name a certification.

How is OpenEMR database TLS work quoted, and what should the quote include?

Quotes follow from a written scope, so the first step is agreeing what is in it. DeployOpen does not publish a price list, and most engagements are fixed-scope, with scope, deliverables and timelines agreed in writing before work starts. A useful quote lists the database topology covered, the certificate source, the OpenEMR configuration changes, the account and grant review, the test plan, the change and rollback steps, the handover documentation, and any retest or rotation runbook. Ask whether the quote includes a post-change verification and whether ongoing certificate renewal is a separate retainer. Compare quotes on the same topology and deliverables rather than on headline effort.

How DeployOpen scopes database TLS work for OpenEMR

DeployOpen scopes database TLS work in writing before any configuration changes are made. The first step is confirming the facts that decide the design: the OpenEMR release and PHP version in use, the MySQL or MariaDB server version and whether the database runs on the same host, a separate virtual machine, a managed service or a container network. The scope also records which deployment method is in place, whether that is Docker, the Ubuntu installer or another packaging, because the way OpenEMR reads database connection settings and the certificate files it can reach differs between them. Ask your engineers to confirm these details against your own environment rather than from memory, since a topology drawn from an older diagram is a common source of rework.

The written scope then settles three decisions that cost the most to change later. The first is the certificate source: an internal certificate authority, a public authority or a platform-issued certificate, along with who holds the private key and how renewal is triggered. The second is the account model, meaning which database accounts the OpenEMR application uses day to day, which account runs schema upgrades, and which account is used for administration, with each granted only the privileges its job requires. The third is the verification method, such as confirming that a session to the database reports an encrypted connection and that connections without TLS are refused for the application account. Each decision should name an owner on your side, so that the people who will later review the configuration can trace it back to an agreed choice.

DeployOpen implements and tests the configuration in your infrastructure, using your cloud accounts, data center or air-gapped network, and leaves behind documentation your compliance and security teams can review. That documentation covers the configuration settings, certificate inventory, account privileges, test results and the steps used to reproduce them. It is evidence of how the controls were built and checked, not an audit report or certification, and independent assessors decide whether it satisfies their requirements. Ongoing needs such as certificate rotation, database minor upgrades and OpenEMR release upgrades can be handled under a retainer, which should be quoted separately from the fixed-scope build so that recurring work is visible from the start.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.