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

refactor!: update revocation #215

Merged
merged 25 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 3 additions & 15 deletions revocation/ocsp/ocsp.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,10 @@ import (
"golang.org/x/crypto/ocsp"
)

// Purpose is an enum for purpose of the certificate chain whose OCSP status
// is checked
type Purpose int

const (
// PurposeCodeSigning means the certificate chain is a code signing chain
PurposeCodeSigning Purpose = iota

// PurposeTimestamping means the certificate chain is a timestamping chain
PurposeTimestamping
)

// Options specifies values that are needed to check OCSP revocation
type Options struct {
CertChain []*x509.Certificate
CertChainPurpose Purpose // default value is `PurposeCodeSigning`
CertChainPurpose x509.ExtKeyUsage
Two-Hearts marked this conversation as resolved.
Show resolved Hide resolved
SigningTime time.Time
HTTPClient *http.Client
}
Expand All @@ -78,11 +66,11 @@ func CheckStatus(opts Options) ([]*result.CertRevocationResult, error) {
// Thus, it is better to pass nil here than fail for a cert's NotBefore
// being after zero time
switch opts.CertChainPurpose {
case PurposeCodeSigning:
case x509.ExtKeyUsageCodeSigning:
if err := coreX509.ValidateCodeSigningCertChain(opts.CertChain, nil); err != nil {
return nil, result.InvalidChainError{Err: err}
}
case PurposeTimestamping:
case x509.ExtKeyUsageTimeStamping:
if err := coreX509.ValidateTimestampingCertChain(opts.CertChain); err != nil {
return nil, result.InvalidChainError{Err: err}
}
Expand Down
Loading
Loading