diff options
Diffstat (limited to 'create_public_key.go')
-rw-r--r-- | create_public_key.go | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/create_public_key.go b/create_public_key.go new file mode 100644 index 0000000..93c0677 --- /dev/null +++ b/create_public_key.go @@ -0,0 +1,26 @@ +package main + +import ( + "flag" +) + +func CreatePublicKey(args []string) error { + fs := flag.NewFlagSet("pkictl create-public-key", flag.ExitOnError) + flagPrivate := fs.String("private-key", "", "path to the private key or read from stdin") + flagOutput := fs.String("output", "stdout", "write private key to file") + fs.Parse(args) + + pk, err := loadPrivateKey(*flagPrivate) + if err != nil { + return err + } + + out, err := openOutput(*flagOutput) + if err != nil { + return err + } + defer out.Close() + + pub := pk.Public() + return writePem(pub, out) +} |