Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
Signed-off-by: nyagamunene <[email protected]>
  • Loading branch information
nyagamunene committed Nov 22, 2024
1 parent 7ae3ca7 commit d6c3ef7
Showing 1 changed file with 15 additions and 19 deletions.
34 changes: 15 additions & 19 deletions sdk/sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,21 @@ type ContentType string
type CertStatus int

const (
Good CertStatus = iota
Valid CertStatus = iota
Revoked
Unknown
)

const (
good = "Good"
valid = "Valid"
revoked = "Revoked"
unknown = "Unknown"
)

func (c CertStatus) String() string {
switch c {
case Good:
return good
case Valid:
return valid
case Revoked:
return revoked
default:
Expand Down Expand Up @@ -407,28 +407,24 @@ func (sdk mgSDK) OCSP(serialNumber, cert string) (OCSPResponse, errors.SDKError)
return OCSPResponse{}, sdkerr
}

var ocspResp *ocsp.Response

if len(body) != emptyOCSPbody {
ocspResp, err = ocsp.ParseResponse(body, nil)
if err != nil {
return OCSPResponse{}, errors.NewSDKError(err)
}
} else {
if len(body) == emptyOCSPbody {
return OCSPResponse{
Status: CertStatus(Unknown),
SerialNumber: sn,
Certificate: nil,
}, nil
}
res, err := ocsp.ParseResponse(body, nil)
if err != nil {
return OCSPResponse{}, errors.NewSDKError(err)
}

resp := OCSPResponse{
Status: CertStatus(ocspResp.Status),
SerialNumber: ocspResp.SerialNumber,
Certificate: ocspResp.Certificate.Raw,
RevokedAt: &ocspResp.RevokedAt,
IssuerHash: ocspResp.IssuerHash.String(),
ProducedAt: &ocspResp.ProducedAt,
Status: CertStatus(res.Status),
SerialNumber: res.SerialNumber,
Certificate: res.Certificate.Raw,
RevokedAt: &res.RevokedAt,
IssuerHash: res.IssuerHash.String(),
ProducedAt: &res.ProducedAt,
}

return resp, nil
Expand Down

0 comments on commit d6c3ef7

Please sign in to comment.