Skip to content

fix: use PyMySQL ssl dict keys (ca, cert, key) in SSLManager.setup_ssl (#36946) - #37359

Merged
akashverma0786 merged 6 commits into
open-metadata:mainfrom
zerafachris:fix/mysql-ssl-config-ca-36946
Nov 17, 2026
Merged

akashverma0786 merged 6 commits into
open-metadata:mainfrom
zerafachris:fix/mysql-ssl-config-ca-36946

Conversation

@zerafachris

@zerafachris zerafachris commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #36946

Context

#37553 (merged to main) already switched SSLManager.setup_ssl for MySQL, Doris and StarRocks to PyMySQL's ca/cert/key keys inside the ssl dict. This PR is now built on top of that fix and covers what it leaves open. All three connectors use PyMySQL (Doris through DorisPyMySQLDialect), so one handler covers them.

What changed and why

  • Top-level SSL options no longer drop sslConfig. When any of ssl_ca, ssl_cert, ssl_key, ssl_verify_cert or ssl_verify_identity is truthy in connectionArguments, PyMySQL replaces the whole ssl dict with one built from those options, so the sslConfig CA and client certificate are discarded. _nest_pymysql_ssl_options moves them into the ssl dict instead (top-level values win), keeps PyMySQL's meaning of ssl_verify_cert/ssl_verify_identity, and nests ssl_key_password as password. String values are resolved through CustomSecretStr first, since secrets are only resolved for top-level arguments.
  • setup_ssl works on a deep copy. get_ssl_connection (profiler, sampler, test suite) sets up the same config object once per interface; mutating it in place would lose the top-level overrides after the first call.
  • Doris and StarRocks set up SSL once. Their __init__ ran setup_ssl before CommonDbSourceService.__init__ ran it again, writing a second set of certificate temp files and orphaning the first manager's files (never cleaned up). The duplicate __init__ is removed.

Test evidence

  • pytest tests/unit/test_ssl_manager.py tests/unit/test_ssl_manager_pymysql.py tests/unit/source/database/test_mysql_iam.py: 78 passed (PyMySQL 2.2.8).
  • The 19 new cases in test_ssl_manager_pymysql.py build a real pymysql.Connection(defer_connect=True) from the resulting arguments; 15 of them fail against main's ssl_manager.py / Doris / StarRocks sources (the other 4 pin behaviour PyMySQL already had).
  • ruff check and ruff format --check: clean.

Prepared with AI assistance (OpenCode), reviewed for correctness before submission.


Summary by Gitar

  • Top-level SSL arguments:
    • Maps ssl_ca, ssl_cert, ssl_key, ssl_verify_cert, and ssl_verify_identity into the nested ssl dict in SSLManager.setup_ssl
    • Resolves ssl_key_password before nesting it as password
  • Connection copying:
    • Uses model_copy(deep=True) so reused connection objects keep their original overrides
  • Source cleanup:
    • Removes duplicate SSL handling from doris/metadata.py and starrocks/metadata.py

This will update automatically on new commits.

@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically.

Maintainers can bypass this check by adding the skip-pr-checks label.

@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

@ayush-shah ayush-shah added the safe to test Add this label to run secure Github workflows on PRs label Nov 9, 2026
@github-actions github-actions Bot removed the safe to test Add this label to run secure Github workflows on PRs label Nov 9, 2026
@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

@ayush-shah ayush-shah added safe to test Add this label to run secure Github workflows on PRs and removed safe to test Add this label to run secure Github workflows on PRs labels Nov 9, 2026
@sonarqubecloud

sonarqubecloud Bot commented Nov 9, 2026

Copy link
Copy Markdown

ayush-shah and others added 2 commits November 12, 2026 12:57
Main switched the PyMySQL ssl dict to ca/cert/key in open-metadata#37553 and added its own
tests. Take main's text unchanged so the branch merges cleanly, keep the deep
copy, move the top-level SSL option folding into _nest_pymysql_ssl_options,
and move the branch tests main does not cover into test_ssl_manager_pymysql.py.
@gitar-bot

gitar-bot Bot commented Nov 13, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 🔴 High risk

Changing SSL option handling for MySQL, Doris, and StarRocks could weaken certificate validation or prevent secure database connections if options are misinterpreted.

Fixes MySQL, Doris, and StarRocks SSL setup by nesting top-level ssl_ca, ssl_cert, ssl_key, ssl_verify_cert, and ssl_verify_identity options into PyMySQL's ssl dict so sslConfig certificates are no longer dropped, and by deep-copying the connection config so reused overrides persist. Duplicate SSL initialization in Doris and StarRocks is removed. No issues found.

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@akashverma0786
akashverma0786 merged commit fef3eb7 into open-metadata:main Nov 17, 2026
49 of 50 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

safe to test Add this label to run secure Github workflows on PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MySQL sslConfig CA is never used: server certificate not verified

4 participants