MariaDB Mutual TLS (mTLS) — Execution Runbook

Environment: OVHcloud MariaDB database host
Operating system: Red Hat Enterprise Linux 9.8
Database: MariaDB 10.11
Operator: Anthony
Scope: Initial certificate setup and testing on the existing OVHcloud database server.

Objective: Configure MariaDB to support mutual TLS authentication between the database server and the ServiceNow application server.

With mTLS confirmed, we need more than a trusted database server certificate. We need certificates for both sides of the connection.

CertificateUsed by
CA certificateBoth servers to validate certificate chains
Database server certificate + keyMariaDB to identify itself
Application client certificate + keyServiceNow/JDBC to identify itself to MariaDB

Success criteria: MariaDB starts with TLS enabled, accepts a connection presenting a valid client certificate, and rejects the same test account when a required client certificate is absent.

We’ll use the existing OVHcloud host as the test environment and keep this first runbook focused on executable commands and validation, not educational material.

Phase 1 — Inspect the existing database host

Run these commands on the OVHcloud MariaDB host. Read-only; no configuration changes.

Anthony — MariaDB mTLS Setup

Phase 1: Host inspection

Target: OVHcloud MariaDB host
Platform: RHEL 9.8 / MariaDB 10.11
Purpose: Establish the existing configuration before generating certificates.

Step 1 — Confirm the operating system and database

cat /etc/redhat-release

mariadb –version

sudo systemctl status mariadb –no-pager

Step 2 — Check certificate-generation tools

openssl version

command -v openssl

command -v keytool

keytool is not required on the database host. OpenSSL is sufficient for generating TLS certificates.

Step 3 — Check existing MariaDB TLS configuration

sudo mariadb -e “SHOW GLOBAL VARIABLES LIKE ‘have_ssl’;”

sudo mariadb -e “SHOW GLOBAL VARIABLES LIKE ‘ssl_%’;”

Inspect the configuration files:

sudo grep -RniE ‘ssl|tls|require_secure_transport’ \

  /etc/my.cnf /etc/my.cnf.d/ 2>/dev/null

Step 4 — Inspect SELinux

getenforce

sestatus

Inspect existing file contexts:

sudo ls -ldZ /var/lib/mysql

sudo ls -ldZ /etc/my.cnf.d

Check recent access denials:

sudo ausearch -m AVC,USER_AVC -ts recent

Step 5 — Identify existing certificates

sudo find /etc/pki /etc/mysql /var/lib/mysql \

  -type f \( \

    -name ‘*.pem’ -o \

    -name ‘*.crt’ -o \

    -name ‘*.key’ \

  \) -print 2>/dev/null

Do not delete, replace, or regenerate existing certificates during this inspection.

Step 6 — Verify MariaDB is listening

sudo ss -lntp | grep 3306

Phase 1 completion

Record the output of each command, excluding any credentials or private-key contents.

Do not restart MariaDB yet.


Phase 2 — Certificate generation

After confirming the existing configuration, generate or reuse:

  1. A trusted CA certificate and private key.
  2. A CA-signed MariaDB server certificate and private key.
  3. A CA-signed application client certificate and private key.

Both issued certificates must contain the appropriate identity and usage extensions.

The server certificate must identify the actual database hostname used by JDBC.

The client certificate must be usable for TLS client authentication.

The CA private key remains protected and is never distributed to the application server.

Phase 3 — MariaDB configuration

Configure MariaDB with:

[mariadb]

ssl_ca=/path/to/ca.pem

ssl_cert=/path/to/server-cert.pem

ssl_key=/path/to/server-key.pem

Configure the ServiceNow database account to require an X.509 client certificate.

Validate file permissions, SELinux contexts, and MariaDB TLS settings before restarting the service.

Phase 4 — Application server

Transfer the approved public CA certificate and the application client certificate and private key using the authorized secure-transfer procedure.

Configure the Java application with:

  • A truststore containing the CA certificate.
  • A client keystore containing the application certificate and its private key.
  • JDBC TLS configuration that validates the database server certificate and presents the client certificate.

The existing ServiceNow/KMF keystore must not be overwritten.

Phase 5 — Validation

Verify:

  • MariaDB starts with TLS enabled.
  • The application can establish a verified TLS connection.
  • The database account authenticates with its valid client certificate.
  • The same account cannot connect without its required certificate.
  • SELinux reports no relevant access denials.

Completion: Mutual TLS is verified independently before the full ServiceNow installation is attempted.

What we do right now

Run Phase 1, Steps 1–4 on the MariaDB host and send me the output.

Then we’ll determine exactly where to generate and store the certificates, which SELinux labels are needed, and how to configure MariaDB without disrupting the working database.

We will build the subsequent phases from the actual host configuration rather than assume its certificate paths or security policy.

The Brand New Content

Phase 3.1 — Certificate Origins and File Placement

Purpose: Identify which certificate files originate on the MariaDB host, which are issued by the Certificate Authority (CA) server, and where each file must be installed.

MariaDB requires three files for the following TLS configuration:

[mariadb]

ssl_ca=/path/to/ca.pem

ssl_cert=/path/to/server-cert.pem

ssl_key=/path/to/server-key.pem

Certificate origins

FileOriginPurpose
ca.pemCA serverPublic CA certificate used by MariaDB to validate trusted client certificates
server-cert.pemSigned and issued by CA serverIdentifies the MariaDB server to connecting clients
server-key.pemGenerated on MariaDB hostPrivate key belonging to the MariaDB server

All three files must ultimately exist on the MariaDB host, at the paths specified in the MariaDB configuration.

Certificate generation and signing workflow

Step 1 — MariaDB host

Generate the MariaDB server’s private key (server-key.pem) and a Certificate Signing Request (CSR).

The CSR contains the server’s public key and requested identity information. It does not contain the private key.

Step 2 — CA server

Transfer the CSR to the CA server using an approved secure-transfer method.

The CA signs the CSR using its private signing key and issues the MariaDB server certificate (server-cert.pem).

Step 3 — CA server

Obtain the CA’s public certificate (ca.pem).

This certificate allows MariaDB to validate client certificates issued by the trusted CA.

Step 4 — MariaDB host

Transfer the following files from the CA server to the MariaDB host:

  • server-cert.pem — Signed MariaDB server certificate
  • ca.pem — Public CA certificate

The MariaDB host now possesses all three required files:

MariaDB Host

├── ca.pem             ← From CA server

├── server-cert.pem    ← Signed by CA server

└── server-key.pem     ← Generated locally

Private key security requirements

  • The CA private signing key (ca-key.pem) must remain protected on the CA server.
  • The MariaDB private key (server-key.pem) must remain on the MariaDB host.
  • Never transfer the CA private signing key to MariaDB or the application server.
  • Configure file ownership and permissions so the MariaDB service account can read its required certificate files without granting unnecessary access.
  • Verify SELinux file contexts and access permissions while SELinux is enforcing.

Application server certificate workflow

The ServiceNow application server follows the same general process:

  1. Generate its own client private key and CSR.
  2. Send the CSR to the CA server for signing.
  3. Receive the signed client certificate and public CA certificate.
  4. Configure its client keystore and CA truststore.

The application server’s private key must remain separate from the MariaDB server’s private key.

Completion criteria

Before proceeding with MariaDB TLS configuration, verify that:

  • ca.pem, server-cert.pem, and server-key.pem exist on the MariaDB host.
  • The server certificate corresponds to the locally generated private key.
  • The server certificate was signed by the expected CA.
  • The certificate contains the correct server identity and TLS server authentication usage.
  • The MariaDB service account has the required file access.
  • SELinux remains enforcing.

Do not restart MariaDB until the certificate files, ownership, permissions, and configuration paths have been verified.

Add a concise handoff summaryAdd exact verification commands

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *