Skip to content
This repository has been archived by the owner on Mar 18, 2024. It is now read-only.

WIP: Provide OCSP verification endpoint and persist certs to disk #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jameshartig
Copy link
Member

return
}
// make sure we can write to the file
if _, err := os.Stat(config.CertsFile); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of checking if the file exists, you might as well just do a Create and Chmod on it either way and save some code.

@jameshartig
Copy link
Member Author

@mediocregopher thanks! I just updated and fixed your comments. I also added /list and /revoke.

f.Close()
}

listCh = make(chan listReq)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can initialize channels in the global scope like this:

+var (
    listCh  = make(chan listReq)
    saveCh = make(chan saveReq)
    timeFmt = "2006-01-02T15:04:05"
    fileFmt = "%s | %s | %s | %s"
)

@mediocregopher
Copy link
Contributor

In main.go you have a lot of repeated code in the handlers. I think quite a bit of it could be generalized into some middleware, specifically the readAndVerifyBody and verifyTimestamp stuff.

It's a bit tricky because multiple things need to use the raw body data, I would suggest first passing all requests through a middleware which reads the body into a buffer (using an http.MaxBytesReader) and replaces the Body field on the request with that buffer, so future middleware and handlers can all use it.

@jameshartig
Copy link
Member Author

Okay so I fixed all the code comments you already made and I'll work on the middleware next week at some point.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants