| 1 | package main |
| 2 | |
| 3 | import ( |
| 4 | "fmt" |
| 5 | "os" |
| 6 | "strings" |
| 7 | |
| 8 | "github.com/pkg/errors" |
| 9 | ) |
| 10 | |
| 11 | func commandListKeys() error { |
| 12 | for j, ident := range idents { |
| 13 | if j > 0 { |
| 14 | fmt.Print("\n") |
| 15 | } |
| 16 | |
| 17 | cert, err := ident.Certificate() |
| 18 | if err != nil { |
| 19 | fmt.Fprintln(os.Stderr, "WARNING:", errors.Wrap(err, "failed to get identity certificate")) |
| 20 | continue |
| 21 | } |
| 22 | |
| 23 | fmt.Println(" ID:", certHexFingerprint(cert)) |
| 24 | fmt.Println(" S/N:", cert.SerialNumber.Text(16)) |
| 25 | fmt.Println("Algorithm:", cert.SignatureAlgorithm.String()) |
| 26 | fmt.Println(" Validity:", cert.NotBefore.String(), "-", cert.NotAfter.String()) |
| 27 | fmt.Println(" Issuer:", cert.Issuer.ToRDNSequence().String()) |
| 28 | fmt.Println(" Subject:", cert.Subject.ToRDNSequence().String()) |
| 29 | fmt.Println(" Emails:", strings.Join(certEmails(cert), ", ")) |
| 30 | } |
| 31 | |
| 32 | return nil |
| 33 | } |