Skip to content

Commit e9902f8

Browse files
authored
Merge branch 'master' into update-changelog-20231127
2 parents 29ffa8d + a78932c commit e9902f8

File tree

17 files changed

+145
-164
lines changed

17 files changed

+145
-164
lines changed

cmd/step/main.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,13 @@ func panicHandler() {
150150
fmt.Fprintf(os.Stderr, "%s\n", step.Version())
151151
fmt.Fprintf(os.Stderr, "Release Date: %s\n\n", step.ReleaseDate())
152152
panic(r)
153-
} else {
154-
fmt.Fprintln(os.Stderr, "Something unexpected happened.")
155-
fmt.Fprintln(os.Stderr, "If you want to help us debug the problem, please run:")
156-
fmt.Fprintf(os.Stderr, "STEPDEBUG=1 %s\n", strings.Join(os.Args, " "))
157-
fmt.Fprintln(os.Stderr, "and send the output to [email protected]")
158-
os.Exit(2)
159153
}
154+
155+
fmt.Fprintln(os.Stderr, "Something unexpected happened.")
156+
fmt.Fprintln(os.Stderr, "If you want to help us debug the problem, please run:")
157+
fmt.Fprintf(os.Stderr, "STEPDEBUG=1 %s\n", strings.Join(os.Args, " "))
158+
fmt.Fprintln(os.Stderr, "and send the output to [email protected]")
159+
os.Exit(2)
160160
}
161161
}
162162

command/certificate/create.go

Lines changed: 53 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,15 @@ func createCommand() cli.Command {
4141
Action: command.ActionFunc(createAction),
4242
Usage: "create a certificate or certificate signing request",
4343
UsageText: `**step certificate create** <subject> <crt-file> <key-file>
44-
[**--kms**=<uri>] [**--csr**] [**--profile**=<profile>]
45-
[**--template**=<file>] [**--set**=<key=value>] [**--set-file**=<file>]
46-
[**--not-before**=<duration>] [**--not-after**=<duration>]
47-
[**--password-file**=<file>] [**--ca**=<issuer-cert>]
48-
[**--ca-key**=<issuer-key>] [**--ca-password-file**=<file>]
49-
[**--ca-kms**=<uri>] [**--san**=<SAN>] [**--bundle**] [**--key**=<file>]
5044
[**--kty**=<type>] [**--curve**=<curve>] [**--size**=<size>]
51-
[**--skip-csr-signature**] [**--no-password**] [**--insecure**]`,
45+
[**--csr**] [**--profile**=<profile>] [**--template**=<file>]
46+
[**--set**=<key=value>] [**--set-file**=<file>]
47+
[**--not-before**=<duration>] [**--not-after**=<duration>] [**--san**=<SAN>]
48+
[**--ca**=<issuer-cert>] [**--ca-kms**=<uri>]
49+
[**--ca-key**=<issuer-key>] [**--ca-password-file**=<file>]
50+
[**--kms**=<uri>] [**--key**=<file>] [**--password-file**=<file>]
51+
[**--bundle**] [**--skip-csr-signature**]
52+
[**--no-password**] [**--subtle**] [**--insecure**]`,
5253
Description: `**step certificate create** generates a certificate or a
5354
certificate signing request (CSR) that can be signed later using 'step
5455
certificate sign' (or some other tool) to produce a certificate.
@@ -347,35 +348,37 @@ $ step certificate create \
347348
--profile intermediate-ca \
348349
--ca-kms 'pkcs11:module-path=/usr/local/lib/softhsm/libsofthsm2.so;token=smallstep?pin-value=password'
349350
--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' \
351+
--kms 'pkcs11:module-path=/usr/local/lib/softhsm/libsofthsm2.so;token=smallstep?pin-value=password' \
351352
--key 'pkcs11:id=4001' \
352353
'My KMS Intermediate' intermediate_ca.crt
353354
'''
354355
355356
Create an intermediate certificate for an RSA decryption key in Google Cloud KMS, signed by a root stored on disk, using <step-kms-plugin>:
356357
'''
357358
$ step certificate create \
358-
--profile intermediate-ca \
359-
--ca root_ca.crt --ca-key root_ca_key \
360-
--kms cloudkms: \
359+
--profile intermediate-ca \
360+
--ca root_ca.crt --ca-key root_ca_key \
361+
--kms cloudkms: \
361362
--key 'projects/myProjectID/locations/global/keyRings/myKeyRing/cryptoKeys/myKey/cryptoKeyVersions/1' \
362363
--skip-csr-signature \
363-
'My RSA Intermediate' intermediate_rsa_ca.crt
364+
'My RSA Intermediate' intermediate_rsa_ca.crt
364365
'''
365366
366367
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>:
367368
'''
368369
$ step certificate create \
369-
--profile intermediate-ca \
370+
--profile intermediate-ca \
370371
--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: \
372+
--ca root_ca.crt --ca-key 'pkcs11:id=4000' \
373+
--kms cloudkms: \
373374
--key 'projects/myProjectID/locations/global/keyRings/myKeyRing/cryptoKeys/myKey/cryptoKeyVersions/1' \
374-
'My RSA Intermediate' intermediate_rsa_ca.crt
375+
'My RSA Intermediate' intermediate_rsa_ca.crt
375376
'''
376377
`,
377378
Flags: []cli.Flag{
378-
flags.KMSUri,
379+
flags.KTY,
380+
flags.Size,
381+
flags.Curve,
379382
cli.BoolFlag{
380383
Name: "csr",
381384
Usage: `Generate a certificate signing request (CSR) instead of a certificate.`,
@@ -407,14 +410,34 @@ $ step certificate create \
407410
flags.TemplateSet,
408411
flags.TemplateSetFile,
409412
cli.StringFlag{
410-
Name: "password-file",
411-
Usage: `The path to the <file> containing the password to
412-
encrypt the new private key or decrypt the user submitted private key.`,
413+
Name: "not-before",
414+
Usage: `The <time|duration> set in the NotBefore property of the certificate. If a
415+
<time> is used it is expected to be in RFC 3339 format. If a <duration> is
416+
used, it is a sequence of decimal numbers, each with optional fraction and a
417+
unit suffix, such as "300ms", "-1.5h" or "2h45m". Valid time units are "ns",
418+
"us" (or "µs"), "ms", "s", "m", "h".`,
419+
},
420+
cli.StringFlag{
421+
Name: "not-after",
422+
Usage: `The <time|duration> set in the NotAfter property of the certificate. If a
423+
<time> is used it is expected to be in RFC 3339 format. If a <duration> is
424+
used, it is a sequence of decimal numbers, each with optional fraction and a
425+
unit suffix, such as "300ms", "-1.5h" or "2h45m". Valid time units are "ns",
426+
"us" (or "µs"), "ms", "s", "m", "h".`,
427+
},
428+
cli.StringSliceFlag{
429+
Name: "san",
430+
Usage: `Add DNS or IP Address Subjective Alternative Names (SANs). Use the '--san'
431+
flag multiple times to configure multiple SANs.`,
413432
},
414433
cli.StringFlag{
415434
Name: "ca",
416435
Usage: `The certificate authority used to issue the new certificate (PEM file).`,
417436
},
437+
cli.StringFlag{
438+
Name: "ca-kms",
439+
Usage: "The <uri> to configure the KMS used for signing the certificate",
440+
},
418441
cli.StringFlag{
419442
Name: "ca-key",
420443
Usage: `The certificate authority private key used to sign the new certificate (PEM file).`,
@@ -424,59 +447,34 @@ encrypt the new private key or decrypt the user submitted private key.`,
424447
Usage: `The path to the <file> containing the password to
425448
decrypt the CA private key.`,
426449
},
450+
flags.KMSUri,
427451
cli.StringFlag{
428452
Name: "key",
429453
Usage: "The <file> of the private key to use instead of creating a new one (PEM file).",
430454
},
455+
cli.StringFlag{
456+
Name: "password-file",
457+
Usage: `The path to the <file> containing the password to
458+
encrypt the new private key or decrypt the user submitted private key.`,
459+
},
431460
cli.BoolFlag{
432461
Name: "no-password",
433462
Usage: `Do not ask for a password to encrypt the private key.
434463
Sensitive key material will be written to disk unencrypted. This is not
435464
recommended. Requires **--insecure** flag.`,
436-
},
437-
cli.StringFlag{
438-
Name: "not-before",
439-
Usage: `The <time|duration> set in the NotBefore property of the certificate. If a
440-
<time> is used it is expected to be in RFC 3339 format. If a <duration> is
441-
used, it is a sequence of decimal numbers, each with optional fraction and a
442-
unit suffix, such as "300ms", "-1.5h" or "2h45m". Valid time units are "ns",
443-
"us" (or "µs"), "ms", "s", "m", "h".`,
444-
},
445-
cli.StringFlag{
446-
Name: "not-after",
447-
Usage: `The <time|duration> set in the NotAfter property of the certificate. If a
448-
<time> is used it is expected to be in RFC 3339 format. If a <duration> is
449-
used, it is a sequence of decimal numbers, each with optional fraction and a
450-
unit suffix, such as "300ms", "-1.5h" or "2h45m". Valid time units are "ns",
451-
"us" (or "µs"), "ms", "s", "m", "h".`,
452-
},
453-
cli.StringSliceFlag{
454-
Name: "san",
455-
Usage: `Add DNS or IP Address Subjective Alternative Names (SANs). Use the '--san'
456-
flag multiple times to configure multiple SANs.`,
457465
},
458466
cli.BoolFlag{
459467
Name: "bundle",
460468
Usage: `Bundle the new leaf certificate with the signing certificate. This flag requires
461469
the **--ca** flag.`,
462470
},
463-
flags.KTY,
464-
flags.Size,
465-
flags.Curve,
466-
flags.Force,
467-
flags.Subtle,
468-
cli.BoolFlag{
469-
Name: "insecure",
470-
Hidden: true,
471-
},
472-
cli.StringFlag{
473-
Name: "ca-kms",
474-
Usage: "The <uri> to configure the KMS used for signing the certificate",
475-
},
476471
cli.BoolFlag{
477472
Name: "skip-csr-signature",
478-
Usage: "Skip creating and signing a CSR",
473+
Usage: "Skip creating and signing a CSR.",
479474
},
475+
flags.Force,
476+
flags.Subtle,
477+
flags.InsecureHidden,
480478
},
481479
}
482480
}

command/certificate/p12.go

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package certificate
22

33
import (
4-
"crypto/rand"
54
"crypto/x509"
65
"fmt"
76

@@ -23,7 +22,8 @@ func p12Command() cli.Command {
2322
Action: command.ActionFunc(p12Action),
2423
Usage: `package a certificate and keys into a .p12 file`,
2524
UsageText: `step certificate p12 <p12-path> [<crt-path>] [<key-path>]
26-
[**--ca**=<file>] [**--password-file**=<file>]`,
25+
[**--ca**=<file>] [**--password-file**=<file>] [**--legacy**]
26+
[**--force**] [**--no-password**] [**--insecure**]`,
2727
Description: `**step certificate p12** creates a .p12 (PFX / PKCS12)
2828
file containing certificates and keys. This can then be used to import
2929
into Windows / Firefox / Java applications.
@@ -56,7 +56,15 @@ Package a certificate and private key with an empty password:
5656
5757
'''
5858
$ step certificate p12 --no-password --insecure foo.p12 foo.crt foo.key
59-
'''`,
59+
'''
60+
61+
Package a certificate and private key using a legacy encoder,
62+
63+
'''
64+
$ step certificate p12 --legacy foo.p12 foo.crt foo.key
65+
'''
66+
67+
`,
6068
Flags: []cli.Flag{
6169
cli.StringSliceFlag{
6270
Name: "ca",
@@ -69,6 +77,10 @@ multiple CAs or intermediates.`,
6977
Usage: `The path to the <file> containing the password to encrypt the .p12 file.`,
7078
},
7179
flags.NoPassword,
80+
cli.BoolFlag{
81+
Name: "legacy",
82+
Usage: "Encodes PKCS#12 files using the algorithms that were traditionally used, PBE+SHA1+RC2 for certificates and PBE+SHA1+3DES for keys.",
83+
},
7284
flags.Force,
7385
flags.Insecure,
7486
},
@@ -86,6 +98,11 @@ func p12Action(ctx *cli.Context) error {
8698
caFiles := ctx.StringSlice("ca")
8799
hasKeyAndCert := crtFile != "" && keyFile != ""
88100

101+
encoder := pkcs12.Modern
102+
if ctx.Bool("legacy") {
103+
encoder = pkcs12.LegacyRC2
104+
}
105+
89106
// If either key or cert are provided, both must be provided
90107
if !hasKeyAndCert && (crtFile != "" || keyFile != "") {
91108
return errs.MissingArguments(ctx, "key_file")
@@ -150,7 +167,7 @@ func p12Action(ctx *cli.Context) error {
150167
// Any remaining certs will be intermediates for the server
151168
x509CAs = append(x509CAs, x509CertBundle[1:]...)
152169

153-
pkcs12Data, err = pkcs12.Encode(rand.Reader, key, x509Cert, x509CAs, password)
170+
pkcs12Data, err = encoder.Encode(key, x509Cert, x509CAs, password)
154171
if err != nil {
155172
return errs.Wrap(err, "failed to encode PKCS12 data")
156173
}
@@ -163,7 +180,7 @@ func p12Action(ctx *cli.Context) error {
163180
FriendlyName: fmt.Sprintf("%s - %s", cert.Subject.String(), x509util.Fingerprint(cert)),
164181
})
165182
}
166-
pkcs12Data, err = pkcs12.EncodeTrustStoreEntries(rand.Reader, certsWithFriendlyNames, password)
183+
pkcs12Data, err = encoder.EncodeTrustStoreEntries(certsWithFriendlyNames, password)
167184
if err != nil {
168185
return errs.Wrap(err, "failed to encode PKCS12 data")
169186
}

command/crypto/hash/hash.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"strings"
1919

2020
"github.com/pkg/errors"
21+
"github.com/smallstep/cli/flags"
2122
"github.com/urfave/cli"
2223
"go.step.sm/cli-utils/errs"
2324
)
@@ -127,10 +128,7 @@ For examples, see **step help crypto hash**.
127128
: MD5 produces a 128-bit hash value
128129
`,
129130
},
130-
cli.BoolFlag{
131-
Name: "insecure",
132-
Hidden: true,
133-
},
131+
flags.InsecureHidden,
134132
},
135133
}
136134
}
@@ -187,10 +185,7 @@ For examples, see **step help crypto hash**.
187185
: MD5 produces a 128-bit hash value
188186
`,
189187
},
190-
cli.BoolFlag{
191-
Name: "insecure",
192-
Hidden: true,
193-
},
188+
flags.InsecureHidden,
194189
},
195190
}
196191
}

command/crypto/jwe/encrypt.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"os"
66

77
"github.com/pkg/errors"
8+
"github.com/smallstep/cli/flags"
89
"github.com/smallstep/cli/utils"
910
"github.com/urfave/cli"
1011
"go.step.sm/cli-utils/errs"
@@ -147,10 +148,7 @@ applications where more than one JWE payload type may be present. This
147148
parameter is ignored by JWE implementations, but may be processed by
148149
applications that use JWE.`,
149150
},
150-
cli.BoolFlag{
151-
Name: "subtle",
152-
Hidden: true,
153-
},
151+
flags.SubtleHidden,
154152
},
155153
}
156154
}

command/crypto/jwk/create.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,9 +377,9 @@ existing <pem-file> instead of creating a new key.`,
377377
},
378378
flags.PasswordFile,
379379
flags.NoPassword,
380+
flags.Force,
380381
flags.Subtle,
381382
flags.Insecure,
382-
flags.Force,
383383
},
384384
}
385385
}

command/crypto/jws/inspect.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"strings"
99

1010
"github.com/pkg/errors"
11+
"github.com/smallstep/cli/flags"
1112
"github.com/smallstep/cli/utils"
1213
"github.com/urfave/cli"
1314
"go.step.sm/cli-utils/errs"
@@ -32,10 +33,7 @@ For examples, see **step help crypto jws**.`,
3233
Usage: `Displays the header, payload and signature as a JSON object. The payload will
3334
be encoded using Base64.`,
3435
},
35-
cli.BoolFlag{
36-
Name: "insecure",
37-
Hidden: true,
38-
},
36+
flags.InsecureHidden,
3937
},
4038
}
4139
}

command/crypto/jws/sign.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,17 +150,14 @@ string. When used with '--jwk' the <kid> value must match the **"kid"** member
150150
of the JWK. When used with **--jwks** (a JWK Set) the <kid> value must match
151151
the **"kid"** member of one of the JWKs in the JWK Set.`,
152152
},
153-
cli.BoolFlag{
154-
Name: "subtle",
155-
Hidden: true,
156-
},
157153
cli.BoolFlag{
158154
Name: "no-kid",
159155
Hidden: true,
160156
},
161157
flags.PasswordFile,
162158
flags.X5cCert,
163159
flags.X5tCert,
160+
flags.SubtleHidden,
164161
},
165162
}
166163
}

0 commit comments

Comments
 (0)