list

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:    "list",
	Usage:   "List certificates issued",
	Aliases: []string{"ls"},
	Flags: []cli.Flag{
		&cli.BoolFlag{
			Name:    "profile",
			Aliases: []string{"p", "profiles"},
			Usage:   "Print list of profiles",
		},
	},
	Action: func(c *cli.Context) error {
		env := action.GlobalEnvironment
		slog := env.Logger.Sugar()

		if c.Bool("profile") {
			if err := LsProfile(env); err != nil {
				return err
			}
			return nil
		}

		profile, err := env.Profile()
		if err != nil {
			return err
		}

		now := env.NowImpl()
		st := profile.Status(now)
		if st.Code != storage.ValidCA {
			if st.Code == storage.Expired {
				slog.Warnf("Expired %s")
			} else {
				slog.Infof("Could not find a valid CA profile %q: %v", env.ProfileName, st)
				return nil
			}
		}

		db, err := issuedb.New(env.Randr, profile.IssueDBPath())
		if err != nil {
			return err
		}

		es, err := db.Entries()
		if err != nil {
			return err
		}

		fmt.Printf("                             YY/MM/DD YY/MM/DD\n")
		fmt.Printf("Status   SerialNumber        NotBefor NotAfter Subject\n")
		for _, e := range es {
			infotxt := CertInfo([]byte(e.CertificatePEM))

			switch e.State {
			case issuedb.IssueInProgress:
				fmt.Printf("issueing %19d\n", e.SerialNumber)

			case issuedb.ActiveCertificate:
				fmt.Printf("active   %19d %s\n", e.SerialNumber, infotxt)
			}
		}

		return nil
	},
}

Functions

func CertInfo added in v0.2.0

func CertInfo(pem []byte) string

func LsProfile added in v0.1.0

func LsProfile(env *action.Environment) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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