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

Add handling of cnf claim #1092

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Add handling of cnf claim #1092

wants to merge 2 commits into from

Conversation

maraino
Copy link
Collaborator

@maraino maraino commented Dec 29, 2023

Allow to add confirmation claims to tokens

This commit allows passing confirmation claims to tokens to tie the
tokens with a provided CSR or SSH public key.

Fixes smallstep/certificates#1637

Related PR:

@github-actions github-actions bot added the needs triage Waiting for discussion / prioritization by team label Dec 29, 2023
This commit allows to generate fingerprints for CSR files to the
`step certificate fingerprint` command.
This commit allows passing confirmation claims to tokens to tie the
tokens with a provided CSR or SSH public key.

The confirmation claim is implemented in the token command as well as
the com commands that uses a given CSR or ssh public key. Those are:

  - step ca token
  - step ca sign
  - step ssh certificate --sign

Fixes smallstep/certificates#1637
Comment on lines +58 to +63
'''

Get the fingerprint for a CSR using base64-url without padding encoding:
'''
$ step certificate fingerprint --format base64-url-raw hello.csr
PJLNhtQoBE1yGN_ZKzr4Y2U5pyqIGiyyszkoz2raDOw
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
'''
Get the fingerprint for a CSR using base64-url without padding encoding:
'''
$ step certificate fingerprint --format base64-url-raw hello.csr
PJLNhtQoBE1yGN_ZKzr4Y2U5pyqIGiyyszkoz2raDOw
'''
Get the fingerprint for a CSR using base64-url encoding without padding:
'''
$ step certificate fingerprint --format base64-url-raw hello.csr
PJLNhtQoBE1yGN_ZKzr4Y2U5pyqIGiyyszkoz2raDOw

Comment on lines +112 to +114
default:
return fmt.Errorf("unsupported fingerprint for %T", vv)
}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
default:
return fmt.Errorf("unsupported fingerprint for %T", vv)
}
default:
return fmt.Errorf("unsupported fingerprint for %T", v)
}

@@ -186,6 +200,8 @@ multiple principals.`,
flags.SSHPOPKey,
flags.NebulaCert,
flags.NebulaKey,
flags.ConfirmationFile,
flags.ConfirmationKid,
Copy link
Member

@hslatman hslatman Apr 2, 2024

Choose a reason for hiding this comment

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

Can you add an example for --cnf-kid?

Comment on lines +390 to +395
// ConfirmationKid is a cli.Flag used to add a confirmation claim in the
// token.
ConfirmationKid = cli.StringFlag{
Name: "cnf-kid",
Usage: `The <fingerprint> of the CSR or SSH public key to restrict this token for.`,
}
Copy link
Member

Choose a reason for hiding this comment

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

Should this be just --cnf? Do we expect different types of values in there? See my note about using kid too.

Comment on lines +116 to +122
kid, err := fingerprint.New(data, crypto.SHA256, fingerprint.Base64RawURLFingerprint)
if err != nil {
return err
}
c.Set(ConfirmationClaim, map[string]string{
"kid": kid,
})
Copy link
Member

Choose a reason for hiding this comment

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

For the X509 case, the value maybe shouldn't be put in kid, as we generally use that claim to carry the thumbprint of a JWK (used as key identifier); not the hash of a full request. Arguably, the kid can be filled arbitrarily, as long as it identifiers the key, so it's not wrong to put the hash of the CSR in there, but I think using a different name might be better.

There's "cnf":{"x5t#S256":"...."} in https://datatracker.ietf.org/doc/html/rfc8705#section-appendix.a, which is for certificates. Can we find/use/create a (custom) variant of that for certificate requests? E.g. "x5rt#S256", or something like that?

@hslatman hslatman changed the title Fix 1637 Add handling of cnf claim Apr 2, 2024
@hslatman hslatman modified the milestones: v0.26.1, v0.26.2 Apr 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage Waiting for discussion / prioritization by team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Option to bind JWK provisioner tokens with CSR
2 participants