Skip to content

Sans #71

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

Merged
merged 9 commits into from
Feb 6, 2019
Merged

Sans #71

merged 9 commits into from
Feb 6, 2019

Conversation

dopey
Copy link
Contributor

@dopey dopey commented Jan 31, 2019

Add SAN support to step certificate create and step ca certificate

Currently the CLI does not support adding Subject Alternative Names. The user can provide one cmd line arg which doubles as a Common Name and the only subject alternative name (in step certificate create it is not duplicated in the SANs).

This PR adds the ability to configure SANs from the cli. If no SANs are configured then:

  1. step ca certificate will duplicate the cmd line arg as both a subject common name and the only SAN.
  2. step certificate create will use the cmd line arg as a subject common name and have no SANs.

If at least one SAN is configured (via the cmd line) then only those SANs which are explicitly configured will be set.

* examples
* modify WithHosts to add only if missing
* add a new claim to step provisioning tokens
@dopey
Copy link
Contributor Author

dopey commented Jan 31, 2019

I will remove the dep on 'sans' branch of certificates before merging (update the dependency and run dep ensure). Just wanted it for testing.

@dopey dopey self-assigned this Jan 31, 2019
@dopey dopey requested a review from maraino January 31, 2019 17:38
@codecov
Copy link

codecov bot commented Jan 31, 2019

Codecov Report

❗ No coverage uploaded for pull request base (master@36df74f). Click here to learn what that means.
The diff coverage is 31.94%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master      #71   +/-   ##
=========================================
  Coverage          ?   68.28%           
=========================================
  Files             ?       58           
  Lines             ?     7778           
  Branches          ?        0           
=========================================
  Hits              ?     5311           
  Misses            ?     2102           
  Partials          ?      365
Impacted Files Coverage Δ
token/token.go 100% <ø> (ø)
token/options.go 93.75% <0%> (ø)
crypto/x509util/crt.go 0% <0%> (ø)
crypto/x509util/profile.go 0% <0%> (ø)
command/certificate/create.go 56.83% <65.71%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 36df74f...5306984. Read the comment docs.

Copy link
Collaborator

@maraino maraino left a comment

Choose a reason for hiding this comment

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

I think we should make distinctions between sans and common name, but it's something that can be discussed.

@@ -27,7 +27,8 @@ func newCertificateCommand() cli.Command {
Usage: "generate a new private key and certificate signed by the root certificate",
UsageText: `**step ca certificate** <hostname> <crt-file> <key-file>
Copy link
Collaborator

Choose a reason for hiding this comment

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

<hostname> here should be common name, and only should be treated as hostname if no --san are given

Copy link
Collaborator

Choose a reason for hiding this comment

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

Change the definition of <hostname> in ##POSITIONAL ARGUMENTS

Copy link
Collaborator

Choose a reason for hiding this comment

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

At least we should discuss if subject should be a hostname or just the common name if --san is provided

@@ -243,6 +266,7 @@ func generateToken(sub, kid, iss, aud, root string, notBefore, notAfter time.Tim
if len(root) > 0 {
tokOptions = append(tokOptions, token.WithRootCA(root))
}
tokOptions = append(tokOptions, token.WithSANS(appendIfMissing(sans, sub)))
Copy link
Collaborator

Choose a reason for hiding this comment

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

See previous comments about sub == cn and sans

* hostname -> common name
@@ -25,16 +25,18 @@ func newCertificateCommand() cli.Command {
Name: "certificate",
Action: command.ActionFunc(newCertificateAction),
Usage: "generate a new private key and certificate signed by the root certificate",
UsageText: `**step ca certificate** <hostname> <crt-file> <key-file>
UsageText: `**step ca certificate** <common-name> <crt-file> <key-file>
Copy link
Collaborator

Choose a reason for hiding this comment

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

For consistency with step ca token let's call this <subject>

Copy link
Collaborator

@maraino maraino left a comment

Choose a reason for hiding this comment

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

👍 Remember to change the Gopkg.toml branch.

* travis trying to use go modules
@dopey dopey merged commit 1a1724d into master Feb 6, 2019
@dopey dopey deleted the sans branch September 12, 2019 23:30
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

Successfully merging this pull request may close these issues.

3 participants