Version: v0.2.3 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Nov 6, 2020 License: Apache-2.0 Imports: 14 Imported by: 0




This section is empty.


View Source
var Command = &cli.Command{
	Name:    "pubkeyhash",
	Usage:   "Dump pubkeyhash of the specified public key/certificate",
	Aliases: []string{"hash"},
	Flags: []cli.Flag{
			Name:    "output",
			Aliases: []string{"o"},
			Usage:   "Output format. (full, hashonly)",
			Value:   "full",
			Name:    "file",
			Aliases: []string{"f"},
			Usage:   "PEM file containing public key/certificates",
			Value:   "-",
	Action: func(c *cli.Context) error {
		env := action.GlobalEnvironment

		ftstr := c.String("output")
		ft, err := FormatTypeFromString(ftstr)
		if err != nil {
			return err

		var r io.Reader

		path := c.String("file")
		if path == "-" {
			r = os.Stdin
		} else {
			f, err := os.Open(path)
			if err != nil {
				return err
			defer f.Close()

			r = f

		bs, err := ioutil.ReadAll(r)
		if err != nil {
			return err

		khs, err := ExtractPublicKeyHashesFromPem(bs, env.Logger)
		if err != nil {
			return err

		for _, e := range khs {
			if ft.ShouldOutputLabel() {
				fmt.Printf("# %s\n", e.Label)
			fmt.Printf("%s\n", e.Hash)

		return nil


This section is empty.


type FormatType added in v0.2.2

type FormatType int
const (
	FormatFull FormatType = iota

func FormatTypeFromString added in v0.2.2

func FormatTypeFromString(s string) (FormatType, error)

func (FormatType) ShouldOutputLabel added in v0.2.2

func (ft FormatType) ShouldOutputLabel() bool

type KeyHash added in v0.2.2

type KeyHash struct {
	Label string
	Hash  string

func ExtractPublicKeyHashesFromPem added in v0.2.2

func ExtractPublicKeyHashesFromPem(bs []byte, logger *zap.Logger) ([]KeyHash, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL