Commit 8c98d0a1 authored by Heiko Reese's avatar Heiko Reese
Browse files

Better panic error messages; redirects default to G2 on unknown serial number

parent ea49101f
......@@ -85,15 +85,15 @@ func redirectHandler(w http.ResponseWriter, r *http.Request) {
func searchHandler(w http.ResponseWriter, r *http.Request) {
format := mux.Vars(r)["format"]
err := r.ParseForm()
if err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
}
query := r.Form.Get("q")
err := r.ParseForm()
if err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
}
query := r.Form.Get("q")
filter := MakeSimpleFilter(query)
results := ccache.Filter(filter)
sort.Sort(results)
w.Header().Set("cache-control", "no-store")
w.Header().Set("cache-control", "no-store")
switch format {
case "json":
w.Header().Set("Content-Type", "application/json")
......@@ -162,7 +162,7 @@ func main() {
// add search handler
r.Path("/search/v1/{format:json|html}").
Methods("GET").
Queries("q", "").
Queries("q", "").
HandlerFunc(searchHandler)
// add download handler
......
......@@ -53,11 +53,11 @@ func CertArchiveWatcher(path string, initialBatchDone chan bool) *CertCache {
// create fsnotify watcher
watcher, err := fsnotify.NewWatcher()
if err != nil {
log.Fatal(err)
log.Fatalf("Unable to create fsnotify watcher: %s", err)
}
err = watcher.Add(path)
if err != nil {
log.Fatal(err)
log.Fatalf("Unable to watch %s: %s", path, err)
}
log.Printf("Watching %s for new certificates", path)
......@@ -66,7 +66,7 @@ func CertArchiveWatcher(path string, initialBatchDone chan bool) *CertCache {
log.Println("Loading all certificates from", path)
files, err := ioutil.ReadDir(path)
if err != nil {
log.Fatal(err)
log.Fatalf("Unable to open directory %s: %s", path, err)
}
for _, file := range files {
if !file.IsDir() {
......@@ -149,11 +149,11 @@ func SymlinkStateWatcher(path string, initialBatchDone chan bool) *CertSymlinkSt
// create fsnotify watcher
watcher, err := fsnotify.NewWatcher()
if err != nil {
log.Fatal(err)
log.Fatalf("Unable to create fsnotify watcher: %s", err)
}
err = watcher.Add(path)
if err != nil {
log.Fatal(err)
log.Fatalf("Unable to watch %s: %s", path, err)
}
log.Printf("Watching %s for symlink changes", path)
......@@ -161,7 +161,7 @@ func SymlinkStateWatcher(path string, initialBatchDone chan bool) *CertSymlinkSt
go func() {
files, err := ioutil.ReadDir(path)
if err != nil {
log.Fatal(err)
log.Fatalf("Unable to open directory %s: %s", path, err)
}
//pp.Print(files)
for _, file := range files {
......
......@@ -43,8 +43,8 @@ func GetIssuer(serial string, ccache *CertCache) (string, error) {
// check certificate cache
fromcache := ccache.Get(serial)
if fromcache == nil {
// don't know? assume G2
return kitcag2, nil
// don't know? assume G2
return kitcag2, nil
//return "", errorUnknownCA
}
return *fromcache.CAGeneration, nil
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment