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

Implement certificate rotation with internal and external CA #86

Merged
merged 5 commits into from
Nov 23, 2023

Conversation

dimitarproynov
Copy link
Contributor

@dimitarproynov dimitarproynov commented Nov 16, 2023

Introduced two new resources: "vcf_certificate" and "vcf_external_certificate" that facilitate the rotation of SDDC Resource certificates via internal and external CA.

Common operations have been extracted into the certificate_operations.go file and the schema for the certificate details has been extracted into certificate_subresource.go.

Since the creation of CSR, rotation of certificate are a one-off operations I've decided to form their id with the following formula: :<domain_id>:<resource_type>:<task_id> to uniquely identify the operation instance.

Summary of Pull Request

Type of Pull Request

  • This is a bug fix.
  • This is an enhancement or feature.
  • This is a code style/formatting update.
  • This is a documentation update.
  • This is a refactoring update.
  • This is a chore update
  • This is something else.
    Please describe:

Related to Existing Issues

Issue Number: N/A

Test and Documentation Coverage

For bug fixes or features:

  • Tests have been completed.
  • Documentation has been added/updated.

Testing done:
make build
make lint
make test

=== RUN TestAccResourceVcfResourceExternalCertificate
=== PAUSE TestAccResourceVcfResourceExternalCertificate
=== CONT TestAccResourceVcfResourceExternalCertificate
--- PASS: TestAccResourceVcfResourceExternalCertificate (1596.07s)
PASS

=== RUN TestAccResourceVcfResourceCertificate
=== PAUSE TestAccResourceVcfResourceCertificate
=== CONT TestAccResourceVcfResourceCertificate
--- PASS: TestAccResourceVcfResourceCertificate (1260.32s)
PASS

Breaking Changes?

  • Yes, there are breaking changes.
  • No, there are no breaking changes.

Introduced two new resources: "vcf_certificate" and "vcf_external_certificate" that facilitate the rotation of SDDC Resource certificates via internal and external CA.

Common operations have been extracted into the certificate_operations.go file and the schema for the certificate details has been extracted into certificate_subresource.go.

Since the creation of CSR, rotation of certificate are a one-off operations I've decided to form their id with the following formula: <operation>:<domain_id>:<resource_type>:<task_id> to uniquely identify the operation instance.

Testing done:
make build
make lint
make test

Signed-off-by: Dimitar Proynov <[email protected]>
raj-chelur
raj-chelur previously approved these changes Nov 16, 2023
@tenthirtyam tenthirtyam removed the needs-review Needs Review label Nov 17, 2023
tenthirtyam
tenthirtyam previously approved these changes Nov 17, 2023
Validation did not take into account that the last octet can be something different from 0.

Testing done:
make build
make lint
make test

Signed-off-by: Dimitar Proynov <[email protected]>
Dimitar Proynov added 2 commits November 21, 2023 11:13
The GET method on a CSR returns 400 if the CSR has been used to replace a certificate, failing the post-creation refresh of the E2E tests. Thus, I've moved all the code from "read" to create, which does have UX implications, but at least will not crash Terraform.

With a subsequent introduction of the "lifecycle" subresource the UX issue will be solved.

Added nil pointer dereference guards in the certificate_subresource.go and removed some always nil properties from the schema.

Increased timeout for certificate replacement as it is a slow operation.

Testing done:
make build
make lint
make test

=== RUN   TestAccResourceVcfResourceCertificate
=== PAUSE TestAccResourceVcfResourceCertificate
=== CONT  TestAccResourceVcfResourceCertificate
--- PASS: TestAccResourceVcfResourceCertificate (1260.32s)
PASS

Signed-off-by: Dimitar Proynov <[email protected]>
API allows only cert chain or cert + CA cert combination.

Testing done:
make build
make lint
make test

=== RUN   TestAccResourceVcfResourceExternalCertificate
=== PAUSE TestAccResourceVcfResourceExternalCertificate
=== CONT  TestAccResourceVcfResourceExternalCertificate
--- PASS: TestAccResourceVcfResourceExternalCertificate (1596.07s)
PASS

Signed-off-by: Dimitar Proynov <[email protected]>
Also rename "vcf_resource_csr" to "vcf_csr"

Testing done:
make build
make lint
make test

Signed-off-by: Dimitar Proynov <[email protected]>
Copy link
Contributor

@vasilsatanasov vasilsatanasov left a comment

Choose a reason for hiding this comment

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

LGTM!

@dimitarproynov dimitarproynov added the feature Feature label Nov 23, 2023
Copy link

@pandeyhere pandeyhere left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@dimitarproynov dimitarproynov merged commit 0559792 into main Nov 23, 2023
8 checks passed
Copy link

I'm going to lock this pull request because it has been closed for 30 days. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 24, 2023
@dimitarproynov dimitarproynov deleted the feature/implement_external_cert_rotation branch May 16, 2024 09:46
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Enhancement feature Feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants