Skip to content
This repository was archived by the owner on Jan 10, 2020. It is now read-only.
This repository was archived by the owner on Jan 10, 2020. It is now read-only.

Misc error checking issues with certificate handling in edgexproxy #74

Description

@anonymouse64
  1. There is no error checking of the response code from vault. If there's an issue with accessing the certs from vault, there will be a non-200 response code and so before unmarshalling the body of the response we should be checking the response code. That would be done right after this bit of code:

req, err := s.New().Base(secretBaseURL).Get(config.SecretService.CertPath).Request()
resp, err := c.Do(req)
if err != nil {
errStr := fmt.Sprintf("Failed to retrieve certificate with path as %s with error %s", config.SecretService.CertPath, err.Error())
return "", "", errors.New(errStr)
}
defer resp.Body.Close()

  1. The error returned from Decode should be checked here and returned if non-nil:

json.NewDecoder(resp.Body).Decode(&collection)

  1. The decoded JSON should be checked to see if the certificate and the key are non-empty as they could be empty from vault, or vault could have returned some other kind of JSON object in which case the decoding would have succeeded but resulted in an empty object. That kind of check should happen just after we decode the JSON object here:

json.NewDecoder(resp.Body).Decode(&collection)

  1. The logger info should not be logging the cert at level Info, I think it should be a debug output, and there should be some labeling of what is being output here:

lc.Info(collection.Section.Cert)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions