From 1719aa5d8ef5216f034a1a0b873cb0f1468112ed Mon Sep 17 00:00:00 2001 From: Andrew Ayer Date: Fri, 6 Jan 2017 12:50:21 -0800 Subject: [PATCH] Set log ID in STHs that we download This will facilitate STH pollination. --- cmd/common.go | 2 +- scanner.go | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/cmd/common.go b/cmd/common.go index 6aac0b2..3cddc6d 100644 --- a/cmd/common.go +++ b/cmd/common.go @@ -108,7 +108,7 @@ func makeLogHandle(logInfo *certspotter.LogInfo) (*logHandle, error) { if err != nil { return nil, fmt.Errorf("Bad public key: %s", err) } - ctlog.scanner = certspotter.NewScanner(logInfo.FullURI(), logKey, &certspotter.ScannerOptions{ + ctlog.scanner = certspotter.NewScanner(logInfo.FullURI(), logInfo.ID(), logKey, &certspotter.ScannerOptions{ BatchSize: *batchSize, NumWorkers: *numWorkers, Quiet: !*verbose, diff --git a/scanner.go b/scanner.go index 41ba6da..462fa78 100644 --- a/scanner.go +++ b/scanner.go @@ -62,6 +62,7 @@ type Scanner struct { // Public key of the log publicKey crypto.PublicKey + LogId []byte // Client used to talk to the CT log instance logClient *client.LogClient @@ -208,6 +209,7 @@ func (s *Scanner) GetSTH() (*ct.SignedTreeHead, error) { return nil, errors.New("STH signature is invalid: " + err.Error()) } } + copy(latestSth.LogID[:], s.LogId) return latestSth, nil } @@ -312,9 +314,10 @@ func (s *Scanner) Scan(startIndex int64, endIndex int64, processCert ProcessCall // Creates a new Scanner instance using |client| to talk to the log, and taking // configuration options from |opts|. -func NewScanner(logUri string, publicKey crypto.PublicKey, opts *ScannerOptions) *Scanner { +func NewScanner(logUri string, logId []byte, publicKey crypto.PublicKey, opts *ScannerOptions) *Scanner { var scanner Scanner scanner.LogUri = logUri + scanner.LogId = logId scanner.publicKey = publicKey scanner.logClient = client.New(logUri) scanner.opts = *opts