aboutsummaryrefslogtreecommitdiff
path: root/client/get-anchors
diff options
context:
space:
mode:
authorRasmus Dahlberg <rasmus.dahlberg@kau.se>2021-01-29 17:29:34 +0100
committerRasmus Dahlberg <rasmus.dahlberg@kau.se>2021-01-29 17:29:34 +0100
commit7dfa743dce780659bd2e71130d91d51e93b1f68e (patch)
treea05f44a93ae28f6cdf3c4b19817a2d53c2370f61 /client/get-anchors
parent20903a5fb26e90ef4b94d157927c3e82bb1893c2 (diff)
replaced x509 with namespace on the client-side
Diffstat (limited to 'client/get-anchors')
-rw-r--r--client/get-anchors/main.go28
1 files changed, 22 insertions, 6 deletions
diff --git a/client/get-anchors/main.go b/client/get-anchors/main.go
index fe00445..1c10924 100644
--- a/client/get-anchors/main.go
+++ b/client/get-anchors/main.go
@@ -10,29 +10,45 @@ import (
"github.com/golang/glog"
"github.com/system-transparency/stfe/client"
+ "github.com/system-transparency/stfe/descriptor"
)
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")
+ logId = flag.String("log_id", "AAEgFKl1V+J3ib3Aav86UgGD7GRRtcKIdDhgc0G4vVD/TGc=", "base64-encoded log identifier")
)
func main() {
flag.Parse()
- client, err := client.NewClientFromPath(*logId, "", "", *operators, &http.Client{}, true)
+ client, err := client.NewClient(mustLoad(*operators, *logId), &http.Client{}, true, nil)
if err != nil {
glog.Fatal(err)
}
- anchors, err := client.GetAnchors(context.Background())
+ namespaces, err := client.GetNamespaces(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))
+ for i, namespace := range namespaces {
+ fmt.Printf("namespace[%d]: %s\n", i, base64.StdEncoding.EncodeToString(namespace))
}
glog.Flush()
}
+
+func mustLoad(operators, logId string) *descriptor.Log {
+ ops, err := descriptor.LoadOperators(operators)
+ if err != nil {
+ glog.Fatalf("failed loading log operators: %v")
+ }
+ id, err := base64.StdEncoding.DecodeString(logId)
+ if err != nil {
+ glog.Fatalf("invalid base64 log id: %v", err)
+ }
+ log, err := descriptor.FindLog(ops, id)
+ if err != nil {
+ glog.Fatalf("unknown log id: %v", err)
+ }
+ return log
+}