Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support certificates rotation #99

Closed

Conversation

ihab-soliman-form3
Copy link

@ihab-soliman-form3 ihab-soliman-form3 commented Apr 18, 2024

Cockroachdb supports certificate rotation using sighup, visus does support sighup but it doesn't update the certificates used, the goal of this PR is to handle certificate rotation to be able to run visus as a sidecar with cockroachdb and both having the same process for certificate rotation.

Changes:

  • Added a new switch flag when starting the server to enable reloading
    certificates, and defaulted to false for backward compatibility.

  • Introduced two new exposed functions to the database factory instead of
    changing the original functions signature for both ease of use and not
    breaking a lot of places in the codebase.
    The reload function will be triggered (if enabled) on every new connection;

    Depending on the lifetime of the connection, when it ends, creating a
    new connection will always reload the certificates from the path.

    The Reset function on sighup will close all the connections but not
    close the pool, allowing new connections to be established.

Closes #94


This change is Reviewable

Upgrading pgx to v5 will allow to use the reset function, which would 
close all the connections but without closing the pool.


Signed-off-by: Ihab Soliman <[email protected]>
Added a new switch flag when starting the server to enable reloading
certificates, and defaulted to `false` for backward compatibility.

Introduced two new exposed functions to the database factory instead of
changing the original functions signature for both ease of use and not
breaking a lot of places in the codebase.

The reload function will be triggered (if enabled) on every new connection;

Depending on the lifetime of the connection, when it ends, creating a
new connection will always reload the certificates from the path.

The `Reset` function on `sighup` will close all the connections but not
close the pool, allowing new connections to be established.

Signed-off-by: Ihab Soliman <[email protected]>
Signed-off-by: Ihab Soliman <[email protected]>
@sravotto
Copy link
Collaborator

sravotto commented Apr 19, 2024

Hi @ihab-soliman-form3, could you review and sign the Contributor License Agreement at https://cla.crdb.dev/cockroachlabs/visus ?

Thank you!

@sravotto
Copy link
Collaborator

sravotto commented May 7, 2024

@ihab-soliman-form3 thanks for the submission.
However, in absence of a CLA we will be using #107 to implement the change requested.

Closing in favor of #107.

@sravotto sravotto closed this May 7, 2024
@ihab-soliman-form3 ihab-soliman-form3 deleted the handle-tls-reload branch May 8, 2024 13:42
@ihab-soliman-form3
Copy link
Author

@sravotto thank you

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.

Support certificates rotation
2 participants