Fixing a Rails database connection between MariaDB client & MySQL 8.4 in the GitLab CI
As the title suggests, this is a short technical post.
I spent too much time today trying to figure out how to fix my GitLab pipeline after upgrading the Ruby version in a Rails app from 3.4.2 to 3.4.5.
The Problem
I have two jobs that connect to the MySQL 8.4 database service: one for testing migrations and one for the RSpec test suite. Both jobs failed quickly with the following error message:
ERROR 2026 (HY000): TLS/SSL error: self-signed certificate in certificate chain
bin/rails aborted!
failed to execute: `mysql`
The solution
I'm still not sure what the root cause of the issue is, but I think it's related to the Ruby Docker images I use. I've switched from ruby:3.4.2-slim
to ruby:3.4.5-slim
.
I realized that I have to disable SSL certificate verification within the MariaDB client, so i added the following to my Dockerfile:
RUN touch ~/.my.cnf
RUN echo "[client] \ndisable-ssl-verify-server-cert" >> ~/.my.cnf
And voilĂ , my jobs are running like a charm again!
I hope this is helpful for you. Please bear in mind that disabling the SSL connection is usually undesirable in production environments. Have a good day and happy debugging!
#ruby #ruby345 #rails8 #mysql2gem #debugging #rails
Follow my Mastodon profile: https://social.tchncs.de/@whereareyoutakingme Follow my blog on the Fediverse: @whererutakingme@text.tchncs.de