Skip to content

Commit 6fdddea

Browse files
committed
erge branch 'master' into carl/winget
2 parents 6f66fa3 + 0e015ff commit 6fdddea

File tree

17 files changed

+300
-168
lines changed

17 files changed

+300
-168
lines changed

CHANGELOG.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,44 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
2828

2929
## [Unreleased]
3030

31+
### Added
32+
33+
- Add support for provisioner claim `disableSmallstepExtensions`
34+
(smallstep/cli#986).
35+
- Add support for PowerShell plugins on Windows (smallstep/certificates#992).
36+
- Create API token using team slug (smallstep/cli#980).
37+
- Detect OIDC tokens issued by Kubernetes (smallstep/cli#953).
38+
- Add support for Smallstep Managed Endpoint X509 extension
39+
(smallstep/cli#989).
40+
- Support signing a certificate for a private key that can only be used for
41+
encryption with the `--skip-csr-signature` flag in `step certificate create`.
42+
Some KMSs restrict key usage to a single type of cryptographic operation.
43+
This blocks RSA decryption keys from being used to sign a CSR for their public
44+
key. Using the `--skip-csr-signature` flag, the public key is used directly
45+
with a certificate template, removing the need for the CSR signature.
46+
- Add all AWS identity document certificates (smallstep/certificates#1510)
47+
48+
### Changed
49+
50+
- Increase PBKDF2 iterations to 600k (smallstep/cli#949).
51+
- `--kms` flag is no longer used for the CA (signing) key for `step certificate create`. It was replaced by the `--ca-kms` flag (smallstep/cli#942).
52+
53+
### Fixed
54+
55+
- Look for Windows plugins with executable extensions
56+
(smallstep/certificates#976)
57+
- Fix empty ca.json with invalid template data (smallstep/certificates#1501).
58+
- Fix interactive prompt on docker builds (smallstep/cli#963).
59+
- `step certificate fingerprint` correctly parse PEM files with non-PEM header
60+
(smallstep/crypto#311)
61+
- `step certificate format` correctly parse PEM files with non-PEM header
62+
(smallstep/cli#1006)
63+
64+
### Remove
65+
66+
- Remove automatic creation of the step path (smallstep/certificates#991)
67+
68+
3169
## [v0.24.4] - 2023-05-11
3270

3371
### Added

cmd/step/main.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package main
33
import (
44
"errors"
55
"fmt"
6-
"math/rand"
76
"os"
87
"reflect"
98
"regexp"
@@ -54,11 +53,17 @@ var BuildTime = "N/A"
5453
func init() {
5554
step.Set("Smallstep CLI", Version, BuildTime)
5655
ca.UserAgent = step.Version()
57-
rand.Seed(time.Now().UnixNano())
5856
}
5957

6058
func main() {
59+
// initialize step environment.
60+
if err := step.Init(); err != nil {
61+
fmt.Fprintln(os.Stderr, err.Error())
62+
os.Exit(1)
63+
}
64+
6165
defer panicHandler()
66+
6267
// Override global framework components
6368
cli.VersionPrinter = func(c *cli.Context) {
6469
version.Command(c)

command/ca/bootstrap.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ $ step ca bootstrap --team superteam --team-url https://config.example.com/<>
6565
fingerprintFlag,
6666
cli.BoolFlag{
6767
Name: "install",
68-
Usage: "Install the root certificate into the system truststore.",
68+
Usage: "Install the root certificate into the system's default trust store.",
6969
},
7070
flags.Team,
7171
flags.TeamAuthority,

command/ca/provisioner/add.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ SCEP
167167
sshHostDefaultDurFlag,
168168
disableRenewalFlag,
169169
allowRenewalAfterExpiryFlag,
170+
disableSmallstepExtensionsFlag,
170171
//enableX509Flag,
171172
enableSSHFlag,
172173

@@ -360,8 +361,9 @@ func addAction(ctx *cli.Context) (err error) {
360361
HostDurations: &linkedca.Durations{},
361362
Enabled: !(ctx.IsSet("ssh") && !ctx.Bool("ssh")),
362363
},
363-
DisableRenewal: ctx.Bool("disable-renewal"),
364-
AllowRenewalAfterExpiry: ctx.Bool("allow-renewal-after-expiry"),
364+
DisableRenewal: ctx.Bool("disable-renewal"),
365+
AllowRenewalAfterExpiry: ctx.Bool("allow-renewal-after-expiry"),
366+
DisableSmallstepExtensions: ctx.Bool("disable-smallstep-extensions"),
365367
}
366368

367369
if ctx.IsSet("x509-min-dur") {

command/ca/provisioner/provisioner.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,10 @@ unit suffix, such as "300ms", "-1.5h" or "2h45m". Valid time units are "ns",
248248
Name: "allow-renewal-after-expiry",
249249
Usage: `Allow renewals for expired certificates generated by this provisioner.`,
250250
}
251+
disableSmallstepExtensionsFlag = cli.BoolFlag{
252+
Name: "disable-smallstep-extensions",
253+
Usage: `Disable the Smallstep extension for all certificates generated by this provisioner.`,
254+
}
251255
//enableX509Flag = cli.BoolFlag{
252256
// Name: "x509",
253257
// Usage: `Enable provisioning of x509 certificates.`,

command/ca/provisioner/update.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ SCEP
166166
sshHostDefaultDurFlag,
167167
disableRenewalFlag,
168168
allowRenewalAfterExpiryFlag,
169+
disableSmallstepExtensionsFlag,
169170
//enableX509Flag,
170171
enableSSHFlag,
171172

@@ -404,8 +405,11 @@ func updateClaims(ctx *cli.Context, p *linkedca.Provisioner) {
404405
if ctx.IsSet("allow-renewal-after-expiry") {
405406
p.Claims.AllowRenewalAfterExpiry = ctx.Bool("allow-renewal-after-expiry")
406407
}
407-
claims := p.Claims
408+
if ctx.IsSet("disable-smallstep-extensions") {
409+
p.Claims.DisableSmallstepExtensions = ctx.Bool("disable-smallstep-extensions")
410+
}
408411

412+
claims := p.Claims
409413
if claims.X509 == nil {
410414
claims.X509 = &linkedca.X509Claims{}
411415
}

command/ca/sign.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func signCertificateCommand() cli.Command {
2020
return cli.Command{
2121
Name: "sign",
2222
Action: command.ActionFunc(signCertificateAction),
23-
Usage: "generate a new certificate signing a certificate request",
23+
Usage: "generate a new certificate from signing a certificate request",
2424
UsageText: `**step ca sign** <csr-file> <crt-file>
2525
[**--token**=<token>] [**--issuer**=<name>] [**--provisioner-password-file=<file>]
2626
[**--not-before**=<time|duration>] [**--not-after**=<time|duration>]

command/certificate/certificate.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,12 @@ Extract the public key from a PEM encoded certificate:
7070
$ step certificate key foo.crt
7171
'''
7272
73-
Install a root certificate in the system truststore:
73+
Install a root certificate in the system's default trust store:
7474
'''
7575
$ step certificate install root-ca.crt
7676
'''
7777
78-
Uninstall a root certificate from the system truststore:
78+
Uninstall a root certificate from the system's default trust store:
7979
'''
8080
$ step certificate uninstall root-ca.crt
8181
'''`,

command/certificate/create.go

Lines changed: 68 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ func createCommand() cli.Command {
4444
[**--kms**=<uri>] [**--csr**] [**--profile**=<profile>]
4545
[**--template**=<file>] [**--set**=<key=value>] [**--set-file**=<file>]
4646
[**--not-before**=<duration>] [**--not-after**=<duration>]
47-
[**--password-file**=<file>] [**--ca**=<issuer-cert>]
47+
[**--password-file**=<file>] [**--ca**=<issuer-cert>]
4848
[**--ca-key**=<issuer-key>] [**--ca-password-file**=<file>]
49-
[**--san**=<SAN>] [**--bundle**] [**--key**=<file>]
49+
[**--ca-kms**=<uri>] [**--san**=<SAN>] [**--bundle**] [**--key**=<file>]
5050
[**--kty**=<type>] [**--curve**=<curve>] [**--size**=<size>]
51-
[**--no-password**] [**--insecure**]`,
51+
[**--skip-csr-signature**] [**--no-password**] [**--insecure**]`,
5252
Description: `**step certificate create** generates a certificate or a
5353
certificate signing request (CSR) that can be signed later using 'step
5454
certificate sign' (or some other tool) to produce a certificate.
@@ -345,11 +345,34 @@ $ step kms create \
345345
'pkcs11:id=4001;object=intermediate-key'
346346
$ step certificate create \
347347
--profile intermediate-ca \
348-
--kms 'pkcs11:module-path=/usr/local/lib/softhsm/libsofthsm2.so;token=smallstep?pin-value=password' \
348+
--ca-kms 'pkcs11:module-path=/usr/local/lib/softhsm/libsofthsm2.so;token=smallstep?pin-value=password'
349349
--ca root_ca.crt --ca-key 'pkcs11:id=4000' \
350+
--kms 'pkcs11:module-path=/usr/local/lib/softhsm/libsofthsm2.so;token=smallstep?pin-value=password' \
350351
--key 'pkcs11:id=4001' \
351352
'My KMS Intermediate' intermediate_ca.crt
352353
'''
354+
355+
Create an intermediate certificate for an RSA decryption key in Google Cloud KMS, signed by a root stored on disk, using <step-kms-plugin>:
356+
'''
357+
$ step certificate create \
358+
--profile intermediate-ca \
359+
--ca root_ca.crt --ca-key root_ca_key \
360+
--kms cloudkms: \
361+
--key 'projects/myProjectID/locations/global/keyRings/myKeyRing/cryptoKeys/myKey/cryptoKeyVersions/1' \
362+
--skip-csr-signature \
363+
'My RSA Intermediate' intermediate_rsa_ca.crt
364+
'''
365+
366+
Create an intermediate certificate for an RSA signing key in Google Cloud KMS, signed by a root stored in an HSM, using <step-kms-plugin>:
367+
'''
368+
$ step certificate create \
369+
--profile intermediate-ca \
370+
--ca-kms 'pkcs11:module-path=/usr/local/lib/softhsm/libsofthsm2.so;token=smallstep?pin-value=password' \
371+
--ca root_ca.crt --ca-key 'pkcs11:id=4000' \
372+
--kms cloudkms: \
373+
--key 'projects/myProjectID/locations/global/keyRings/myKeyRing/cryptoKeys/myKey/cryptoKeyVersions/1' \
374+
'My RSA Intermediate' intermediate_rsa_ca.crt
375+
'''
353376
`,
354377
Flags: []cli.Flag{
355378
flags.KMSUri,
@@ -446,6 +469,14 @@ the **--ca** flag.`,
446469
Name: "insecure",
447470
Hidden: true,
448471
},
472+
cli.StringFlag{
473+
Name: "ca-kms",
474+
Usage: "The <uri> to configure the KMS used for signing the certificate",
475+
},
476+
cli.BoolFlag{
477+
Name: "skip-csr-signature",
478+
Usage: "Skip creating and signing a CSR",
479+
},
449480
},
450481
}
451482
}
@@ -485,17 +516,22 @@ func createAction(ctx *cli.Context) error {
485516
}
486517

487518
var (
488-
sans = ctx.StringSlice("san")
489-
profile = ctx.String("profile")
490-
templateFile = ctx.String("template")
491-
bundle = ctx.Bool("bundle")
492-
subtle = ctx.Bool("subtle")
519+
sans = ctx.StringSlice("san")
520+
profile = ctx.String("profile")
521+
templateFile = ctx.String("template")
522+
bundle = ctx.Bool("bundle")
523+
subtle = ctx.Bool("subtle")
524+
skipCSRSignature = ctx.Bool("skip-csr-signature")
493525
)
494526

495527
if ctx.IsSet("profile") && templateFile != "" {
496528
return errs.IncompatibleFlagWithFlag(ctx, "profile", "template")
497529
}
498530

531+
if ctx.Bool("csr") && skipCSRSignature {
532+
return errs.IncompatibleFlagWithFlag(ctx, "csr", "skip-csr-signature")
533+
}
534+
499535
// Read template if passed
500536
var template string
501537
if templateFile != "" {
@@ -631,20 +667,31 @@ func createAction(ctx *cli.Context) error {
631667
defaultValidity = defaultTemplatevalidity
632668
}
633669

634-
// Create X.509 certificate used as base for the certificate
635-
cr, err := x509util.CreateCertificateRequest(subject, sans, signer)
636-
if err != nil {
637-
return err
638-
}
639-
640670
// Create X.509 certificate
641671
templateData := x509util.CreateTemplateData(subject, sans)
642672
templateData.SetUserData(userData)
643-
certificate, err := x509util.NewCertificate(cr, x509util.WithTemplate(template, templateData))
644-
if err != nil {
645-
return err
673+
674+
var certTemplate = &x509.Certificate{}
675+
if skipCSRSignature {
676+
certTemplate.PublicKey = pub
677+
certificate, err := x509util.NewCertificateFromX509(certTemplate, x509util.WithTemplate(template, templateData))
678+
if err != nil {
679+
return err
680+
}
681+
certTemplate = certificate.GetCertificate()
682+
} else {
683+
// Create X.509 certificate used as base for the certificate
684+
cr, err := x509util.CreateCertificateRequest(subject, sans, priv)
685+
if err != nil {
686+
return err
687+
}
688+
certificate, err := x509util.NewCertificate(cr, x509util.WithTemplate(template, templateData))
689+
if err != nil {
690+
return err
691+
}
692+
certTemplate = certificate.GetCertificate()
646693
}
647-
certTemplate := certificate.GetCertificate()
694+
648695
if parent == nil {
649696
parent = certTemplate
650697
}
@@ -766,9 +813,9 @@ func parseSigner(ctx *cli.Context, defaultSigner crypto.Signer) (*x509.Certifica
766813
var (
767814
caCert = ctx.String("ca")
768815
caKey = ctx.String("ca-key")
816+
caKMS = ctx.String("ca-kms")
769817
profile = ctx.String("profile")
770818
template = ctx.String("template")
771-
kms = ctx.String("kms")
772819
)
773820

774821
// Check required flags when profile is used.
@@ -819,7 +866,7 @@ func parseSigner(ctx *cli.Context, defaultSigner crypto.Signer) (*x509.Certifica
819866
opts = append(opts, pemutil.WithPasswordFile(passFile))
820867
}
821868

822-
signer, err := cryptoutil.CreateSigner(kms, caKey, opts...)
869+
signer, err := cryptoutil.CreateSigner(caKMS, caKey, opts...)
823870
if err != nil {
824871
return nil, nil, err
825872
}

command/certificate/fingerprint.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func fingerprintCommand() cli.Command {
2121
Action: cli.ActionFunc(fingerprintAction),
2222
Usage: "print the fingerprint of a certificate",
2323
UsageText: `**step certificate fingerprint** <crt-file>
24-
[**--bundle**] [**--roots**=<root-bundle>] [**--servername**=<servername>]
24+
[**--bundle**] [**--roots**=<root-bundle>] [**--servername**=<servername>]
2525
[**--format**=<format>] [**--sha1**] [**--insecure**]`,
2626
Description: `**step certificate fingerprint** reads a certificate and prints to STDOUT the
2727
certificate SHA256 of the raw certificate.

0 commit comments

Comments
 (0)