Skip to content

fix(k8s): normalize certificate identities on create like on update - #4350

Closed
89799969 wants to merge 1 commit into
apache:rocketmq-studiofrom
89799969:fix/k8s-cert-create-normalize-identities
Closed

89799969 wants to merge 1 commit into
apache:rocketmq-studiofrom
89799969:fix/k8s-cert-create-normalize-identities

Conversation

@89799969

Copy link
Copy Markdown
Contributor

What

Make POST /api/k8s-certs/create normalize k8sId, cluster, and issuer the same way update already does.

Why

createCert stored submitted identities verbatim while updateCert trims and rejects blank values. Consequences:

  • padded identities (" new-tls-cert ") are persisted and break exact-match lookups;
  • whitespace-only issuer is accepted on create but rejected on update;
  • a certificate row can exist in a state the update API cannot produce.

CreateCertDTO @NotBlank does not close the gap because it allows surrounding whitespace, and issuer is unconstrained.

How

  • Trim/reject blank k8sId and cluster via normalizeOptionalIdentity.
  • Normalize submitted issuer when no PEM overrides it.
  • PEM-parsed issuer/SAN still win when certPem is present.

Tests

K8sCertServiceTest:

  • createCertShouldTrimIdentityFields
  • createCertShouldRejectBlankIssuerWithoutPem

Focused run: mvn -Dtest=K8sCertServiceTest test (JDK 21) — passed.

Fixes #4299

createCert stored k8sId, cluster, and issuer verbatim while updateCert
trimmed them and rejected blank values. Clients that skip the web
dialog could persist padded identities the update API cannot produce,
and whitespace-only issuer values were accepted.

Route create through the same normalizeOptionalIdentity helper used by
update, and keep PEM-parsed issuer/SAN overrides intact.

Fixes apache#4299
@89799969

Copy link
Copy Markdown
Contributor Author

Closing: this change is already covered by merged #4300 (normalize certificate identities on create like on update, Fixes #4299). Thanks for the review window — no second patch needed.

@89799969 89799969 closed this Sep 15, 2026
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.

1 participant