MySQL sslConfig CA is never used: server certificate not verified

Đang mở Phù hợp với người mới
#36,946 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
82/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
mysql, python
Lĩnh vực
databases

Hướng nghiên cứu

Bắt đầu từ ingestion/src/metadata/utils/ssl_manager.py và theo dõi cách SSLManager.setup_ssl tạo dict ssl cho MySQL, Doris và StarRocks. Kiểm tra cách PyMySQL đọc các tùy chọn SSL bên trong dict đó; hoàn thành khi CA được dùng để xác minh máy chủ và CA sai khiến kết nối thất bại.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Connector

MySQL

Feature area

Authentication / Connection

Describe the bug

A MySQL connection with sslConfig.caCertificate set encrypts the connection but never verifies the server certificate, and sslCertificate/sslKey are never presented.

SSLManager.setup_ssl for MysqlConnection (also Doris and StarRocks) builds connectionArguments["ssl"] = {"ssl_ca": ..., "ssl_cert": ..., "ssl_key": ...}. That dict is passed to PyMySQL as ssl=, and PyMySQL's _create_ssl_ctx reads the keys ca, cert and key. With no ca it sets verify_mode = CERT_NONE and check_hostname = False:

>>> Connection._create_ssl_ctx(None, {"ssl_ca": "ca.pem"})   # what OpenMetadata passes
verify_mode=CERT_NONE check_hostname=False
>>> Connection._create_ssl_ctx(None, {"ca": "ca.pem"})
verify_mode=CERT_REQUIRED check_hostname=True

(PyMySQL 2.2.8, as shipped with openmetadata-ingestion 2.1.0.0.) ssl_ca/ssl_cert/ssl_key are valid as top-level pymysql.connect keyword arguments, but not inside the ssl dict.

To Reproduce
  1. Set sslConfig.caCertificate on a MySQL service.
  2. Build the connection arguments with SSLManager.setup_ssl and pass the resulting ssl dict to pymysql.connections.Connection._create_ssl_ctx.
  3. The context has verify_mode=CERT_NONE and check_hostname=False, as shown above. I have not run a live connection against a wrong CA.
Expected behavior

The CA is used to verify the server (ca, cert, key inside the ssl dict), so a wrong CA fails the connection.

OS

Kubernetes (ingestion-base image)

Python version

3.12

OpenMetadata version

2.0.6

OpenMetadata Ingestion package version

openmetadata-ingestion==2.0.6.0; same code on main (ingestion/src/metadata/utils/ssl_manager.py).

Pre-submission checklist
  • I searched for duplicate issues.
  • I removed credentials, hostnames, emails, and other sensitive data from logs and config.
Ngôn ngữ chính
TypeScript
Star
15.4k
Fork
2.4k
Merge trung bình
1 ngày 5 giờ
Pull request đã merge (30 ngày)
774

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của open-metadata/OpenMetadata

Tất cả issue của open-metadata/OpenMetadata

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.