Skip to content

Commit

Permalink
PEM format check should query whole file for expected header (#1006)
Browse files Browse the repository at this point in the history
* rand.Seed(SEED) deprecated and unnecessary since golang 1.20
  • Loading branch information
dopey authored Aug 17, 2023
1 parent ec31caa commit 6020d95
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 5 deletions.
2 changes: 0 additions & 2 deletions cmd/step/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package main
import (
"errors"
"fmt"
"math/rand"
"os"
"reflect"
"regexp"
Expand Down Expand Up @@ -54,7 +53,6 @@ var BuildTime = "N/A"
func init() {
step.Set("Smallstep CLI", Version, BuildTime)
ca.UserAgent = step.Version()
rand.Seed(time.Now().UnixNano())
}

func main() {
Expand Down
2 changes: 1 addition & 1 deletion command/certificate/fingerprint.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func fingerprintCommand() cli.Command {
Action: cli.ActionFunc(fingerprintAction),
Usage: "print the fingerprint of a certificate",
UsageText: `**step certificate fingerprint** <crt-file>
[**--bundle**] [**--roots**=<root-bundle>] [**--servername**=<servername>]
[**--bundle**] [**--roots**=<root-bundle>] [**--servername**=<servername>]
[**--format**=<format>] [**--sha1**] [**--insecure**]`,
Description: `**step certificate fingerprint** reads a certificate and prints to STDOUT the
certificate SHA256 of the raw certificate.
Expand Down
2 changes: 1 addition & 1 deletion command/certificate/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func formatAction(ctx *cli.Context) error {
}

switch {
case bytes.HasPrefix(crtBytes, []byte("-----BEGIN ")): // PEM format
case bytes.Contains(crtBytes, []byte("-----BEGIN ")): // PEM format
ob, err = decodeCertificatePem(crtBytes)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/smallstep/cli

go 1.19
go 1.20

require (
github.com/Microsoft/go-winio v0.6.1
Expand Down

0 comments on commit 6020d95

Please sign in to comment.