Skip to content

Add more certificates to the truststore #598

Closed

Description

@gulecroc

Is your feature request related to a problem? Please describe.
Currently only the CA certificate is added to the trustore.

I would like to add others CA certificates the trustore.

Describe the solution you'd like
Mount others certificates to one directory per certificate (so the certificate file will be updated when the secret is changed), for example /pulsar/certs/trusted/{alias}/ca.crt.

Configure trusted certificate with :

certs:
  trusted:
    - name: other-pulsar-cluster-ca
      secretName: other-pulsar-cluster-ca
      mountPath: /pulsar/certs/trusted/other-pulsar-cluster-ca

Update keytool.sh to load those external certificates to the trustore.

I don't know yet how to restart the pod when one certificate file is updated

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Activity

  1. lhotari commented on May 28, 2025

    @lhotari
    Member

    slightly related to #359 (comment) .
    I'd like to get rid of keytool.sh completely for the typical use case of a single certificate file.

    Update keytool.sh to load those external certificates to the trustore.

    I don't know yet how to restart the pod when one certificate file is updated

    For multiple certs, one option would be to have a background job poll file paths and trigger when the certificate files change to combine them into a single file. This background job could be started in the container command. To keep it lightweight, it could be a plain bash script or Python script. There isn't a need to restart the pod since Pulsar, BookKeeper and ZooKeeper support reloading the keystore and truststore files when it changes.

  2. lhotari commented on May 28, 2025

    @lhotari
    Member

    keytool.sh has been removed in #613 .

  3. lhotari commented on May 28, 2025

    @lhotari
    Member

    I don't know yet how to restart the pod when one certificate file is updated

    This could be achieved with https://docs.stakater.com/reloader/.

  4. lhotari commented on May 29, 2025

    @lhotari
    Member

    Since #613 gets rid of the use of JKS truststores and keystores, it will be possible to use a PEM bundle file as the truststore which is simply a text file with all trusted CA certificates appended.

    The main challenge to solve would be to start a background job (bash script) to watch for the individual certificate files and when any of them change, update the combined PEM bundle file (which is just simple done by concatenating all individual CA files into one file). The configuration of component's trusted certs would just point to the bundle file and the component (broker, zookeeper, bookie) would reload the changes when the file changes.

    Perhaps it should be configurable on a component basis what additional CA certs are trusted?

  5. gulecroc commented on Jun 6, 2025

    @gulecroc
    ContributorAuthor

    The main challenge to solve would be to start a background job (bash script) to watch for the individual certificate files and when any of them change, update the combined PEM bundle file (which is just simple done by concatenating all individual CA files into one file). The configuration of component's trusted certs would just point to the bundle file and the component (broker, zookeeper, bookie) would reload the changes when the file changes.

    When you say "the component could reload the changes when the file changes" : do we need to restart pod or not ?

    Maybe we could use a cronjob to update the combined PEM ? Or you prefer a sidecar with a background process ?

  6. lhotari commented on Jun 6, 2025

    @lhotari
    Member

    When you say "the component could reload the changes when the file changes" : do we need to restart pod or not ?

    There is no need to restart pods.

    Maybe we could use a cronjob to update the combined PEM ? Or you prefer a sidecar with a background process ?

    I think that the files made available by mounting secrets are read-only. A sidecar / background process would be more useful. It would simply have a loop where it checks all files for modification time and if any change, it would combine them into a single file. With PEM files, it's really simple since they are text files that can be concatenated into a single "pem bundle" file to form a "trust store".
    When this feature is enabled, the component would just be pointed to the concatenated file instead of the file provided directly by cert manager.

    I think that some thought should be put into whether additional trusted CAs would be added only to specific components such as the broker and proxy or whether it should apply to internal components such as bookkeeper and zookeeper.

    The solution for combining the files might require executing the concatenation once in an init container so that the file is available when the component starts and then having a sidecar or background job to keep the concatenated file up-to-date.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions