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 Custom CA for certificate issuing #438

Merged
merged 38 commits into from
Oct 16, 2024
Merged

Support Custom CA for certificate issuing #438

merged 38 commits into from
Oct 16, 2024

Conversation

meng-han
Copy link
Contributor

@meng-han meng-han commented Oct 14, 2024

previously we have one giant class certificatemanager which has a certificatauthority class which is basically ACM PCA.

Now we want to add support for custom ca, without impacting existing contracts/apis on /v1/certificates prefix. So a new base class is created so that both acm pca and custom ca can inherit from.

other changes are mostly tests and settings along side this.

@meng-han meng-han changed the title Cca1 Support Custom CA for certificate issuing Oct 14, 2024
skiptomyliu
skiptomyliu previously approved these changes Oct 15, 2024

def _load_rootca_certificate(self, ca_json):
if "rootcrt" not in ca_json or not ca_json["rootcrt"]:
logger.warning("Custom CA has no root CA certificate provided")

Choose a reason for hiding this comment

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

maybe adding ca id to enrich the log for debugging purpose?
logger.warning("Custom CA %s has no root CA certificate provided", ca_env)


acceptable_validity = min(validity, self.settings["max_validity_days"])
builder = builder.not_valid_after(
datetime.now(timezone.utc) + timedelta(days=acceptable_validity)

Choose a reason for hiding this comment

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

call datetime.now twice at 129 and 133. considering consolidate them into 1?

active_ca = [
ca
for ca in CUSTOM_CERTIFICATE_AUTHORITIES[ca_env]
if validator.validate(ca) and ca["kid"] == active_ca_id

Choose a reason for hiding this comment

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

if validator.validate(ca) return False, will we still log Custom CA %s has no active keys?

# Get the certificate in PEM format
intermediate_ca_pem = self.encode_certificate(self.ca_certificate)
root_ca_pem = self.encode_certificate(self.root_ca_certificate)
return intermediate_ca_pem + root_ca_pem

Choose a reason for hiding this comment

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

self.root_ca_certificate can be None? if so intermediate_ca_pem + root_ca_pem will throw TypeError

Yueren-Wang
Yueren-Wang previously approved these changes Oct 15, 2024
@meng-han meng-han dismissed stale reviews from Yueren-Wang and skiptomyliu via 1958e28 October 16, 2024 15:49
@meng-han
Copy link
Contributor Author

/offload

@meng-han meng-han merged commit 78f7057 into master Oct 16, 2024
6 checks passed
@meng-han meng-han deleted the cca1 branch October 16, 2024 22:16
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.

3 participants