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

fix: Updating akv cert provider to use getSecret #957

Merged
merged 36 commits into from
Aug 15, 2023

Conversation

susanshi
Copy link
Collaborator

@susanshi susanshi commented Jul 31, 2023

Description

  • This PR includes:
  1. Updating akv cert provider to use getSecret to fetch certificates for the entire chain
  2. adding clean up step for dangling aks resources
  3. Updated documentation to configure certificate policy on cert import
  4. Uploaded existing test cert chain in e2e integration, inline root cert is no longer needed.

What this PR does / why we need it:

Fixes #695

Which issue(s) this PR fixes (optional, using fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when the PR gets merged):

Fixes #695

Type of change

Please delete options that are not relevant.

  • [ X] Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Helm Chart Change (any edit/addition/update that is necessary for changes merged to the main branch)
  • [X ] This change requires a documentation update

How Has This Been Tested?

-Uploaded existing test cert chain in e2e integration, inline root cert is no longer needed
Manual validation includes:

  • Secret with non content type
  • Secret disabled
  • Secret that is not a a cert
  • Not enough permissions for identity
  • PEM and PCKS12 formats

Checklist:

  • Does the affected code have corresponding tests?
  • Are the changes documented, not just with inline documentation, but also with conceptual documentation such as an overview of a new feature, or task-based documentation like a tutorial? Consider if this change should be announced on your project blog.
  • Does this introduce breaking changes that would require an announcement or bumping the major version?
  • Do all new files have appropriate license header?

Post Merge Requirements

  • MAINTAINERS: manually trigger the "Publish Package" workflow after merging any PR that indicates Helm Chart Change

@codecov
Copy link

codecov bot commented Aug 1, 2023

Codecov Report

Patch coverage: 64.17% and project coverage change: +0.46% 🎉

Comparison is base (1051142) 56.99% compared to head (3d693c6) 57.45%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #957      +/-   ##
==========================================
+ Coverage   56.99%   57.45%   +0.46%     
==========================================
  Files          90       90              
  Lines        5292     5326      +34     
==========================================
+ Hits         3016     3060      +44     
+ Misses       1970     1956      -14     
- Partials      306      310       +4     
Files Changed Coverage Δ
pkg/certificateprovider/azurekeyvault/provider.go 58.11% <64.17%> (+15.44%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

```bash
az keyvault certificate import \
--vault-name ${AKV_NAME} \
-n ${KEY_NAME} \
-f ${CERT_PATH}
Copy link
Contributor

Choose a reason for hiding this comment

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

Are there any steps that walk the reader through creating a certificate? Or is that assumed knowledge or a prerequisite?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I ve actually deleted the entire kv import step, customer should follow https://learn.microsoft.com/en-us/azure/container-registry/container-registry-tutorial-sign-build-push#build-and-sign-a-container-image from the prereq section of this quick start.

.github/workflows/build-pr.yml Outdated Show resolved Hide resolved
.github/workflows/build-pr.yml Outdated Show resolved Hide resolved
scripts/azure-ci-test-cleanup.sh Show resolved Hide resolved
pkg/certificateprovider/azurekeyvault/provider.go Outdated Show resolved Hide resolved

data := []byte(*secretBundle.Value)

if *secretBundle.ContentType == PKCS12ContentType {
Copy link
Collaborator

Choose a reason for hiding this comment

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

as mentioned in: #695 (comment), does pkcs12 works now in Golang?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Discussed offline, we will keep the current implementation but provided more guidance in documentation.

pkg/certificateprovider/azurekeyvault/provider.go Outdated Show resolved Hide resolved

```bash
az keyvault set-policy --name ${AKV_NAME} \
--certificate-permissions get \
--secret-permissions get \
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

log an issue to update the ratify terraform resource

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Issue logged at #973

@susanshi
Copy link
Collaborator Author

susanshi commented Aug 8, 2023

Hi @akashsinghal and @binbin-li , i ve addressed the feedback and merged with latest main. Please give another round of review, please review aks rest result and clean up log at https://github.com/susanshi/ratify/actions/runs/5793405981/job/15701535090, and

binbin-li
binbin-li previously approved these changes Aug 10, 2023
Copy link
Collaborator

@binbin-li binbin-li left a comment

Choose a reason for hiding this comment

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

lgtm

certsStatus = append(certsStatus, certProperty)
}
default:
logrus.Warnf("certificate '%s', version '%s': azure keyvualt certificate provider detected unknown block type %s", certName, version, block.Type)
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: "keyvault" is mispelled in multiple places keyvualt --> keyvault

akashsinghal
akashsinghal previously approved these changes Aug 10, 2023
Copy link
Collaborator

@akashsinghal akashsinghal left a comment

Choose a reason for hiding this comment

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

LGTM

@susanshi susanshi dismissed stale reviews from akashsinghal and binbin-li via 7aed3bf August 15, 2023 01:26
@susanshi susanshi merged commit dcfa9b5 into ratify-project:main Aug 15, 2023
15 checks passed
junczhu pushed a commit to ZAFT-Armored-Keeper-of-Unity/ratify that referenced this pull request Aug 23, 2023
Signed-off-by: Susan Shi <huish@microsoft.com>
junczhu added a commit to ZAFT-Armored-Keeper-of-Unity/ratify that referenced this pull request Aug 23, 2023
fix: fix cert-rotator test (ratify-project#992)

chore: bump github.com/aws/aws-sdk-go-v2/config from 1.18.32 to 1.18.33 (ratify-project#988)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Akash Singhal <akashsinghal@microsoft.com>

feat: add graceful shutdown for http server (ratify-project#949)

fix: Updating akv cert provider to use getSecret (ratify-project#957)

Signed-off-by: Susan Shi <huish@microsoft.com>

chore: bump golangci/golangci-lint-action from 3.6.0 to 3.7.0 (ratify-project#997)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

chore: bump actions/setup-go from 4.0.1 to 4.1.0 (ratify-project#996)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

fix: adding experimental to dynamic plugin flag (ratify-project#980)

refactor: refactor error handling (ratify-project#956)

docs: add notaryv2 upgrade doc (ratify-project#999)

chore: update assign.yaml template

chore: update library templates

chore: update library templates2

chore: update library templates fix typo

chore: update library templates array
bspaans pushed a commit to bspaans/ratify that referenced this pull request Oct 17, 2023
Signed-off-by: Susan Shi <huish@microsoft.com>
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.

Ratify should retrieve the entire cert chain from AKV
4 participants