dump

package
v0.2.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Command = &cli.Command{
	Name:      "dump",
	Usage:     "dump details of the input x509 certificate",
	UsageText: `kmgm tool dump`,
	Flags: []cli.Flag{
		&cli.StringFlag{
			Name:    "output",
			Aliases: []string{"o"},
			Usage:   "Output format. (full, pem)",
			Value:   "full",
		},
		&cli.StringFlag{
			Name:    "input",
			Aliases: []string{"i"},
			Usage:   "The certificate file.",
			Value:   "-",
		},
	},
	Action: func(c *cli.Context) error {
		ftstr := c.String("output")
		ft, err := show.FormatTypeFromString(ftstr)
		if err != nil {
			return err
		}

		var r io.Reader
		inpath := c.String("input")
		if inpath == "-" {
			r = os.Stdin
		} else {
			f, err := os.Open(inpath)
			if err != nil {
				return err
			}
			r = f
			defer f.Close()
		}

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

		certs, err := pemparser.ParseCertificates(bs)
		if err != nil {
			return err
		}

		w := os.Stdout
		for _, cert := range certs {
			show.PrintCertInfo(w, cert, ft)
		}

		return nil
	},
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL