in go/cmd/ct-fetch/ct-fetch.go [915:978]
func (el *EnrolledLogs) updateFromRemoteSettingsOnce() error {
remoteSettingsURL, err := url.Parse(*ctconfig.RemoteSettingsURL)
if err != nil {
return err
}
if remoteSettingsURL.Scheme != "https" {
glog.Warning("Changing RemoteSettingsURL scheme to https")
remoteSettingsURL.Scheme = "https"
}
ctLogConfURL, _ := remoteSettingsURL.Parse(
"buckets/security-state/collections/ct-logs/records")
httpRsp, err := httpClient.Get(ctLogConfURL.String())
if err != nil {
return err
}
body, err := ioutil.ReadAll(httpRsp.Body)
httpRsp.Body.Close()
if err != nil {
return err
}
if httpRsp.StatusCode != http.StatusOK {
return fmt.Errorf("HTTP Status %q", httpRsp.Status)
}
// The response from the remote settings server is
// { "data" : []CTLogMetadata }
var ctLogJSON map[string][]types.CTLogMetadata
if err := json.Unmarshal([]byte(body), &ctLogJSON); err != nil {
return err
}
_, exists := ctLogJSON["data"]
if !exists {
return fmt.Errorf("Malformed response from Remote Settings %s", *ctconfig.RemoteSettingsURL)
}
el.mutex.Lock()
defer el.mutex.Unlock()
for _, ctLog := range ctLogJSON["data"] {
_, prs := el.metadata[ctLog.LogID]
if prs {
if !ctLog.CRLiteEnrolled {
delete(el.metadata, ctLog.LogID)
glog.Infof("[%s] Unenrolled", ctLog.URL)
} else {
glog.Infof("[%s] Remains enrolled", ctLog.URL)
}
} else {
if ctLog.CRLiteEnrolled {
el.metadata[ctLog.LogID] = ctLog
el.NewChan <- ctLog
glog.Infof("[%s] Enrolled with LogID %s", ctLog.URL, ctLog.LogID)
}
}
}
return nil
}