Skip to content
This repository was archived by the owner on Apr 6, 2026. It is now read-only.

NOISSUE - Fix ocsp with sdk#52

Merged
dborovcanin merged 3 commits into
absmach:mainfrom
nyagamunene:fix-sdk-ocsp
Nov 22, 2024
Merged

NOISSUE - Fix ocsp with sdk#52
dborovcanin merged 3 commits into
absmach:mainfrom
nyagamunene:fix-sdk-ocsp

Conversation

@nyagamunene

Copy link
Copy Markdown
Contributor

What type of PR is this?

This is a bug fix because it fixes the following issue: it changes how the OCSP request is created and presented while using the SDK.

What does this do?

it changes how the OCSP request is created and presented while using the SDK.

Which issue(s) does this PR fix/relate to?

N/A

Have you included tests for your changes?

No

Did you document any new/modified features?

No

Notes

Signed-off-by: nyagamunene <stevenyaga2014@gmail.com>
Signed-off-by: nyagamunene <stevenyaga2014@gmail.com>
@nyagamunene nyagamunene marked this pull request as ready for review November 19, 2024 17:54
SammyOina
SammyOina previously approved these changes Nov 20, 2024
Comment thread sdk/sdk.go Outdated
type CertStatus int

const (
Good CertStatus = iota

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Rename to Valid.

Comment thread sdk/sdk.go Outdated
)

const (
good = "Good"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same.

Comment thread sdk/sdk.go Outdated
Comment on lines +409 to +431

var ocspResp *ocsp.Response

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

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
var ocspResp *ocsp.Response
if len(body) != emptyOCSPbody {
ocspResp, err = ocsp.ParseResponse(body, nil)
if err != nil {
return OCSPResponse{}, errors.NewSDKError(err)
}
} else {
return OCSPResponse{
Status: CertStatus(Unknown),
SerialNumber: sn,
Certificate: nil,
}, nil
}
resp := OCSPResponse{
Status: CertStatus(ocspResp.Status),
SerialNumber: ocspResp.SerialNumber,
Certificate: ocspResp.Certificate.Raw,
RevokedAt: &ocspResp.RevokedAt,
IssuerHash: ocspResp.IssuerHash.String(),
ProducedAt: &ocspResp.ProducedAt,
if len(body) == emptyOCSPbody {
return OCSPResponse{
Status: CertStatus(Unknown),
SerialNumber: sn,
}, nil
}
r, err := ocsp.ParseResponse(body, nil)
if err != nil {
return OCSPResponse{}, errors.NewSDKError(err)
}
resp := OCSPResponse{
Status: CertStatus(r.Status),
SerialNumber: r.SerialNumber,
Certificate: r.Certificate.Raw,
RevokedAt: &r.RevokedAt,
IssuerHash: r.IssuerHash.String(),
ProducedAt: &r.ProducedAt,
}
return resp, nil

Signed-off-by: nyagamunene <stevenyaga2014@gmail.com>
@dborovcanin dborovcanin merged commit 2a4de1e into absmach:main Nov 22, 2024
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.

3 participants