Bug 41099 - koha-mysql doesn't work out of the box on Debian 13
Summary: koha-mysql doesn't work out of the box on Debian 13
Status: RESOLVED WORKSFORME
Alias: None
Product: Koha
Classification: Unclassified
Component: Command-line Utilities (show other bugs)
Version: unspecified
Hardware: All All
: P5 - low major
Assignee: Tomás Cohen Arazi (tcohen)
QA Contact: Victor Grousset/tuxayo
URL:
Keywords:
Depends on:
Blocks: 41077
  Show dependency treegraph
 
Reported: 2025-10-24 18:45 UTC by Tomás Cohen Arazi (tcohen)
Modified: 2025-12-04 14:27 UTC (History)
6 users (show)

See Also:
GIT URL:
Initiative type: ---
Sponsorship status: ---
Comma delimited list of Sponsors:
Crowdfunding goal: 0
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Bug 41099: Make `koha-mysql` disable SSL if required (1.53 KB, patch)
2025-10-24 18:57 UTC, Tomás Cohen Arazi (tcohen)
Details | Diff | Splinter Review
Bug 41099: Make `koha-mysql` disable SSL if required (1.65 KB, patch)
2025-10-28 01:52 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 41099: Make `koha-mysql` disable SSL if required (1.70 KB, patch)
2025-10-28 03:21 UTC, David Nind
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Tomás Cohen Arazi (tcohen) 2025-10-24 18:45:33 UTC
The shipped mysql client on Debian 13 has `ssl=on` by default. So, on newer Debian and Ubuntu versions, we would need to add a configuration step for disabling SSL if you're not using it.

I propose we disable it by default in `koha-mysql` as we are already setting `ssl=on` when SSL/TLS is properly configured in Koha (i.e. it is a change that will keep the current behavior, both of them).
Comment 1 Tomás Cohen Arazi (tcohen) 2025-10-24 18:57:18 UTC
Created attachment 188434 [details] [review]
Bug 41099: Make `koha-mysql` disable SSL if required

Now that Debian 13 (and Ubuntu 25.04) set `ssl=on` by default, we should
make the `koha-mysql` helper script disable it by default if not
configured.
This patch does that.
To test:
1. Run:
   $ ktd --shell
  k$ koha-mysql kohadev
=> SUCCESS: You get into the DB shell
2. Apply this patch
3. Run:
  k$ debian/scripts/koha-mysql kohadev
=> SUCCESS: It works as step 1!
4. Make sure you enable SSL in my.cnf:
[client]
ssl = on
5. Repeat 1
=> FAIL: You get an error about SSL in the server being disabled
6. Repeat 4
=> SUCCESS: The patch fixes it!
7. This steps imply we reproduced the issue, and it gets fixed, while
   keeping the current behavior.
8. Sign off :-D
Signed-off-by: Tomás Cohen Arazi <tomascohen@theke.io>
Comment 2 Tomás Cohen Arazi (tcohen) 2025-10-24 18:57:20 UTC
Now that Debian 13 (and Ubuntu 25.04) set `ssl=on` by default, we should
make the `koha-mysql` helper script disable it by default if not
configured.
This patch does that.
To test:
1. Run:
   $ ktd --shell
  k$ koha-mysql kohadev
=> SUCCESS: You get into the DB shell
2. Apply this patch
3. Run:
  k$ debian/scripts/koha-mysql kohadev
=> SUCCESS: It works as step 1!
4. Make sure you enable SSL in my.cnf:
[client]
ssl = on
5. Repeat 1
=> FAIL: You get an error about SSL in the server being disabled
6. Repeat 4
=> SUCCESS: The patch fixes it!
7. This steps imply we reproduced the issue, and it gets fixed, while
   keeping the current behavior.
8. Sign off :-D
Signed-off-by: Tomás Cohen Arazi <tomascohen@theke.io>
Comment 3 David Nind 2025-10-25 20:00:46 UTC
For step 3 and 4 of the test plan, do I need to do anything else?

I don't get an SSL failure error.

Using KTD with Debian 12. Do I need to use a Debian 13 image?
Comment 4 Victor Grousset/tuxayo 2025-10-28 01:52:36 UTC
Created attachment 188493 [details] [review]
Bug 41099: Make `koha-mysql` disable SSL if required

Now that Debian 13 (and Ubuntu 25.04) set `ssl=on` by default, we should
make the `koha-mysql` helper script disable it by default if not
configured.

This patch does that.

To test:
0. Start a Debian 13 KTD e.g. with:
   $ KOHA_IMAGE=main-trixie ktd up
1. Run:
   $ ktd --shell
  k$ koha-mysql kohadev
=> SUCCESS: You get into the DB shell
2. Apply this patch
3. Run:
  k$ debian/scripts/koha-mysql kohadev
=> SUCCESS: It works as step 1!
4. Make sure you enable SSL in my.cnf:

[client]
ssl = on

5. Repeat 1
=> FAIL: You get an error about SSL in the server being disabled
6. Repeat 4
=> SUCCESS: The patch fixes it!
7. This steps imply we reproduced the issue, and it gets fixed, while
   keeping the current behavior.
8. Sign off :-D

Signed-off-by: Tomás Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Comment 5 Victor Grousset/tuxayo 2025-10-28 01:56:19 UTC
It works!

(In reply to David Nind from comment #3)
> Using KTD with Debian 12. Do I need to use a Debian 13 image?

Yes, I amended the test plan to reflect this.


Also, with MariaDB 12 (latest) the issue isn't reproducible. But with the default (10.5) it can be reproduced. So anyone else having trouble should also check that.
Comment 6 David Nind 2025-10-28 03:21:38 UTC
Created attachment 188495 [details] [review]
Bug 41099: Make `koha-mysql` disable SSL if required

Now that Debian 13 (and Ubuntu 25.04) set `ssl=on` by default, we should
make the `koha-mysql` helper script disable it by default if not
configured.

This patch does that.

To test:
0. Start a Debian 13 KTD e.g. with:
   $ KOHA_IMAGE=main-trixie ktd up
1. Run:
   $ ktd --shell
  k$ koha-mysql kohadev
=> SUCCESS: You get into the DB shell
2. Apply this patch
3. Run:
  k$ debian/scripts/koha-mysql kohadev
=> SUCCESS: It works as step 1!
4. Make sure you enable SSL in my.cnf:

[client]
ssl = on

5. Repeat 1
=> FAIL: You get an error about SSL in the server being disabled
6. Repeat 4
=> SUCCESS: The patch fixes it!
7. This steps imply we reproduced the issue, and it gets fixed, while
   keeping the current behavior.
8. Sign off :-D

Signed-off-by: Tomás Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Signed-off-by: David Nind <david@davidnind.com>
Comment 7 David Nind 2025-10-28 03:22:52 UTC
(In reply to Victor Grousset/tuxayo from comment #5)
> It works!
> 
> (In reply to David Nind from comment #3)
> > Using KTD with Debian 12. Do I need to use a Debian 13 image?
> 
> Yes, I amended the test plan to reflect this.
> 
> 
> Also, with MariaDB 12 (latest) the issue isn't reproducible. But with the
> default (10.5) it can be reproduced. So anyone else having trouble should
> also check that.

Thanks Victor!

Using a Debian 13 image worked.

I've added my sign off, so your sign off can probably be counted as QA.

David
Comment 8 Tomás Cohen Arazi (tcohen) 2025-10-28 14:09:50 UTC
Thanks for the amended test plan. I wrote it without explicitly mentioning Debian 13 because the issue was reproducible by tweaking the mysql config. And by the time I submitted the main-trixie image was not tweaked to launch regardless of this fix.

But it is great that we test on Debian 13. Once we push this patch, we can remove the workaround on KTD.

Thanks everyone!
Comment 9 Victor Grousset/tuxayo 2025-10-29 07:15:57 UTC
(In reply to David Nind from comment #7)
> so your sign off can probably be counted as QA.

By default no. But here it's ok.

(In reply to Tomás Cohen Arazi (tcohen) from comment #0)
> I propose we disable it by default in `koha-mysql` as we are already setting
> `ssl=on` when SSL/TLS is properly configured in Koha (i.e. it is a change
> that will keep the current behavior, both of them).

Let's do this indeed.

I just tested with mysql 8 and no issue. Expected since the client is still mariadb's.

Works, makes sense, QA script happy, code looks good, passing QA :)
Comment 10 Lucas Gass (lukeg) 2025-10-29 21:29:36 UTC
Pushed to main for 25.11.00
Comment 11 Lucas Gass (lukeg) 2025-10-31 17:27:07 UTC
This has been reverted from main upon Tomas's request.
Comment 12 Tomás Cohen Arazi (tcohen) 2025-10-31 20:16:12 UTC
(In reply to Lucas Gass (lukeg) from comment #11)
> This has been reverted from main upon Tomas's request.

There's no elegant solution that works for everyone, at `koha-mysql` level. The `mysql` command (be it from MariaDB or MySQL) on each of the supported OS versions has really different behaviors:


| Version       | SSL Disable Method        |  Status         |
|---------------|---------------------------|-----------------|
| MySQL 5.7     | None reliable             | Omit SSL config |
| MySQL 8.0+    | `ssl=off`                 | Supported       |
| MariaDB 10.5  | `ssl=off`                 | Supported       |
| MariaDB 10.6  | `ssl=off`                 | Supported.      |
| MariaDB 10.11 | `ssl=off` or `--skip-ssl` | Both supported  |
| MariaDB 11.4+ | `ssl-mode=DISABLED`       | Supported       |

I suggest we add something like this at KTD level, in `run.sh`:

```bash
# Detect database version
DB_VERSION=$(mysql --version | grep -oE '[0-9]+\.[0-9]+')
DB_TYPE=$(mysql --version | grep -q MariaDB && echo "mariadb" || echo "mysql")

# Set SSL parameter based on version
if [[ "$DB_TYPE" == "mysql" ]]; then
    if [[ "$DB_VERSION" == "5.7" ]]; then
        SSL_PARAM=""  # No reliable disable option
    else
        SSL_PARAM="ssl=off"
    fi
elif [[ "$DB_TYPE" == "mariadb" ]]; then
    case "$DB_VERSION" in
        10.5|10.6)
            SSL_PARAM="ssl=off"
            ;;
        10.11)
            SSL_PARAM="ssl=off"  # or --skip-ssl
            ;;
        11.*)
            SSL_PARAM="ssl-mode=DISABLED"
            ;;
        *)
            SSL_PARAM="ssl=off"  # fallback
            ;;
    esac
fi
```
Comment 13 Victor Grousset/tuxayo 2025-11-03 09:34:03 UTC
> MariaDB 11.4+ | `ssl-mode=DISABLED`

Are you sure it's the only possible option?
On version 11.8.3-MariaDB client (in Debian 13)
I have ssl = off in my.cnf

$ mysql --help | grep ssl
[...]
  --ssl               Enable SSL for connection (automatically enabled with
                      (Defaults to on; use --skip-ssl to disable.)
[...]
ssl                               FALSE
[...]

And no ssl-mode=DISABLED in sight, I find that in mysql doc however.

Same on version 10.11 from  Debian 12
And if I switch to ssl = off in my.cnf, the --help shows TRUE for ssl

Does MySQL have an influence here? It's for KTD for the client in the koha container which I think comes from the mariadb-client. Regardless of using mysql for the db container.
Comment 14 Tomás Cohen Arazi (tcohen) 2025-11-03 16:45:10 UTC
(In reply to Victor Grousset/tuxayo from comment #13)
> 
> Does MySQL have an influence here? It's for KTD for the client in the koha
> container which I think comes from the mariadb-client. Regardless of using
> mysql for the db container.

Right. But that's the reason to revert this patch, as there is no proper solution for production sites which *could* prefer to stick to MySQL.

That's the reason for making it a KTD-specific fix and updating the docs to let people know how to workaround it on affected systems.
Comment 15 Victor Grousset/tuxayo 2025-11-05 16:04:09 UTC
I meant the PoC for new proposal in comment 12 could just set ssl=off without any condition. As it's just for the dev and CI container so the client is mariadb-client which seem to support ssl=off in all versions.
Comment 16 Tomás Cohen Arazi (tcohen) 2025-11-09 22:33:59 UTC
(In reply to Victor Grousset/tuxayo from comment #15)
> I meant the PoC for new proposal in comment 12 could just set ssl=off
> without any condition. As it's just for the dev and CI container so the
> client is mariadb-client which seem to support ssl=off in all versions.

I tried that and it didn’t work on some versions.
Comment 17 Victor Grousset/tuxayo 2025-11-13 17:24:57 UTC
> I tried that and it didn’t work on some versions.

It likely is related to "TLS/SSL error: SSL is required" only happening on MariaDB < 11.4.

So the failing versions are 10.11, 10.6, 10.5, 10.3
(I didn't try 10.1, too old. And non LTS versions.)

Like I can't reproduce the issue on 11.4 and 12.0.
And if I add

[client]
ssl = on

or

[client]
ssl = off


`koha-mysql kohadev` will still work.


`mysql --help | grep ssl` confirms the ssl = on/off config is read and default to ssl = on

What was your approach to get failures with MariaDB >= 11.4? Whether koha-mysql or the KTD startup.
Comment 18 Tomás Cohen Arazi (tcohen) 2025-12-04 14:27:42 UTC
I worked around this on KTD. If someone wants to write a how-to on the Koha_on_Debian wiki entry, they can do it. For now, this is done.