aboutsummaryrefslogtreecommitdiff
path: root/client/get-anchors
diff options
context:
space:
mode:
authorRasmus Dahlberg <rasmus.dahlberg@kau.se>2020-11-05 20:13:39 +0100
committerRasmus Dahlberg <rasmus.dahlberg@kau.se>2020-11-05 20:13:39 +0100
commit0fb26b527a9dbf9d90e6df10f025d2a546cde407 (patch)
tree5940fe796324a63685a5ed63a0e1d7b1b135a259 /client/get-anchors
parentd95210ed7e2b00394fe55abd08c1ebc9252f39a6 (diff)
added client-side get-anchors code
Diffstat (limited to 'client/get-anchors')
-rw-r--r--client/get-anchors/main.go38
1 files changed, 38 insertions, 0 deletions
diff --git a/client/get-anchors/main.go b/client/get-anchors/main.go
new file mode 100644
index 0000000..fe00445
--- /dev/null
+++ b/client/get-anchors/main.go
@@ -0,0 +1,38 @@
+package main
+
+import (
+ "context"
+ "flag"
+ "fmt"
+
+ "encoding/base64"
+ "net/http"
+
+ "github.com/golang/glog"
+ "github.com/system-transparency/stfe/client"
+)
+
+var (
+ operators = flag.String("operators", "../../descriptor/stfe.json", "path to json-encoded list of log operators")
+ logId = flag.String("log_id", "B9oCJk4XIOMXba8dBM5yUj+NLtqTE6xHwbvR9dYkHPM=", "base64-encoded log identifier")
+)
+
+func main() {
+ flag.Parse()
+
+ client, err := client.NewClientFromPath(*logId, "", "", *operators, &http.Client{}, true)
+ if err != nil {
+ glog.Fatal(err)
+ }
+
+ anchors, err := client.GetAnchors(context.Background())
+ if err != nil {
+ glog.Fatal(err)
+ }
+ for i, anchor := range anchors {
+ glog.V(3).Infof("anchor[%d] serial number: %x", i, anchor.SerialNumber)
+ fmt.Printf("anchor[%d]: %s\n", i, base64.StdEncoding.EncodeToString(anchor.Raw))
+ }
+
+ glog.Flush()
+}