Skip to content

MDEV-39857: Add ssl-alt-cert/ssl-alt-key for dual RSA+ECDSA certificate support#5178

Draft
rmetrich wants to merge 2 commits into
MariaDB:mainfrom
rmetrich:ssl-alt-cert
Draft

MDEV-39857: Add ssl-alt-cert/ssl-alt-key for dual RSA+ECDSA certificate support#5178
rmetrich wants to merge 2 commits into
MariaDB:mainfrom
rmetrich:ssl-alt-cert

Conversation

@rmetrich
Copy link
Copy Markdown

@rmetrich rmetrich commented Jun 4, 2026

MariaDB currently supports only a single SSL certificate, configured via --ssl-cert and --ssl-key.
Services like httpd, nginx and haproxy can serve both RSA and ECDSA certificates simultaneously, selecting the appropriate one based on the cipher suite negotiated with the client.

This adds --ssl-alt-cert and --ssl-alt-key options that load a second certificate/key pair into the same SSL_CTX. OpenSSL natively supports one certificate per key type (RSA, ECDSA, EdDSA) and automatically selects the matching certificate during the TLS handshake.

Example configuration:

  [mysqld]
  ssl-cert=/path/to/server-rsa.crt
  ssl-key=/path/to/server-rsa.key
  ssl-alt-cert=/path/to/server-ecdsa.crt
  ssl-alt-key=/path/to/server-ecdsa.key

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Jun 4, 2026

CLA assistant check
All committers have signed the CLA.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces dual RSA and ECDSA certificate support by adding the --ssl-alt-cert and --ssl-alt-key configuration options. It updates the SSL initialization logic to load these alternate credentials into the same SSL context and includes integration tests to verify that clients can connect using either RSA or ECDSA ciphers. The feedback suggests adding validation to ensure that if either the alternate certificate or key is provided, both must be specified, preventing the configuration from being silently ignored.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread vio/viosslfactories.c Outdated
@gkodinov gkodinov added the External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements. label Jun 4, 2026
MariaDB currently supports only a single SSL certificate, configured via
--ssl-cert and --ssl-key. Services like httpd, nginx, and haproxy can
serve both RSA and ECDSA certificates simultaneously, selecting the
appropriate one based on the cipher suite negotiated with the client.

This adds --ssl-alt-cert and --ssl-alt-key options that load a second
certificate/key pair into the same SSL_CTX. OpenSSL natively supports
one certificate per key type (RSA, ECDSA, EdDSA) and automatically
selects the matching certificate during the TLS handshake.

Example configuration:
  [mysqld]
  ssl-cert=/path/to/server-rsa.crt
  ssl-key=/path/to/server-rsa.key
  ssl-alt-cert=/path/to/server-ecdsa.crt
  ssl-alt-key=/path/to/server-ecdsa.key
@rmetrich rmetrich changed the title Add ssl-alt-cert/ssl-alt-key for dual RSA+ECDSA certificate support Add ssl-alt-cert/ssl-alt-key for dual RSA+ECDSA certificate support -- WIP Jun 4, 2026
@rmetrich rmetrich marked this pull request as draft June 4, 2026 09:20
@rmetrich rmetrich changed the title Add ssl-alt-cert/ssl-alt-key for dual RSA+ECDSA certificate support -- WIP Add ssl-alt-cert/ssl-alt-key for dual RSA+ECDSA certificate support Jun 4, 2026
The server must refuse to start if only one of the two alternate SSL
options is specified, since a certificate without its key (or vice versa)
cannot be used. Add an explicit check and error message, and add MTR
tests covering all four error scenarios: missing key, missing cert,
invalid cert file, and invalid key file.
@rmetrich rmetrich marked this pull request as ready for review June 4, 2026 11:55
Copy link
Copy Markdown
Member

@gkodinov gkodinov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution! This is a preliminary review.

I believe this needs to be designed well first. So please consider adding a Jira about it, as mentioned by the community contributions guidelines.

Also, please keep 1 commit per "feature". I believe in your case that should be 1 in total: makes it easier to merge later.

Now on the substance of the issue:

First of all: Great analysis! This is something we've missed for so many years. So, again, thanks for bringing this up!

Now on the execution: You are saying that OpenSSL (currently) supports 3 certificate chains (so far). And it's picking which one to use based on the cipher.
now, you're adding --ssl-alt-cert and --ssl-alt-key. Singular. This makes 2 cert/key pairs. What about the 3d? Or future ones?
Now, one thing you're not saying is that these certs need to come from the same cert chain. https://linux.die.net/man/3/ssl_ctx_use_certificate_file says that

SSL_CTX_use_certificate_file() loads the first certificate stored in file into ctx.

The first!

So you might end up needing --ssl-alt-ca etc.

And, finally, you have exactly the same issue on the client. Do you want to support multiple certificate chains on it too?

This is where some forethought and a good design would have been handy!

I have no strong preference here (it's the preliminary review too). But I'll pitch in some thoughts:

  1. make all tools take multiple --ssl-cert --ssl-key options. It solves the "multiple" design problem. But then you may need to somehow match the keys to the certs. Define that. I'd use positional matching: first cert matches with the first key etc. Not really needed by openssl, but it'd be nice to define for future use.
  2. keep all tools in lock-step: people by now are used to having the same options on the client and on the server.
  3. Consider switching to SSL_CTX_use_certificate_chain_file() when processing these files so you could keep the cert chain out of the --ssl-ca list.
  4. Consider exposing the current cert selected and/or the list of certs/keys available as status vars for observability. This will help with writing more meaningful tests too.
  5. Consider the effects on other SSL libraries mariadb supports. Will it work on e.g. wolfSSL? How exactly? Ditto GnuTLS. You might need to have a status variable for this alone. E.g. so that automated configs somehow know if this is supported or not.

Looking forward to the Jira with a good design that has all of these questions answered.

@rmetrich
Copy link
Copy Markdown
Author

rmetrich commented Jun 4, 2026

Regarding 2 certificates only, it's true OpenSSL can load up to 3, but I believe it's totally overkill for now, because EdDSA is not implemented currently by certificate providers.

Regarding --ssl-alt-ca it's also overkill because the CA is usually a bundle.

@rmetrich
Copy link
Copy Markdown
Author

rmetrich commented Jun 4, 2026

What do you mean by file a JIRA btw? it's the first time I contribute. I have an internal JIRA for Red Hat people but I guess it's a different one you need :-)

@gkodinov
Copy link
Copy Markdown
Member

gkodinov commented Jun 5, 2026

What do you mean by file a JIRA btw? it's the first time I contribute. I have an internal JIRA for Red Hat people but I guess it's a different one you need :-)

https://mariadb.com/docs/general-resources/community/contributing-participating/contributing-code#finding-development-projects-to-work-on says:

If you have your own ideas, please submit them to JIRA so other MariaDB developers can comment on them and suggest how to implement them.

https://jira.mariadb.org is the place to keep all features and bug reports.

@rmetrich rmetrich marked this pull request as draft June 5, 2026 08:10
@rmetrich
Copy link
Copy Markdown
Author

rmetrich commented Jun 5, 2026

What do you mean by file a JIRA btw? it's the first time I contribute. I have an internal JIRA for Red Hat people but I guess it's a different one you need :-)

https://mariadb.com/docs/general-resources/community/contributing-participating/contributing-code#finding-development-projects-to-work-on says:

If you have your own ideas, please submit them to JIRA so other MariaDB developers can comment on them and suggest how to implement them.

https://jira.mariadb.org is the place to keep all features and bug reports.

https://jira.mariadb.org/browse/MDEV-39857

@gkodinov gkodinov changed the title Add ssl-alt-cert/ssl-alt-key for dual RSA+ECDSA certificate support MDEV-39857: Add ssl-alt-cert/ssl-alt-key for dual RSA+ECDSA certificate support Jun 5, 2026
@gkodinov
Copy link
Copy Markdown
Member

gkodinov commented Jun 5, 2026

Regarding 2 certificates only, it's true OpenSSL can load up to 3, but I believe it's totally overkill for now, because EdDSA is not implemented currently by certificate providers.

Regarding --ssl-alt-ca it's also overkill because the CA is usually a bundle.

Well, in design IMHO there's one or many. But that's just me.
As for it being an overkill: that it may be atm. But I guess we should keep the richest possible design in mind and make sure it's not prevented in any way by the current steps.

Anyway, I said my peace. But to do a best-effort preliminary review. So I am not here to debate the choices. All I asked is to document these decisions intо the design (jira).

@gkodinov gkodinov self-assigned this Jun 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements.

Development

Successfully merging this pull request may close these issues.

3 participants