Closed noelbundick-msft closed 1 year ago
thanks you so much for writing this up , we really appreciate this all the context and thought here @noelbundick-msft! @toddysm , do you have additional insights to customer workflow , or any other possible workaround?
@susanshi Looking at the CertificateStore
CRD, it seems like a good option in the future might be to implement a new spec.provider
option named "inline" or similar, and enable me to do something like:
apiVersion: config.ratify.deislabs.io/v1alpha1
kind: CertificateStore
metadata:
name: my-ca-root
spec:
# this would tell Ratify to load directly from inline values rather than calling out to an external key store
provider: inline
parameters:
# this would be only the public cert (chain) in PEM format
certificate: |
-----BEGIN CERTIFICATE-----
MIIFxzCCA6+gAwIBAgIUBU8GfzuQwEbUNllUTvApn20BC2swDQYJKoZIhvcNAQEL
BQAwazELMAkGA1UEBhMCVVMxCzAJBgNVBAgMAldBMRAwDgYDVQQHDAdSZWRtb25k
MRMwEQYDVQQKDApNeSBDb21wYW55MQ8wDQYDVQQLDAZNeSBPcmcxFzAVBgNVBAMM
DmNhLmV4YW1wbGUuY29tMB4XDTIzMDEyNzE5MTIzM1oXDTMzMDEyNDE5MTIzM1ow
azELMAkGA1UEBhMCVVMxCzAJBgNVBAgMAldBMRAwDgYDVQQHDAdSZWRtb25kMRMw
EQYDVQQKDApNeSBDb21wYW55MQ8wDQYDVQQLDAZNeSBPcmcxFzAVBgNVBAMMDmNh
LmV4YW1wbGUuY29tMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAuHbv
6GuyvA8Cza0wXJQfzYo90uh1rTRuSrBL6cGdvFMdZgy2UyxL8vmQs7qHHIJupbKw
EjURPn0rmPrIHFBmmyK7kjojOQma+AjOHJowcXZy619Qar2wTkopk6+ubtwjx8PZ
t0LdHSRK0dUrcZDINqrjWBv8KknsgVkyP9PdNsnHH58hu8Po2kZEp+V6Yj+hWJ00
GgKdPgrE1LVReA6fzFR/RvS8XuAeWiP06EkuyLCeq9qCmo7Idm2pNRJ10B/Nbmb1
3O9wC90ESw0CT8cBjFYt2PogjWDWJgj15BA0xDpYA7RVrZRkFQQb2JZAD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ck0J1A6tPmgpDkd/G17nbNLKmA5CYy0E6ZqTHl1p/r
027OjBAHnQMcP9Zr2cv4vC8EWOjmtDGSIJi2WYhRaIqCI5MDahGYS+aLrfXPaHCu
0IMA3zXuwyaStKnYUxRomApvhjcWvrpAD1f/QxvkixYk4to7p6USOACkKQ==
-----END CERTIFICATE-----
And then have the CertificateStoreReconciler
add/remove that from the in-memory map like it does with the "azurekeyvault" provider.
I think we'll encounter more of these cases. Ex: I anticipate wanting to verify that I'm running properly signed images from mcr.microsoft.com
, but I certainly won't have access to the private keys. This would give me a consistent way to specify my public certs without having to resort to Helm postrender ConfigMap/Secret volume mount hacks
I want to enable the following scenario:
Below is a walkthrough that shows what works + what doesn't as of today
Infra team: Create a Certificate Authority
To demonstrate the issue, we'll put on our Infra Team hat and stand up a simple local CA. Companies do this in a myriad of different ways, so we'll keep it straightforward for this demo
Create a pipeline cert signing request
I interact with the infra team (web portal, service ticket, etc) to get a cert. Let's say in this case, I create a certificate signing request from Key Vault where the private key will stay and never be exported.
Infra Team: Complete the CSR
The infra team approves, and I get back a cert that's a child of my company CA root
Upload the cert to Key Vault
I merge that cert into Key Vault, and now I can use it
Sign an image using the leaf cert
I use it with notation to sign an image
Verify the signature via notation
I validate the signature. Note that I'm using the CA root cert public key here (which I have access to), and not the leaf pipeline cert that directly created the signature.
Verify the signature via Ratify
Now, do the same thing with Ratify. I create a Ratify config with a simple trust policy that uses notation's trust store path (just saves me copying some files around)
Verify the image
So far, so good!
At this point, we've seen that
Azure Key Vault behavior
Azure Key Vault certificates must include the private key. Here are some commands that will fail:
So I can refer to a CA file, but can't refer to a CA cert in Key Vault (unless I have & am willing to upload its private key)
What's next?
So in this scenario, I can't store this CA cert in Key Vault. And in the above, we've shown that I don't actually need it. What I really need is to get the public key into my trust store. But that flow doesn't play nicely with Ratify + k8s as of today.
Q: Do we expect companies/users to be using cert chains in their software supply chain security?
I don't have a specific customer in mind right away, but I would assume the answer is "yes"?
Q: What's the "happy path" for pointing to a public key?
I can modify the Helm chart and pass in the root CA cert as a ConfigMap/Secrets, and then volume mount those files on disk. I fully expect folks on Azure to ask "Why can't I use the Key Vault feature?", and walk them through this journey as well.
Other thoughts
Doing something like expanding
ratifyTestCert
in Helm values into an array with one entry per public key, and then wiring everything up in the chart, would give this category of users a "better" experience. This would effectively mean that customers that have well-governed CA's (note: I personally think this pattern is reasonable and common) wouldn't use the Key Vault feature at allWe could say: don't tell Ratify to trust the root CA, but instead an intermediate CA. We do put that private key in Key Vault. This would work at a technical level (important note: even though it's not needed by notation), but asking someone to maintain a complicated CA chain just to use Ratify + Key Vault is, for me personally, unreasonable to ask someone to do.