Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

NOISSUE - Fix ocsp with sdk #52

Merged
merged 3 commits into from
Nov 22, 2024
Merged

Conversation

nyagamunene
Copy link
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 <[email protected]>
Signed-off-by: nyagamunene <[email protected]>
@nyagamunene nyagamunene marked this pull request as ready for review November 19, 2024 17:54
SammyOina
SammyOina previously approved these changes Nov 20, 2024
sdk/sdk.go Outdated
type CertStatus int

const (
Good CertStatus = iota
Copy link
Contributor

Choose a reason for hiding this comment

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

Rename to Valid.

sdk/sdk.go Outdated
)

const (
good = "Good"
Copy link
Contributor

Choose a reason for hiding this comment

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

Same.

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
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 <[email protected]>
@dborovcanin dborovcanin merged commit 2a4de1e into absmach:main Nov 22, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants