-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
48 lines (43 loc) · 1.07 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
This tool reads JSON from stdin, attempts to parse it as "log" claim of
endorsements, and verifies that the given certificates are committed to the
respective logs.
*/
package main
import (
"encoding/json"
"flag"
"io"
"log"
"os"
"github.com/adem-wg/adem-proto/pkg/args"
"github.com/adem-wg/adem-proto/pkg/roots"
"github.com/adem-wg/adem-proto/pkg/tokens"
)
func init() {
args.AddCTArgs()
}
func main() {
flag.Parse()
if bs, err := io.ReadAll(os.Stdin); err != nil {
log.Fatalf("could not read from stdin: %s", err)
} else if err := args.FetchKnownLogs(); err != nil {
log.Fatalf("could not fetch known CT logs: %s", err)
} else {
logs := []*tokens.LogConfig{}
if err := json.Unmarshal(bs, &logs); err != nil {
log.Fatalf("could not decode json: %s", err)
} else {
results := roots.VerifyInclusionConfig(logs)
for _, r := range results {
var msg string
if r.Ok {
msg = "certificate included in log"
} else {
msg = "inclusion check failed for log"
}
log.Printf("%s:\n\turl: %s\n\tname: %s", msg, r.LogURL, r.LogID)
}
}
}
}