From d6c3ef7c243c56a4caba06dc7d6c0f55a9548408 Mon Sep 17 00:00:00 2001 From: nyagamunene Date: Fri, 22 Nov 2024 14:32:18 +0300 Subject: [PATCH] Address comments Signed-off-by: nyagamunene --- sdk/sdk.go | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/sdk/sdk.go b/sdk/sdk.go index f372366..9bf3ff3 100644 --- a/sdk/sdk.go +++ b/sdk/sdk.go @@ -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: @@ -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