Skip to content

Conversation

@ramondeklein
Copy link
Contributor

@ramondeklein ramondeklein commented Nov 5, 2025

Why a new certificate manager?

The existing certificate manager doesn't know how to rescan the manager to load all new and discard removed certificates. Since the old certificate manager doesn't know how to scan, this can't be done from the manager itself. This requires code -outside the manager- to listen to SIGHUP and to update the certificates in the manager.

There is a problem with the current manager, because it doesn't allow certificates to be removed. Also the underlying certificate code doesn't handle "unloading" them well. It leaks Go routines (in case the certificate is loaded via a symbolic link).

The new certificate manager implements the same functions, but during creation it is initialized using a "scanning" function that loads all the certificates. When SIGHUP is received, then the same scanning function is invoked again to perform a full rescan.

Global certificates

The EOS code uses HTTP clients that uses GetCertificate or GetClientCertificate. This should ensure that the transport layer always uses the current certificate. Although this works, it creates a new certificate manager during the process and this will leak Go routines and file-system notification events.

That's why new_global_certs.go is introduced. It will use a certificate cache and will only load a certificate once (even if it's requested more often). This avoid leakage of Go routines and file-system notification events. It also simplifies the code...

@ramondeklein ramondeklein self-assigned this Nov 5, 2025
@ramondeklein ramondeklein requested a review from Copilot November 5, 2025 16:35
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements an improved certificate manager (Manager2) that addresses limitations in the existing certificate manager by adding support for directory scanning, certificate removal, proper resource cleanup, and SIGHUP signal handling for certificate rescanning.

Key changes:

  • Introduced Certificate2 that automatically reloads certificates when underlying files change, with support for both regular files and symlinks
  • Implemented Manager2 that manages multiple certificates and reloads all certificates on SIGHUP signal
  • Added comprehensive test coverage for certificate auto-reloading, SIGHUP handling, and edge cases

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
certs/new_certificate.go Implements Certificate2 with automatic file-watching and reloading capabilities
certs/new_certificate_test.go Comprehensive tests for Certificate2 including auto-reload scenarios and error cases
certs/new_manager.go Implements Manager2 with SIGHUP signal handling and certificate lifecycle management
certs/new_manager_test.go Tests for Manager2 including Close, SIGHUP signal handling, and reload functionality
Comments suppressed due to low confidence (1)

certs/new_manager.go:1

  • Corrected grammar: 'Make sure the call Close' should be 'Make sure to call Close'.
// Copyright (c) 2015-2022 MinIO, Inc.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ramondeklein ramondeklein force-pushed the new-certs-manager branch 2 times, most recently from cd692c3 to 90c4ceb Compare November 5, 2025 16:39
@ramondeklein ramondeklein requested a review from Copilot November 5, 2025 16:39
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ramondeklein ramondeklein force-pushed the new-certs-manager branch 2 times, most recently from 0d812a1 to 200c6d7 Compare November 5, 2025 18:50
@ramondeklein ramondeklein requested a review from Copilot November 5, 2025 19:01
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ramondeklein ramondeklein requested a review from Copilot November 5, 2025 19:22
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ramondeklein ramondeklein requested review from aead and Copilot November 6, 2025 10:35
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ramondeklein ramondeklein added the enhancement New feature or request label Nov 6, 2025
Copy link
Member

@harshavardhana harshavardhana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's with the naming of files as new_ ?

@ramondeklein
Copy link
Contributor Author

I named them NewCertificate and NewManager at first. Let me change that.

Copy link
Member

@harshavardhana harshavardhana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall approach looks good, will wait for @aead since he may better opinions

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 9 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ramondeklein ramondeklein force-pushed the new-certs-manager branch 2 times, most recently from cf67740 to 0c828a0 Compare November 13, 2025 18:59
@ramondeklein ramondeklein requested a review from Copilot November 13, 2025 19:00
Copilot finished reviewing on behalf of ramondeklein November 13, 2025 19:05
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 10 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ramondeklein ramondeklein marked this pull request as ready for review November 20, 2025 08:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants