...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package cmd
16
17 import (
18 "context"
19 "fmt"
20
21 ct "github.com/google/certificate-transparency-go"
22 "github.com/spf13/cobra"
23 )
24
25 func init() {
26 rootCmd.AddCommand(&cobra.Command{
27 Use: fmt.Sprintf("get-sth %s", connectionFlags),
28 Aliases: []string{"sth"},
29 Short: "Fetch the latest STH of the log",
30 Args: cobra.MaximumNArgs(0),
31 Run: func(cmd *cobra.Command, _ []string) {
32 runGetSTH(cmd.Context())
33 },
34 })
35 }
36
37
38 func runGetSTH(ctx context.Context) {
39 logClient := connect(ctx)
40 sth, err := logClient.GetSTH(ctx)
41 if err != nil {
42 exitWithDetails(err)
43 }
44
45 when := ct.TimestampToTime(sth.Timestamp)
46 fmt.Printf("%v (timestamp %d): Got STH for %v log (size=%d) at %v, hash %x\n", when, sth.Timestamp, sth.Version, sth.TreeSize, logClient.BaseURI(), sth.SHA256RootHash)
47 fmt.Printf("%v\n", signatureToString(&sth.TreeHeadSignature))
48 }
49
View as plain text