func LoadExceptions()

in entryMaker/util/exceptions.go [36:75]


func LoadExceptions(location string, existing *oneCRL.Records, records *oneCRL.Records) error {
	res := new(oneCRL.Records)
	var data []byte

	if 0 != strings.Index(strings.ToUpper(location), "HTTP") {
		// if it's not an HTTP URL, attempt to load from a file
		if fileData, err := ioutil.ReadFile(location); nil != err {
			fmt.Printf("problem loading oneCRL exceptions from file %s\n", err)
		} else {
			data = fileData
		}
	} else {
		// ensure it's not an HTTP location
		if 0 != strings.Index(strings.ToUpper(location), "HTTPS") {
			return errors.New("Cowardly refusing to load exceptions from a non HTTPS location")
		}
		if resp, err := http.Get(location); nil != err {
			return err
		} else {
			defer resp.Body.Close()
			if urlData, err := ioutil.ReadAll(resp.Body); nil != err {
				return err
			} else {
				data = urlData
			}
		}
	}

	if err := json.Unmarshal(data, res); nil != err {
		return err
	}

	for idx := range res.Data {
		record := res.Data[idx]
		if !RecordExists(record, existing) {
			records.Data = append(records.Data, record)
		}
	}
	return nil
}