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

Allow generation of other types of SSH CA keys #14008

Merged
merged 3 commits into from
Feb 15, 2022

Conversation

cipherboy
Copy link
Contributor

@cipherboy cipherboy commented Feb 10, 2022

Curious about general sentiment here; if it is positive, I'll add docs and a changelog and we can decide what to do about the UI (leave it as-is or drop it for future work).

See #11035 for context. We derive types from the x/crypto/ssh types (which match OpenSSH's constants), thus making key bits only relevant for RSA keys. We're notably short exporting the private key (for parity with PKI secrets engine).

Resolves: #11035


This probably needs some additional UI work, but it works 😆

@ivana-mcconnell or @hellobontempo do either you have any thoughts here? It seems like the UI of SSH CA generation isn't at all like the PKI functionality; it looks like there's no dynamic fields (the hbs template needed to be updated manually) and lacks a lot of the actions for groups or changes &c. I couldn't figure out how to use a <Select /> component either; it appears to require an onChange action (which we appear to lack completely) and even without it, the options didn't populate (either manually or from the element's chosen values). Similarly failed via <FormFieldFromModel /> -- that didn't even display at all. :/

Edit: Screenshot

Screenshot from 2022-02-14 10-09-32

Copy link
Contributor

@stevendpclark stevendpclark left a comment

Choose a reason for hiding this comment

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

Overall +1 from me, a few little nits on the specific PR and I'll let others discuss/decide about the UI parts of this PR, hence the lack of approval from my part.

Copy link
Collaborator

@sgmiller sgmiller left a comment

Choose a reason for hiding this comment

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

Looks good to me. Needs docs and changelog though.

@ivana-mcconnell
Copy link

@cipherboy Thanks! Just wanting to make sure I understand the desired behaviour here: we want to enable a user to select the key type first (from ssh-rsa, ecdsa-sha2-nistp256, ecdsa-sha2-nistp384, ecdsa-sha2-nistp521, or ssh-ed25519) and then, based on that, enter the key bits. Is that correct?

Should key bits be an open input, or are there only specific values that are allowed for each key type?

@cipherboy
Copy link
Contributor Author

Hey @ivana-mcconnell!

I'd actually love to see something similar to those boxes in the PKI UI RFC doc where the user first selects if they're going to import a SSH CA (first two fields on that form) OR if they're going to generate a key. (Or put them under folding menus, you'd know better than me!).

In the former case, they just need the top two fields (private/public key).

In the latter case, they just need the two new fields. Yes, ideally a drop-down would be best for the key type; I tried getting that working with a select but failed. Presently key bits is only necessary when keyType == ssh-rsa so yes, could definitely be hidden otherwise :-) For now, its the standard RSA key sizes (which would either be an int or if you wanted some sane limits, values of 2048, 3072, 4096, and maybe something larger but unlikely). Lemme know if you think there's some easy fixes I could do (and some existing code that does it right) or what :-)

@hellobontempo
Copy link
Contributor

Hey @ivana-mcconnell!

I'd actually love to see something similar to those boxes in the PKI UI RFC doc where the user first selects if they're going to import a SSH CA (first two fields on that form) OR if they're going to generate a key. (Or put them under folding menus, you'd know better than me!).

In the former case, they just need the top two fields (private/public key).

In the latter case, they just need the two new fields. Yes, ideally a drop-down would be best for the key type; I tried getting that working with a select but failed. Presently key bits is only necessary when keyType == ssh-rsa so yes, could definitely be hidden otherwise :-) For now, its the standard RSA key sizes (which would either be an int or if you wanted some sane limits, values of 2048, 3072, 4096, and maybe something larger but unlikely). Lemme know if you think there's some easy fixes I could do (and some existing code that does it right) or what :-)

Once design (@ivana-mcconnell) has put together designs for this I'm happy to review your PR, or pair through implementing in the UI

@cipherboy cipherboy force-pushed the cipherboy-allow-generate-other-key-types branch from 3d02735 to d04f0c2 Compare February 14, 2022 20:55
@vercel vercel bot temporarily deployed to Preview – vault-storybook February 14, 2022 20:55 Inactive
@vercel vercel bot temporarily deployed to Preview – vault February 14, 2022 20:55 Inactive
@cipherboy
Copy link
Contributor Author

fmt errors all in unrelated files.

Per discussion with @ivana-mcconnell, removed the fledgling UI :-)

@cipherboy cipherboy removed the ui label Feb 14, 2022
@cipherboy cipherboy marked this pull request as ready for review February 14, 2022 21:02
@cipherboy cipherboy requested a review from a team February 14, 2022 21:08
This adds two new arguments to config/ca, mirroring the values of PKI
secrets engine but tailored towards SSH mounts. Key types are specified
as x/crypto/ssh KeyAlgo identifiers (e.g., ssh-rsa or ssh-ed25519)
and respect current defaults (ssh-rsa/4096). Key bits defaults to 0,
which for ssh-rsa then takes a value of 4096.

Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>
Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>
Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>
@cipherboy cipherboy force-pushed the cipherboy-allow-generate-other-key-types branch from d04f0c2 to e360b0e Compare February 15, 2022 14:15
@vercel vercel bot temporarily deployed to Preview – vault-storybook February 15, 2022 14:15 Inactive
@vercel vercel bot temporarily deployed to Preview – vault February 15, 2022 14:15 Inactive
@cipherboy cipherboy merged commit 696e1e4 into main Feb 15, 2022
@briankassouf briankassouf deleted the cipherboy-allow-generate-other-key-types branch February 15, 2022 19:38
cipherboy added a commit to cipherboy/vault that referenced this pull request Feb 17, 2022
To bring better parity with the changes of hashicorp#14008, wherein we allowed
OpenSSH-style key identifiers during generation. When specifying a list
of allowed keys, validate against both OpenSSH-style key identifiers
and the usual simplified names as well ("rsa" or "ecdsa"). Notably, the
PKI secrets engine prefers "ec" over "ecdsa", so we permit both as well.

Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>
cipherboy added a commit to cipherboy/vault that referenced this pull request Feb 17, 2022
To bring better parity with the changes of hashicorp#14008, wherein we allowed
OpenSSH-style key identifiers during generation. When specifying a list
of allowed keys, validate against both OpenSSH-style key identifiers
and the usual simplified names as well ("rsa" or "ecdsa"). Notably, the
PKI secrets engine prefers "ec" over "ecdsa", so we permit both as well.

Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>
cipherboy added a commit that referenced this pull request Feb 18, 2022
* Allow OpenSSH-style key type identifiers

To bring better parity with the changes of #14008, wherein we allowed
OpenSSH-style key identifiers during generation. When specifying a list
of allowed keys, validate against both OpenSSH-style key identifiers
and the usual simplified names as well ("rsa" or "ecdsa"). Notably, the
PKI secrets engine prefers "ec" over "ecdsa", so we permit both as well.

Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>

* Fix missing quote in docs
@cipherboy cipherboy added this to the 1.10 milestone Feb 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SSH CA: generate_signing_key to support ed25519 keys
5 participants