aboutsummaryrefslogblamecommitdiff
path: root/create_public_key.go
blob: 93c06778e299b321655f4803f64f208c2df9a3a1 (plain) (tree)

























                                                                                                 
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)
}