|
@@ -11,6 +11,7 @@ import (
|
|
|
"strings"
|
|
|
"time"
|
|
|
|
|
|
+ "github.com/skip2/go-qrcode"
|
|
|
"github.com/slackhq/nebula/cert"
|
|
|
"golang.org/x/crypto/ed25519"
|
|
|
)
|
|
@@ -21,6 +22,7 @@ type caFlags struct {
|
|
|
duration *time.Duration
|
|
|
outKeyPath *string
|
|
|
outCertPath *string
|
|
|
+ outQRPath *string
|
|
|
groups *string
|
|
|
ips *string
|
|
|
subnets *string
|
|
@@ -33,6 +35,7 @@ func newCaFlags() *caFlags {
|
|
|
cf.duration = cf.set.Duration("duration", time.Duration(time.Hour*8760), "Optional: amount of time the certificate should be valid for. Valid time units are seconds: \"s\", minutes: \"m\", hours: \"h\"")
|
|
|
cf.outKeyPath = cf.set.String("out-key", "ca.key", "Optional: path to write the private key to")
|
|
|
cf.outCertPath = cf.set.String("out-crt", "ca.crt", "Optional: path to write the certificate to")
|
|
|
+ cf.outQRPath = cf.set.String("out-qr", "", "Optional: output a qr code image (png) of the certificate")
|
|
|
cf.groups = cf.set.String("groups", "", "Optional: comma separated list of groups. This will limit which groups subordinate certs can use")
|
|
|
cf.ips = cf.set.String("ips", "", "Optional: comma separated list of ip and network in CIDR notation. This will limit which ip addresses and networks subordinate certs can use")
|
|
|
cf.subnets = cf.set.String("subnets", "", "Optional: comma separated list of ip and network in CIDR notation. This will limit which subnet addresses and networks subordinate certs can use")
|
|
@@ -146,6 +149,18 @@ func ca(args []string, out io.Writer, errOut io.Writer) error {
|
|
|
return fmt.Errorf("error while writing out-crt: %s", err)
|
|
|
}
|
|
|
|
|
|
+ if *cf.outQRPath != "" {
|
|
|
+ b, err = qrcode.Encode(string(b), qrcode.Medium, -5)
|
|
|
+ if err != nil {
|
|
|
+ return fmt.Errorf("error while generating qr code: %s", err)
|
|
|
+ }
|
|
|
+
|
|
|
+ err = ioutil.WriteFile(*cf.outQRPath, b, 0600)
|
|
|
+ if err != nil {
|
|
|
+ return fmt.Errorf("error while writing out-qr: %s", err)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
return nil
|
|
|
}
|
|
|
|