fix: Use helpser in CA command.
This commit is contained in:
1 parent
b4b628210f
commit
abecfc3708
1 file changed
+2
-11
@@ -5,9 +5,6 @@ import (
|
||||
"crypto/x509"
|
||||
"crypto/x509/pkix"
|
||||
"encoding/pem"
|
||||
"errors"
|
||||
"math"
|
||||
"math/big"
|
||||
"path"
|
||||
"time"
|
||||
|
||||
@@ -32,17 +29,11 @@ var generateCACmd = &cobra.Command{
|
||||
Short: "Generate a Certificate Authority",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
// Private key for the ca.
|
||||
key := pki.GenerateKey()
|
||||
key := pki.NewKey()
|
||||
|
||||
// Cryptographically random 64bit number as the serial.
|
||||
sn, err := rand.Int(rand.Reader, big.NewInt(math.MaxInt64))
|
||||
if err != nil {
|
||||
return errors.New("Could not generate a ca serial number")
|
||||
}
|
||||
caTmpl := &x509.Certificate{
|
||||
SerialNumber: sn,
|
||||
SerialNumber: pki.NewCertSerialNumber(),
|
||||
Subject: pkix.Name{
|
||||
// TODO: Accept common name as a flag.
|
||||
CommonName: CommonName,
|
||||
},
|
||||
// Valid starting now and for 10 years.
|
||||
|
||||
Reference in new issue
Block a user