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

Support to test AWS KMS signing using Localstack #288

Open
semmet95 opened this issue Jun 21, 2024 · 3 comments
Open

Support to test AWS KMS signing using Localstack #288

semmet95 opened this issue Jun 21, 2024 · 3 comments

Comments

@semmet95
Copy link

I have been trying to setup acceptance tests for aws kms signing but I'm running into,

failed to verify certificate: x509: cannot validate certificate

error for the localstack endpoint. Digging a bit deeper I found that if I hardcode a.options.insecureSkipVerify to true here the signing operation works fine.
I also found this function that returns an Option which can set the insecureSkipVerify property to false. But I couldn't figure out how to use it when creating a SignerProvider or a SignerVerifier.
Can someone please help me with configuring this property 🙏
Thanks.

@ChaosInTheCRD
Copy link
Collaborator

Hi @semmet95!

Thank you for raising this issue. I think I understand the problem you are facing, as you said you're writing acceptance tests, are these with the intention of submitting as a PR to the repository? That sounds great if so!

The way the options for KMS providers are wired up is a little tricksy, apologies for this. You will however find some example logic of the KMS provider options getting initialized at https://github.com/in-toto/witness/blob/main/cmd/keyloader.go#L50.

There is a little bit of unwanted behaviour being experienced with KMS (e.g., in-toto/witness#427), so it might be worth noting that I have just submitted a PR to make some changes to how these options are passed around (see #292).

If you want any more specific help with your work, feel free to get in contact with me on the CNCF Slack (Thomas Philip Meadows

@ChaosInTheCRD
Copy link
Collaborator

It's also probably worth noting that I will test using Localstack at some point soon in the next day or two, and will report any issues found here.

@semmet95
Copy link
Author

semmet95 commented Jul 3, 2024

Hey @ChaosInTheCRD

My issue was specific to setting the insecureSkipVerify property to true and I somehow managed to find a way to do that (definitely not elegant but it seems to work 🥹).
The loadSigners link you shared helped and I figured out that I could call the option setter function for the "kms-aws" SignerProviderOption, where the configurer name is insecure-skip-verify, providing true as the value for the flag.
Here's how I did it.

for _, configurer := range witnessProvider.Options["kms-aws"].Init() {
    if(configurer.Name() == "insecure-skip-verify") {
        optT := configurer.(*registry.ConfigOption[signer.SignerProvider, bool])
        optT.Setter()(witnessProvider, true)
    }
}

As for submitting a PR to the repo, I'm all for that but I'm not sure where to add what I tested. Maybe in the docs as an example?

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

No branches or pull requests

2 participants