Skip to content

feat: support mtls for query api - #254

Merged
NguyenHoangSon96 merged 2 commits into
mainfrom
feat/support-mtls
Dec 4, 2026
Merged

NguyenHoangSon96 merged 2 commits into
mainfrom
feat/support-mtls

Conversation

@NguyenHoangSon96

@NguyenHoangSon96 NguyenHoangSon96 commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Closes #

Proposed Changes

  • Add support for mTLS for query API.
  • Add examples of how to configure mTLS.

Checklist

  • CHANGELOG.md updated
  • Rebased/mergeable
  • A test has been added if appropriate
  • Tests pass
  • Commit messages are conventional
  • Sign CLA (if not already signed)

@NguyenHoangSon96 NguyenHoangSon96 self-assigned this Nov 5, 2026
Copilot AI balanced review requested due to automatic review settings November 5, 2026 08:49
@NguyenHoangSon96
NguyenHoangSon96 marked this pull request as draft November 5, 2026 08:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

New required constructor parameters break existing non-mTLS callers, while invalid TLS certificate configurations prevent plaintext mock servers from initializing.

5 open issues
What changed in this PR

This PR adds mutual TLS (mTLS) support to Arrow Flight queries, extending the client’s certificate settings to the query API.

Changes:

  • Pass client certificates and private keys into Flight options, including bundled PEM support.
  • Add TLS and mTLS query/write tests and TLS-capable mock servers.
  • Add certificate fixtures and a script to regenerate them.
File Description
tests/​util/​mocks.py Adds TLS configuration to the Flight mock server.
tests/​test_influxdb_client_3.py Adds TLS and mTLS success and failure cases.
tests/​data/​certificates/​other-server.pem Bundled credentials for rejection tests.
tests/​data/​certificates/​other-server.key Private key for untrusted test credentials.
tests/​data/​certificates/​other-server.crt Certificate for rejection tests.
tests/​data/​certificates/​influxdb.pem Bundled server certificate and key.
tests/​data/​certificates/​influxdb.key Private key for TLS test servers.
tests/​data/​certificates/​influxdb.crt Certificate for trusted TLS test servers.
tests/​data/​certificates/​client.pem Bundled client credentials for mTLS tests.
tests/​data/​certificates/​client.key Client private key for mTLS tests.
tests/​data/​certificates/​client.crt Client certificate for mTLS tests.
scripts/​generate-self-signed-cert.sh Generates self-signed certificate fixtures.
influxdb_client_3/​query/​query_api.py Adds certificate options and forwards credentials to Flight.
influxdb_client_3/​__init__.py Connects client certificate settings to query options.

Review effort: Balanced

Comment thread influxdb_client_3/query/query_api.py Resolved
Comment thread tests/util/mocks.py Resolved
Comment thread influxdb_client_3/query/query_api.py Resolved
Comment thread tests/test_influxdb_client_3.py Resolved
Comment thread tests/test_influxdb_client_3.py Resolved
@NguyenHoangSon96
NguyenHoangSon96 force-pushed the feat/support-mtls branch 5 times, most recently from 6041d64 to 0d280ff Compare November 9, 2026 07:27
@codecov

codecov Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.15385% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.88%. Comparing base (9a05224) to head (d565a66).

Files with missing lines Patch % Lines
influxdb_client_3/query/query_api.py 94.44% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #254      +/-   ##
==========================================
- Coverage   89.45%   88.88%   -0.58%     
==========================================
  Files          28       28              
  Lines        2049     2096      +47     
==========================================
+ Hits         1833     1863      +30     
- Misses        216      233      +17     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Comment thread tests/test_influxdb_client_3.py Resolved
Comment thread tests/util/mocks.py Resolved
Comment thread influxdb_client_3/query/query_api.py Resolved
Comment thread scripts/generate-self-signed-cert.sh Resolved
Comment thread tests/data/certificates/client.key Resolved
Comment thread tests/test_influxdb_client_3.py Resolved
Comment thread tests/test_influxdb_client_3.py Resolved
Comment thread tests/test_influxdb_client_3.py Resolved
Comment thread tests/util/mocks.py Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Comment thread examples/core/basic_ssl.py Resolved
Comment thread influxdb_client_3/__init__.py Resolved
@NguyenHoangSon96
NguyenHoangSon96 force-pushed the feat/support-mtls branch 2 times, most recently from 9c5d659 to 136b1ca Compare November 10, 2026 10:44
@NguyenHoangSon96
NguyenHoangSon96 marked this pull request as ready for review November 10, 2026 11:26
Comment thread influxdb_client_3/query/query_api.py Resolved
@bednar
bednar removed their request for review November 30, 2026 08:08

@karel-rehor karel-rehor left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please take a second look at how keys and certificates are setup for CI test runs.

Comment thread tests/data/certificates/client.key Resolved
@NguyenHoangSon96
NguyenHoangSon96 force-pushed the feat/support-mtls branch 2 times, most recently from 3e51be9 to 953a777 Compare December 2, 2026 14:29

@karel-rehor karel-rehor left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Will continue review tomorrow. But have one comment that might be worth looking at.

@karel-rehor karel-rehor left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I see in the core changes for this PR that

  • mocks.py - mock ConstantFlightServer now reliably supports TLS/mTLS configurations
  • test_influxdb_client_3.py - subtests are used to verify tls and mtls use cases with certs and pems
    • core use cases seem to be complete
  • helpers.py - introduces read_certs to convert key/cert files to normalized bytes
  • query_api.py -
    • QueryApiOptionsBuilder & QueryApiOptions for tls/mtls support introduce
      • cert_chain
      • private_key
      • private_key_password
    • QueryApi
      • passes these to _flight_client_options
      • falls back to a pem file assumed to be the cert_chain when no key is provided
      • continues to use flight_client_options when instantiating the FlightClient.
  • __init__.py - checks for new kwargs passed to respectiv query options
    • cert_file
    • cert_key_file
    • cert_key_password

Local tests are passing with these changes, which all make sense.

However the example basic_ssl.py includes a constructor argument that appears to be incorrect.

Comment thread examples/core/basic_ssl.py Resolved

@karel-rehor karel-rehor left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good to me. 🚴 🏁

@NguyenHoangSon96
NguyenHoangSon96 merged commit 14a91b1 into main Dec 4, 2026
14 checks passed
@NguyenHoangSon96
NguyenHoangSon96 deleted the feat/support-mtls branch December 4, 2026 09:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants