Skip to content

Eventing TLS: support K_CA_CERTS in adapter/v2#6848

Merged
knative-prow[bot] merged 5 commits intoknative:mainfrom
pierDipi:support-k-ca-certs-in-adapter-v2
Apr 18, 2023
Merged

Eventing TLS: support K_CA_CERTS in adapter/v2#6848
knative-prow[bot] merged 5 commits intoknative:mainfrom
pierDipi:support-k-ca-certs-in-adapter-v2

Conversation

@pierDipi
Copy link
Member

@pierDipi pierDipi commented Apr 5, 2023

This patch adds support for the K_CA_CERTS environment variable for the source adapter library.

This will enable the APIServerSource data plane and other sources leveraging adapter/v2 to work with the Eventing TLS feature.

Fixes: #6847

@knative-prow knative-prow bot requested review from aliok and lionelvillard April 5, 2023 16:31
@knative-prow knative-prow bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Apr 5, 2023
@pierDipi pierDipi changed the title Eventing TLS: support K_CA_CERTS in adapter/v2 [WIP] Eventing TLS: support K_CA_CERTS in adapter/v2 Apr 5, 2023
@knative-prow knative-prow bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 5, 2023
@codecov
Copy link

codecov bot commented Apr 5, 2023

Codecov Report

Patch coverage: 30.70% and project coverage change: -0.44 ⚠️

Comparison is base (d991040) 80.40% compared to head (be128a8) 79.96%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6848      +/-   ##
==========================================
- Coverage   80.40%   79.96%   -0.44%     
==========================================
  Files         236      237       +1     
  Lines       12243    12354     +111     
==========================================
+ Hits         9844     9879      +35     
- Misses       1907     1981      +74     
- Partials      492      494       +2     
Impacted Files Coverage Δ
pkg/kncloudevents/message_receiver.go 84.44% <18.18%> (-9.39%) ⬇️
pkg/eventingtls/eventingtls.go 21.17% <21.17%> (ø)
pkg/adapter/v2/cloudevents.go 80.89% <81.25%> (+2.01%) ⬆️
pkg/adapter/v2/config.go 82.14% <100.00%> (+0.43%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@pierDipi pierDipi force-pushed the support-k-ca-certs-in-adapter-v2 branch 2 times, most recently from 81d5079 to e85b76a Compare April 5, 2023 17:45
@github-advanced-security
Copy link

You have successfully added a new CodeQL configuration .github/workflows/knative-security.yaml:analyze-codeql. As part of the setup process, we have scanned this repository and found no existing alerts. In the future, you will see all code scanning alerts on the repository Security tab.

@pierDipi pierDipi force-pushed the support-k-ca-certs-in-adapter-v2 branch from e85b76a to d4871fe Compare April 5, 2023 18:59
module knative.dev/eventing

go 1.18
go 1.19
Copy link
Member Author

Choose a reason for hiding this comment

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

This is needed to be able to use x509.CertPool.Clone()

@pierDipi pierDipi force-pushed the support-k-ca-certs-in-adapter-v2 branch from d4871fe to 284cf32 Compare April 5, 2023 22:22
This patch adds support for the `K_CA_CERTS` environment variable
for the source adapter library.

This will enable the APIServerSource data plane to work with the
Eventing TLS feature.

Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
@pierDipi pierDipi force-pushed the support-k-ca-certs-in-adapter-v2 branch from 284cf32 to b592562 Compare April 5, 2023 22:25
Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
@pierDipi pierDipi changed the title [WIP] Eventing TLS: support K_CA_CERTS in adapter/v2 Eventing TLS: support K_CA_CERTS in adapter/v2 Apr 11, 2023
@knative-prow knative-prow bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 11, 2023
Comment on lines +44 to +45
// DefaultMinTLSVersion is the default minimum TLS version for servers and clients.
DefaultMinTLSVersion = tls.VersionTLS12
Copy link
Member Author

Choose a reason for hiding this comment

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

I was wondering if we should go with 1.3?

@pierDipi
Copy link
Member Author

/cc @matzew @creydr @aliok @evankanderson

Comment on lines +101 to +103
if err != nil {
return
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Log error

"github.com/cloudevents/sdk-go/v2/event"
"github.com/cloudevents/sdk-go/v2/protocol"
"github.com/cloudevents/sdk-go/v2/protocol/http"
cehttp "github.com/cloudevents/sdk-go/v2/protocol/http"
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Is this a duplicate import? Can just use the import above

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

UpdateFunc: func(_, newObj interface{}) {
store(newObj)
},
DeleteFunc: nil,
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we clear the store on a delete? I can't think of a valid reason for a user to delete the Secret but the intent is likely to stop the usage of the cert when that happens.

Copy link
Member Author

Choose a reason for hiding this comment

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

I was thinking about that, however, if the secret is deleted by mistake that would cause an outage or maybe the cert management is migrated to a different tool (like Cert-Manager first and Vault after), there might be a need to delete and recreate the secret without downtime and that is hard if we stop serving the certs.

Copy link
Contributor

Choose a reason for hiding this comment

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

That makes sense to me


// Clone the pool before appending other certs or returning since we don't want to add user
// provided CA certs for different resources to the system pool or to any other "global" pool.
p = p.Clone()
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's safe to assume it'll already be a copy. From SystemCertPool :

// SystemCertPool returns a copy of the system cert pool.
// Any mutations to the returned pool are not written to disk and do not affect
// any other pool returned by SystemCertPool.

Copy link
Member Author

Choose a reason for hiding this comment

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

Removed

Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
@pierDipi
Copy link
Member Author

/test upgrade-tests

@pierDipi pierDipi requested a review from gab-satchi April 18, 2023 14:43
@knative-prow knative-prow bot added the lgtm Indicates that a PR is ready to be merged. label Apr 18, 2023
@knative-prow
Copy link

knative-prow bot commented Apr 18, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: gab-satchi, pierDipi

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow knative-prow bot merged commit 193f2df into knative:main Apr 18, 2023
@pierDipi pierDipi deleted the support-k-ca-certs-in-adapter-v2 branch April 18, 2023 18:26
vishal-chdhry pushed a commit to vishal-chdhry/eventing that referenced this pull request Apr 25, 2023
This patch adds support for the `K_CA_CERTS` environment variable for
the source adapter library.

This will enable the APIServerSource data plane and other sources
leveraging adapter/v2 to work with the Eventing TLS feature.

Fixes: knative#6847

---------

Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Eventing TLS: Support K_CA_CERTS in source adapter

2 participants