Repository navigation
umbrella: certmgr adding support for fullchain PEM - #71513
Conversation
Prep step for moving the PEM-parsing functions (parse_tls_pem_bundle and friends) out to ceph.deployment.tls_utils in a following commit. Renaming first keeps that move commit a clean "delete from here, add over there" diff against the new filename, rather than mixing a rename and a content move in the same patch. ssl_certs.py will hold only the SSLCerts class once the move lands. No behavior change; import sites updated accordingly. Signed-off-by: Redouane Kachach <[email protected]> (cherry picked from commit 6bb1a84)
Add parse_tls_pem_bundle() as the canonical TLS PEM parser, supporting plain certs, cert+key pairs, and fullchain PEMs (key + leaf + intermediates) as emitted by many CAs. Split fullchain blobs on ingest via the new save_cert_key_from_pem() so downstream consumers never see combined PEM input — key and cert chain are always stored separately. Also: - Fix RGW legacy cert ingestion (inventory.py) to preserve intermediate certs instead of silently dropping them, and avoid logging PEM content (may contain private key material) on parse failure. - Avoid importing PEM-parsing utilities into orchestrator/module.py (would create a cephadm <-> orchestrator circular import) by having _cert_store_cert_key_set forward raw inbuf to cert_store_set_pair(), which already owns PEM parsing per-backend. - Remove now-unused parse_combined_pem_file from mgr_util.py. Fixes: https://tracker.ceph.com/issues/75710 Assisted-by: Claude <claude.ai> Assisted-by: ChatGPT <chatgpt.com> Signed-off-by: Redouane Kachach <[email protected]> (cherry picked from commit fad19f1)
Relocate parse_tls_pem_bundle() and friends from cephadm/ssl_cert_utils.py into ceph.deployment.tls_utils so they're reusable outside the cephadm module. No behavior change. cephadm/ssl_certs.py now only contains SSLCerts; cert_mgr.py, inventory.py, module.py, and cephadmservice.py are updated to import from the new location. Drops the now-duplicate parse_combined_pem_file from python-common/ceph/deployment/utils.py. Fixes: https://tracker.ceph.com/issues/75710 Signed-off-by: Redouane Kachach <[email protected]> (cherry picked from commit 4414696)
|
/audit override |
|
✅ Audit Override Applied by @rkachach. |
|
jenkins test make check |
RGWSpec.validate() attempts to migrate the legacy rgw_frontend_ssl_certificate field into ssl_cert/ssl_key by parsing it with parse_tls_pem_bundle(). If parsing failed (e.g. a cert/key format no longer accepted by the newer parser), validate() raised SpecValidationError. validate() is not only invoked on user-initiated `orch apply`, it also runs whenever existing specs are reloaded/reconciled (e.g. on mgr restart or during an upgrade). A persisted spec that was valid and running fine under the old parser could therefore start failing validation after an upgrade with no change to the actual cert/key. Since the orchestrator treats a spec that fails validation as unusable, this caused existing RGW daemons to be torn down as unmanaged/stray during upgrades. Move the migration logic into a dedicated _migrate_legacy_rgw_frontend_ssl_certificate() helper and make it best-effort: if parse_tls_pem_bundle() fails or returns an incomplete cert/key pair, log a warning and leave rgw_frontend_ssl_certificate untouched instead of raising. This keeps validate() non-destructive for legacy specs being reloaded, while still migrating the field cleanly whenever the bundle can be parsed. This does not change behavior for specs that already use ssl_cert/ ssl_key directly (no rgw_frontend_ssl_certificate set), since those never enter this code path. Fixes: https://tracker.ceph.com/issues/75710 Assisted-by: Claude <claude.ai> Assisted-by: ChatGPT <chatgpt.com> Signed-off-by: Redouane Kachach <[email protected]> (cherry picked from commit 5c8b417)
This adds automatic migration of the legacy `rgw_frontend_ssl_certificate` field on RGW specs to the newer `ssl_cert`/`ssl_key` fields. When an RGW spec has `ssl` enabled, no `ssl_cert` set, and a legacy `rgw_frontend_ssl_certificate` present, the new `_check_and_migrate_legacy_rgw_frontend_ssl_field` method parses the legacy field as a combined PEM bundle (private key + leaf certificate + optional intermediate CAs) and splits it into `ssl_cert` and `ssl_key`. On success, it sets `certificate_source` to `INLINE` and clears the legacy field. If `ssl_cert` is already set, the legacy field is left untouched since the new fields take precedence. Invalid or unparseable PEM bundles raise an `OrchestratorError` with a clear message describing the expected format, including the case where a certificate chain is provided without its private key. The migration check is called from `_apply_service_spec` right before `_check_cert_source`, so it runs ahead of spec validation. Fixes: https://tracker.ceph.com/issues/75710 Assisted-by: Claude <claude.ai> Assisted-by: ChatGPT <chatgpt.com> Signed-off-by: Redouane Kachach <[email protected]> (cherry picked from commit 87810fa)
Keep RGW's legacy `rgw_frontend_ssl_certificate` handling backward compatible when automatic migration to `ssl_cert` / `ssl_key` cannot be performed. `RGWSpec.validate()` now treats the legacy-field migration as best-effort and non-destructive. This allows stored RGW specs to keep loading during mgr restart, failover, or upgrade even if the legacy PEM bundle cannot be parsed by the newer parser. For newly applied specs, cephadm performs a stricter check in the apply path before persisting the spec. If a user submits a new RGW spec using `rgw_frontend_ssl_certificate`, the field must contain a valid combined PEM bundle with one unencrypted private key and at least one certificate. Valid input is migrated to `ssl_cert` / `ssl_key` and the legacy field is cleared. Invalid input is rejected before it reaches the spec store. Also keep the RGW daemon configuration path compatible with unmigrated legacy specs. If an existing stored spec still has `rgw_frontend_ssl_certificate` and no migrated `ssl_cert` / `ssl_key` values, cephadm continues to use the legacy PEM value when writing the RGW certificate config-key. This avoids silently switching the service to cephadm-signed certificates, or failing later during reconfig/redeploy, when migration was intentionally skipped for upgrade safety. Fixes: https://tracker.ceph.com/issues/75710 Assisted-by: Claude <claude.ai> Assisted-by: ChatGPT <chatgpt.com> Signed-off-by: Redouane Kachach <[email protected]> (cherry picked from commit 5f24bbc)
Add a contains_chain flag to certificate info returned by certmgr cert ls when the stored PEM contains more than one CERTIFICATE block. This keeps the default output focused on the leaf certificate while still making it clear when a user-provided fullchain PEM was stored. Single-certificate PEMs remain unchanged and do not include the flag. Fixes: https://tracker.ceph.com/issues/75710 Signed-off-by: Redouane Kachach <[email protected]> (cherry picked from commit 92abd49)
Add test coverage for the new TLS PEM bundle handling: * ceph.deployment.tls_utils: parse_tls_pem_bundle() happy paths (PKCS#1/PKCS#8/EC keys, multi-cert chains, cert-only input) and error paths (no cert block, duplicate keys, key/cert mismatch, encrypted/unsupported key types, empty/garbage input); is_fullchain_pem() and contains_private_key() detectors; get_certificate_info() on fullchain input. * cephadm: CertMgr.save_cert_key_from_pem(), cert_store_set_pair(), cert_store_set_cert(), and _get_certificates_from_spec() — covering fullchain splitting, chain preservation/ordering, key mismatch and encrypted-key rejection, malformed multi-block input rejection, and the conflicting-separate-key case. * RGW legacy SSL input: cover best-effort migration of rgw_frontend_ssl_certificate during spec deserialization, ensuring invalid legacy input does not make stored specs fail to load. Also cover the stricter cephadm apply path, where newly applied RGW specs using the legacy field are validated, migrated to ssl_cert/ssl_key on success, and rejected before being persisted on invalid combined PEM input. Adds cryptography to src/python-common/requirements.txt as a test dependency. Fixture data is intentionally duplicated between cephadm/tests/pem_fixtures.py and python-common/ceph/tests/test_tls_utils.py rather than shared, since cephadm's test suite should not import test modules from python-common's test tree. Fixes: https://tracker.ceph.com/issues/75710 Assisted-by: Claude <claude.ai> Assisted-by: ChatGPT <chatgpt.com> Signed-off-by: Redouane Kachach <[email protected]> (cherry picked from commit a72f97f)
Document the supported PEM input forms for certmgr and RGW HTTPS configuration. This clarifies that certificate chains are supported, that combined PEM input must include an unencrypted private key, and that reference mode requires both certificate and key entries. Fixes: https://tracker.ceph.com/issues/75710 Assisted-by: Claude <claude.ai> Assisted-by: ChatGPT <chatgpt.com> Signed-off-by: Redouane Kachach <[email protected]> (cherry picked from commit 7c6fa80)
Rename function is_fullchain_pem to contains_multiple_pem_blocks to reflect precisely what it actually does. Signed-off-by: Redouane Kachach <[email protected]> (cherry picked from commit ab3f636)
this checks seems to faild with older Python vesions, let's remove it as we already have the explict check if spec.service_type != 'rgw' Signed-off-by: Redouane Kachach <[email protected]> (cherry picked from commit b693036)
`_check_and_migrate_legacy_rgw_frontend_ssl_field()` already returns early unless the service type is `rgw`, but mypy cannot infer that a generic `ServiceSpec` is an `RGWSpec` from the `service_type` value alone. Add an explicit `typing.cast(RGWSpec, spec)` after the service-type guard so RGW-specific attributes such as `rgw_frontend_ssl_certificate` are accepted by mypy. This keeps the runtime logic unchanged and avoids reintroducing an `isinstance(spec, RGWSpec)` check, which can be problematic in cephadm/mgr subinterpreter scenarios. Signed-off-by: Redouane Kachach <[email protected]> (cherry picked from commit dce2303)
`pyOpenSSL.crypto.PKey.check()` is RSA-only and raises `TypeError` for EC private keys, even when the key is valid. This caused valid ECDSA certificate/key pairs to fail TLS validation with: `Invalid private key: Only RSA keys can currently be checked.` Fix the code to only call `PKey.check()` for RSA keys. Non-RSA keys are still parsed by OpenSSL and the certificate/private-key pair is still validated through `context.check_privatekey()`, so mismatched or invalid key pairs are still rejected. This fixes EC user-provided certificates in certmgr/cephadm paths while preserving the existing RSA consistency check. Signed-off-by: Redouane Kachach <[email protected]> (cherry picked from commit b462ee3)
|
✅ Audit Override Applied by @rkachach. |
|
/audit retest |
|
🔄 Audit Retest Triggered by @rkachach. |
There was a problem hiding this comment.
Ceph Release Engineering Audit Report
Commit Parity Visualizer
| BACKPORT PR #71513 | SOURCE PR |
SOURCE STATUS |
|---|---|---|
| 7047d57 mgr/cephadm: rename ssl_cert_utils.py to ssl_certs.py | PR #68632 | 6bb1a84 mgr/cephadm: rename ssl_cert_utils.py to ssl_certs.py |
| e0ad0bf mgr/cephadm: add fullchain PEM ingestion support to certmgr | fad19f1 mgr/cephadm: add fullchain PEM ingestion support to certmgr | |
| 02e70f2 mgr/cephadm: move TLS PEM utilities to shared python-common | 4414696 mgr/cephadm: move TLS PEM utilities to shared python-common | |
| 2242fd7 mgr/cephadm: don't fail RGWSpec validatations on ssl legacy fields | 5c8b417 mgr/cephadm: don't fail RGWSpec validatations on ssl legacy fields | |
| 546671a mgr/cephadm: migrate rgw_frontend_ssl_certificate to new cert/key | 87810fa mgr/cephadm: migrate rgw_frontend_ssl_certificate to new cert/key | |
| 6939526 mgr/cephadm: keep legacy SSL field usable after failed migration | 5f24bbc mgr/cephadm: keep legacy SSL field usable after failed migration | |
| 58352cc python-common: Add contains_chain bool to get_certificate_info | 92abd49 python-common: Add contains_chain bool to get_certificate_info | |
| 448019a cephadm/certmgr: add unit tests for fullchain PEM ingest | a72f97f cephadm/certmgr: add unit tests for fullchain PEM ingest | |
| 4bb60aa doc: document RGW and certmgr PEM input handling | 7c6fa80 doc: document RGW and certmgr PEM input handling | |
| 965e961 mgr/cephadm: rename is_fullchain_pem to contains_multiple_pem_blocks | ab3f636 mgr/cephadm: rename is_fullchain_pem to contains_multiple_pem_blocks | |
| 859cc20 mgr/cephadm: removing extra isinstance(RGWSpec) check | b693036 mgr/cephadm: removing extra isinstance(RGWSpec) check | |
| 3550b7f mgr/cephadm: cast RGW spec after service type check | dce2303 mgr/cephadm: cast RGW spec after service type check | |
| e01692c mgr/cryptotools: avoid RSA-only key check for EC private keys | b462ee3 mgr/cryptotools: avoid RSA-only key check for EC private keys | |
| 4bb82cf python-common/cryptotools: reimplement on top of cryptography | PR #69510 | d814088 python-common/cryptotools: reimplement on top of cryptography |
Automated Backport Parity Review - Cherry-Pick Conflicts / Deviations
A conflict or deviation was detected during the simulation of this backport. The code in this PR does not match a clean cherry-pick of the upstream commits.
This does not necessarily indicate an issue but a maintainer should review.
**Click to expand conflict summaries.**
Deviation in Backport 2242fd7 (cherry-pick of 5c8b417)
Affected File(s)
src/python-common/ceph/deployment/service_spec.py
Range Diff
Click to expand
--- Original (5c8b417e)
+++ Backport (2242fd78)
@@ -31,3 +31,4 @@
Assisted-by: Claude <claude.ai>
Assisted-by: ChatGPT <chatgpt.com>
Signed-off-by: Redouane Kachach <[email protected]>
+(cherry picked from commit 5c8b417e5a2654c57885f42fa33744548c4db794)
================================================================================
RANGE DIFF
================================================================================
1: 5c8b417e5a2 ! 1: 2242fd78742 mgr/cephadm: don't fail RGWSpec validatations on ssl legacy fields
@@ Commit message
Assisted-by: Claude <claude.ai>
Assisted-by: ChatGPT <chatgpt.com>
Signed-off-by: Redouane Kachach <[email protected]>
+ (cherry picked from commit 5c8b417e5a2654c57885f42fa33744548c4db794)
## src/python-common/ceph/deployment/service_spec.py ##
@@ src/python-common/ceph/deployment/service_spec.py: from ceph.deployment.hostspec import (
@@ src/python-common/ceph/deployment/service_spec.py: from ceph.deployment.hostspec
from ceph.deployment.utils import verify_positive_int, verify_non_negative_number
from ceph.deployment.utils import verify_boolean, verify_enum, verify_int, verify_non_empty_string
-from ceph.deployment.utils import parse_combined_pem_file, validate_port, validate_unique_ports
--from ceph.deployment.utils import verify_size_with_units
-+from ceph.deployment.utils import verify_size_with_units, validate_port, validate_unique_ports
++from ceph.deployment.utils import validate_port, validate_unique_ports
from ceph.cephadm.d3n_types import D3NCacheSpec, D3NCacheError
from ceph.utils import is_hex
from ceph.smb import constants as smbconstDeviation in Backport 6939526 (cherry-pick of 5f24bbc)
Affected File(s)
src/pybind/mgr/cephadm/services/cephadmservice.py
Range Diff
Click to expand
--- Original (5f24bbc0)
+++ Backport (69395266)
@@ -28,3 +28,4 @@
Assisted-by: Claude <claude.ai>
Assisted-by: ChatGPT <chatgpt.com>
Signed-off-by: Redouane Kachach <[email protected]>
+(cherry picked from commit 5f24bbc0b815e5f56b0e59c14e1b25056adad601)
================================================================================
RANGE DIFF
================================================================================
1: 5f24bbc0b81 ! 1: 69395266d57 mgr/cephadm: keep legacy SSL field usable after failed migration
@@ Commit message
Assisted-by: Claude <claude.ai>
Assisted-by: ChatGPT <chatgpt.com>
Signed-off-by: Redouane Kachach <[email protected]>
+ (cherry picked from commit 5f24bbc0b815e5f56b0e59c14e1b25056adad601)
## src/pybind/mgr/cephadm/services/cephadmservice.py ##
@@ src/pybind/mgr/cephadm/services/cephadmservice.py: class RgwService(CephService):
@@ src/pybind/mgr/cephadm/services/cephadmservice.py: class RgwService(CephService)
if spec.ssl:
- san_list = spec.zonegroup_hostnames or []
- custom_sans = san_list + [f"*.{h}" for h in san_list] if spec.wildcard_enabled else san_list
-- tls_creds = self.get_certificates(daemon_spec, custom_sans=custom_sans)
+- tls_creds = self.get_certificates(daemon_spec, custom_sans)
- pem = f'{tls_creds.key.rstrip()}\n{tls_creds.cert.lstrip()}'
-+
+ legacy_pem = spec.rgw_frontend_ssl_certificate
+ if legacy_pem and not spec.ssl_cert:
+ if isinstance(legacy_pem, list):
@@ src/pybind/mgr/cephadm/services/cephadmservice.py: class RgwService(CephService)
+ custom_sans = san_list + [f"*.{h}" for h in san_list] if spec.wildcard_enabled else san_list
+ tls_creds = self.get_certificates(daemon_spec, custom_sans=custom_sans)
+ pem = f'{tls_creds.key.rstrip()}\n{tls_creds.cert.lstrip()}'
-+
rgw_cert_name = daemon_spec.name() if spec.generate_cert else spec.service_name()
ret, out, err = self.mgr.check_mon_command({
'prefix': 'config-key set',How to proceed:
- Authors (Genuine Conflicts): If this is a genuine conflict requiring manual resolution, ensure your resolution is correct. You must explain the conflict resolution in the commit message (e.g., leave the standard Git
Conflicts:block intact) and include an explanation for changes. - Authors (Need Help?): Reach out to the Component Lead for technical guidance on complex code conflicts.
- Component Leads (Review): Please review the Range Diff(s) above to verify the author's manual conflict resolution is correct for this release branch. If the deviation is intentional, documented, and approved then the component lead or @ceph/ceph-release-manager can bypass this check by commenting
/audit override.
Be familiar with the rules and guidelines for writing backports.
🛟 Need Help?
If you need technical help resolving these issues, please consult with the Component Lead. If you need administrative overrides, please see the #ceph-upstream-releases channel on Slack and request a review from the @ceph/ceph-release-manager.
📋 Component Lead / Release Manager
To override the audit failure, apply releng-audit-override label or comment /audit override.
When you are ready for a new audit, please remove the releng-audit-fail label or comment /audit retest.
|
/audit override |
|
✅ Audit Override Applied by @rkachach. |
|
This PR has been added to wip-bharath18-testing-20260914.015853-umbrella. |
|
@rkachach does https://tracker.ceph.com/issues/80502 need an |
@batrick yes, |
|
The packages are expired, need to bundle into a new QA run. |
|
This PR has been added to umbrella integration testing by pdonnell started 2026-09-29-17:26. |
backport tracker: https://tracker.ceph.com/issues/80226
backport of #68632
backport of #69510
parent tracker: https://tracker.ceph.com/issues/75710
this backport was staged using ceph-backport.sh version 16.0.0.6848
find the latest version at https://github.com/ceph/ceph/blob/main/src/script/ceph-backport.sh