-
Notifications
You must be signed in to change notification settings - Fork 16
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
Add simple online signer store (wip) #427
Conversation
lukpueh
commented
Dec 4, 2023
- Can be used to load/cache/use any signer from securesystemslib Signer API, including custom signers.
- Should replace IKeyVault and related classes.
- Details in Use securesystemslib signer API as intended #419
Let's use this PR to discuss the comments I left in #419 (comment) and inline (see |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will add some questions and I will enumerate them, so you can address them:
- Can you describe why this is a better implementation of what we currently do - one child class per signer?
- The next important question is what will it take to use this new approach to add support for a new signer as in my case for AWSSigner.
What I see is that: I will need to add a section in__init__
specificy for AWSSigner where I will need to import my AWSKey, import the signer, use it and make sure it's working - How do we make sure that the private keys we have loaded through
from_priv_key_uri
can work with the public key that has been used to load that private key?
I ask as I don't see such a code in securesystemslib.
Great questions!
We currently have a redundant abstraction layer over individual signer implementations. Why implement a Moreover, the Maybe the advantage becomes more apparent below:
The work we currently do in If we'd directly configure For AWS this means:
The most reliable way to see if they belong together is to create a signature and verify it, which we'll do anyway when bootstrapping/updating metadata. Otherwise, it should be okay to just rely on the mapping by keyid. |
I understand that the significant change here is that we no longer need to create the IKeyVault Service. The background here, @MVrachev is that we started with securesystemslib (sslib) in RSTUF when it was on version 0.23.0. At this moment, sslib supported only files for signing, so the idea was to use it for the IKeyVault service The sslib has greatly improved and now supports all these signers; we can simplify it and relay it on securesystemslib. In the RSTUF, we need to keep the user experience of configuring the containers easily, implementing the environment variables ( |
Is this a response to something I said? Regardless, I have some comments... :) Re: container config UX... Agreed, this should be super easy. Asking the user to come up with config like Then the CLI could print the constructed Alternatively, and this is what tuf-on-ci does, we could just include the uri with the public key in tuf metadata. Then the user does not have to configure the key information at all, just the key itself. I think we should go for that. Re: environment variables ( Re: supporting secrets, custom configurations, etc. Currently, you can configure a private key via
I suggest to allow either path to file with key data or key data itself. |
Not clear here, but I believe you're mentioning the use case for type LocalKeyVault, which we agree shouldn't be most used in production deployments (but will have anyway).
Should we make the user obligated to use the CLI? Now, it is more of an interface and interface example for RSTUF API. Remember that the RSTUF deployment can have a different setup as it uses containers. There is a difference from tuf-on-ci here.
Here, I disagree. Secondly, it is a standard. Here are some examples:
It sounds strange, but I think we support the two common use cases for containers with the constraint that it is a volume always.
|
What problems do you mean and how are they related to my proposal?
No, and we don't need to. An organisation can very well build their own tooling to create TUF metadata, with private key uris included in public keys.
Sure, that doesn't change with my proposal. As before, the user still needs to get the private key somehow into the system. The difference is that now the user only needs to configure the key (e.g. via mounting a volume with the key file), and the information where to get the key from is included transparently via TUF metadata. Whereas previously the user had to configure both, the key and the information where to load it from.
I would argue that it is already a distributed experience, because the user will likely manage their aws key via aws tooling. It seems okay to say in user docs something like, "if you are using aws, make sure to configure these aws env vars: [link to aws env var docs]". Alternatively, you'd have to say something like, "if you are using aws make sure to configure these rstuf env vars, which correspond to these aws env vars but w/o the RSTUF_ prefix: [link to aws env var docs]". :P But yeah, I won't insist. It's okay with me to just re-export them.
Do you disagree that we currently support the 3 ways of configuring local keys above? Also, my question was, if the user really needs all that flexibility. |
👍
What I was trying to elaborate on is that when you deploy the RSTUF you don't yet have the TUF metadata (user will bootstrap it). The RSTUF-Worker will not have this information and cannot access the key. I thought it could be a problem.🤔
I'm not saying that I disagree here. If you just try to deploy your environment using, for example, Docker, the volume is not created until you deploy. Only after it starts, are you able to add a key inside the volume. Here is the trick part, to add a key, you must do it through a container that mounts this volume. |
68ae260
to
3d798f8
Compare
@kairoaraujo, @MVrachev, I updated the PR to implement what we discussed: d079add rewrites the signer store to remove any custom key config parsing and instead uses a key URI, which can be attached to the public key. This solves the problem of mapping public keys to private keys at signing time, works for any registered Signer implementation, and makes the signing code extremely simple. The other two commits (39ea16c, 68ae260) implement two custom signer loaders. One for relative path URIs, where a base path is expected as environment variable (as you requested). And one for URIs, which point to environment variable names, from which the key can be loaded. As you can see, they only need to be registered in the Signer API's dispatch table for Btw. I mostly removed the config parsing code for emphasis (to show how the code becomes even simpler). If we want to stay backwards compatible we can easily revert that and make the SignerStore use the old-style config if it exists, but expect URIs on keys otherwise. |
I like what you did here, but will feel more confident when we have the other part which is at the CLI. |
Re-implement key loading and signing parts of ceremony cli, with the following goals: - configure online signer via uri attached to public key (for repository-service-tuf/repository-service-tuf-worker#427) - use state-of-the-art securesystemslib API only - make re-usable for similar cli - simplify (e.g. avoid custom/redudant abstractions over python-tuf/securesystemslib Metadata API) Signed-off-by: Lukas Puehringer <[email protected]>
Can be used to load/cache/use any signer from securesystemslib Signer API, including custom signers. Should replace IKeyVault and related classes. Signed-off-by: Lukas Puehringer <[email protected]>
- remove all config parsing (revert this for backwards compatibility with LOCAL_KEY_VAULT config style) - use x-rstuf-online-key-uri in public key (requires adoption in CLI) Signed-off-by: Lukas Puehringer <[email protected]>
The base path is provided via envrionment variable. Signed-off-by: Lukas Puehringer <[email protected]>
Signed-off-by: Lukas Puehringer <[email protected]>
3d798f8
to
b02b4f6
Compare
implements option 2 from repository-service-tuf/repository-service-tuf#580 supersedes repository-service-tuf#427 (does not include a custom "relative file path signer", can be added in a follow-up PR) -- Change `SignerStore.get` to load non-cached signers from private key uri configured on the passed public key in a "x-rstuf-online-key-uri" field. If the public key does not include a uri, RSTUF_KEYVAULT_BACKEND is used as fallback. securesystemslib.signer.CryptoSigner is "registered" to load signers from private key files. No key specific secrets handling is added. This means the keys must be stored unencryped, preferrably using the secrets handling of the deployment platform (e.g. docker secrets). Default schemes in `securesystemslib.signer.SIGNER_FOR_URI_SCHEME` can be used but are untested. **Tests** Add test to load actual signer from private key file. Uses new unencrypted ed25519 private key copied from: secure-systems-lab/securesystemslib@7952c3f Public key stubs in other tests are updated, because signer store now reads the `unrecognized_fields` attribute, which is mandatory in Key objects. -- implements option 2 described in repository-service-tuf/repository-service-tuf#580 mostly supersedes repository-service-tuf#427 (does not include a custom "relative file path signer") Signed-off-by: Lukas Puehringer <[email protected]>
implements option 2 from repository-service-tuf/repository-service-tuf#580 supersedes #427 (does not include a custom "relative file path signer", can be added in a follow-up PR) -- Change `SignerStore.get` to load non-cached signers from private key uri configured on the passed public key in a "x-rstuf-online-key-uri" field. If the public key does not include a uri, RSTUF_KEYVAULT_BACKEND is used as fallback. securesystemslib.signer.CryptoSigner is "registered" to load signers from private key files. No key specific secrets handling is added. This means the keys must be stored unencryped, preferrably using the secrets handling of the deployment platform (e.g. docker secrets). Default schemes in `securesystemslib.signer.SIGNER_FOR_URI_SCHEME` can be used but are untested. **Tests** Add test to load actual signer from private key file. Uses new unencrypted ed25519 private key copied from: secure-systems-lab/securesystemslib@7952c3f Public key stubs in other tests are updated, because signer store now reads the `unrecognized_fields` attribute, which is mandatory in Key objects. -- implements option 2 described in repository-service-tuf/repository-service-tuf#580 mostly supersedes #427 (does not include a custom "relative file path signer") Signed-off-by: Lukas Puehringer <[email protected]>
Closing in favour of #455 |