certspotter/cmd/ctparsewatch/main.go

44 lines
954 B
Go
Raw Normal View History

package main
import (
"flag"
"os"
2016-05-04 20:49:07 +02:00
"src.agwa.name/certspotter"
"src.agwa.name/certspotter/ct"
"src.agwa.name/certspotter/cmd"
)
func DefaultStateDir () string {
if envVar := os.Getenv("CTPARSEWATCH_STATE_DIR"); envVar != "" {
return envVar
} else {
return cmd.DefaultStateDir("ctparsewatch")
}
}
var stateDir = flag.String("state_dir", DefaultStateDir(), "Directory for storing state")
2016-05-04 20:49:07 +02:00
func processEntry (scanner *certspotter.Scanner, entry *ct.LogEntry) {
info := certspotter.EntryInfo{
LogUri: scanner.LogUri,
Entry: entry,
2016-05-04 20:49:07 +02:00
IsPrecert: certspotter.IsPrecert(entry),
FullChain: certspotter.GetFullChain(entry),
}
2016-05-04 20:49:07 +02:00
info.CertInfo, info.ParseError = certspotter.MakeCertInfoFromLogEntry(entry)
if info.CertInfo != nil {
info.Identifiers, info.IdentifiersParseError = info.CertInfo.ParseIdentifiers()
}
if info.HasParseErrors() {
cmd.LogEntry(&info)
}
}
func main() {
flag.Parse()
cmd.Main(*stateDir, processEntry)
}