-
Notifications
You must be signed in to change notification settings - Fork 547
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
Importing RSA and EC keypairs #1050
Conversation
Looks like DCO is missing! You'll need to use the |
Signed-off-by: Ivan Wallis <[email protected]>
Signed-off-by: Ivan Wallis <[email protected]>
Signed-off-by: Ivan Wallis <[email protected]>
8db9819
to
c55d69e
Compare
Signed-off-by: Ivan Wallis <[email protected]>
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.
Overall, it looks in a good direction, but I wonder how this fits the broader codebase (I think there's a lot of possibly repeated code).
I also feel there are a couple of minor fix/tweaks that may be making the code slightly harder to review. I wonder if we could split those into a smaller PR...
} | ||
fmt.Fprintln(os.Stderr) | ||
fmt.Fprint(os.Stderr, "Enter password for private key again: ") | ||
pw2, err := term.ReadPassword(0) |
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'm not entirely fond of pw2 when this should be a confirmation. I'm not sure what the golang guidelines are for variable naming, but maybe something more explicit would make the code more readable.
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.
Ok, I can update the variable to something more explcit such as confirmpw
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.
small ping on this comment
Signed-off-by: Ivan Wallis <[email protected]>
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.
Thanks! looking really good so far :D appreciate all the changes
pkg/cosign/keys.go
Outdated
|
||
} | ||
|
||
func MarshallKeyPair(keypair Key, pf PassFunc) (*Keys, error) { |
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.
nit: spelling MarshalKeyPair
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.
could you share this code with GenerateKeyPair
? and given that it's only called within this function, maybe it should be made private.
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.
made changes.
Signed-off-by: Ivan Wallis <[email protected]>
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.
Sorry for the delay, taking a review! Could you check on the test failures as well?
? github.com/sigstore/cosign/pkg/blob [no test files]
--- FAIL: TestImportPrivateKey (0.12s)
keys_test.go:158: unexpected error importing key: parsing error
FAIL
Also, running and committing the change from go run -tags pivkey,pkcs11key,cgo ./cmd/help/
will fix the doc gen CI check
Signed-off-by: Ivan Wallis <[email protected]>
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.
Thanks! Could you just please address the lint comments and update the branch and this would LGTM!
Your code suggestion doesn't compile. |
Signed-off-by: Ivan Wallis <[email protected]>
Was hoping you would take away the gist of what I was saying. I pulled your branch and completed it for you:
|
Signed-off-by: Ivan Wallis <[email protected]>
ImportKeyPair function updated. |
Signed-off-by: Ivan Wallis <[email protected]>
Signed-off-by: Ivan Wallis <[email protected]>
cc @lukehinds @dlorenc do you want to give this a merge? LGTM just want a final pass in case I'm missing something cosign-style-y |
looks goof from a cursory view, but there are a quite a few CI failures. |
Yeah looks like a merge conflict somewhere, otherwise should be good to go. |
Signed-off-by: Ivan Wallis <[email protected]>
Signed-off-by: Ivan Wallis <[email protected]>
@dlorenc Made some code updates and looks good for next steps. |
This looks good to me, there's one more conflict though :( Once that gets fixed i'll merge right away so you don't keep getting hit! |
Signed-off-by: Ivan Wallis <[email protected]>
Conflict resolved |
Thanks for dealing with all the delays and merge conflicts! |
### Sign a container with imported keypair | ||
|
||
```shell | ||
$ cosign sign --key import import-cosign.key dlorenc/demo |
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.
this import
is needed?
or should be just cosign sign --key import-cosign.key dlorenc/demo
?
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.
documentation needs to be updated as it should be:
cosign sign --key import-cosign.key dlorenc/demo
Summary
This PR provides support for importing RSA and EC keypairs that were generated using 3rd party utilities such as OpenSSL. Imported keypairs are converted to Cosign keypairs.
Ticket Link
This PR is in relation to #549
Release Notes
import-key-pair