Skip to content

StatusForbidden in case of no registered device #88

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions pkg/server/apiHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,29 @@ func (h *apiHandler) probe(w http.ResponseWriter, r *http.Request) {
}

func (h *apiHandler) ping(w http.ResponseWriter, r *http.Request) {
if devID := h.checkCertAndRecord(w, r); devID == nil {
cert := getClientCert(r)
u, err := h.manager.DeviceCheckCert(cert)
if err != nil {
log.Printf("error checking device cert: %v", err)
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
return
}
// now just return a 200
w.WriteHeader(http.StatusOK)
if u != nil {
h.recordClient(u, r)
w.WriteHeader(http.StatusOK)
return
}
//process onboard cert before registration
onboardCert, _, err := h.manager.OnboardGet(cert.Subject.CommonName)
if err != nil || onboardCert == nil {
//here we have no onboard/device cert
log.Printf("unknown onboard/device cert: %v", err)
http.Error(w, http.StatusText(http.StatusUnauthorized), http.StatusUnauthorized)
return
}
log.Printf("unknown device cert, known onboard cert")
http.Error(w, http.StatusText(http.StatusForbidden), http.StatusForbidden)
return
}

func (h *apiHandler) configPost(w http.ResponseWriter, r *http.Request) {
Expand Down