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

feat: Timestamp #207

Merged
merged 86 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from 69 commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
582a011
tsa
Two-Hearts Nov 30, 2023
8d92e01
test
Two-Hearts Nov 30, 2023
ac03000
test
Two-Hearts Dec 1, 2023
05b0463
fix hash
Two-Hearts Dec 4, 2023
212930a
Merge branch 'notaryproject:main' into tsa
Two-Hearts Dec 13, 2023
f859d84
Merge branch 'notaryproject:main' into tsa
Two-Hearts Dec 26, 2023
f39811a
Merge branch 'notaryproject:main' into tsa
Two-Hearts Dec 28, 2023
8cfd74d
initial commit
Two-Hearts Jan 9, 2024
034e4cd
cose
Two-Hearts Jan 9, 2024
84661c3
Merge branch 'notaryproject:main' into tsa
Two-Hearts Jan 15, 2024
01e4268
initial commits
Two-Hearts Jan 15, 2024
d0a39ce
Merge branch 'notaryproject:main' into tsa
Two-Hearts Jan 19, 2024
8ad3eab
refactored to use tspclient-go
Two-Hearts Jan 23, 2024
3e76750
update tspclient-go
Two-Hearts Jan 31, 2024
5fc45dc
test
Two-Hearts Feb 1, 2024
182af1a
update
Two-Hearts Feb 1, 2024
e780d70
resolve conflicts
Two-Hearts Mar 18, 2024
8a4cd55
update
Two-Hearts Mar 22, 2024
f75c250
Merge branch 'notaryproject:main' into tsa
Two-Hearts Mar 22, 2024
65fe878
fix bug
Two-Hearts Mar 22, 2024
bad5a7f
update
Two-Hearts Mar 22, 2024
3bbfdbb
fix bug
Two-Hearts Mar 22, 2024
bf4ea64
update sign
Two-Hearts Mar 22, 2024
e653780
fix JWS timestamp
Two-Hearts Mar 22, 2024
fecb8d8
Merge branch 'notaryproject:main' into tsa
Two-Hearts Mar 27, 2024
e085696
updated tspclient-go
Two-Hearts Mar 27, 2024
2338257
updated tsa cert validation
Two-Hearts Apr 8, 2024
952d151
added tsa request nonce support
Two-Hearts Apr 8, 2024
db08071
fix typo
Two-Hearts Apr 8, 2024
7654060
fix OCSP
Two-Hearts Apr 8, 2024
4f5a246
updated tsa with ocsp
Two-Hearts Apr 8, 2024
8c59a12
fix OCSP
Two-Hearts Apr 8, 2024
cbde6f9
update timestamping
Two-Hearts Apr 8, 2024
59a472a
Merge branch 'notaryproject:main' into tsa
Two-Hearts Apr 10, 2024
29bc773
update
Two-Hearts Apr 10, 2024
44995cc
added check signing time
Two-Hearts Apr 11, 2024
7b26dab
tsa cert validation
Two-Hearts Apr 15, 2024
5f03064
fix test
Two-Hearts Apr 15, 2024
f78e16e
fix test
Two-Hearts Apr 15, 2024
679399a
fix test
Two-Hearts Apr 15, 2024
14d0551
resolved conflicts
Two-Hearts Apr 18, 2024
5f7a175
added tests
Two-Hearts Apr 19, 2024
04390e2
Merge branch 'notaryproject:main' into tsa
Two-Hearts Apr 19, 2024
80b57f0
added tests
Two-Hearts Apr 25, 2024
f67e52b
add more tests
Two-Hearts Apr 26, 2024
c5f93ec
updated tspclient-go
Two-Hearts May 8, 2024
fc1cb3d
Merge branch 'notaryproject:main' into tsa
Two-Hearts May 8, 2024
bf89fbf
updated tspclient-go
Two-Hearts May 10, 2024
3b51449
Merge branch 'notaryproject:main' into tsa
Two-Hearts Jun 4, 2024
619f7fe
updated tspclient-go
Two-Hearts Jun 4, 2024
99b5190
fix tests
Two-Hearts Jun 4, 2024
0089871
validate tsa cert chain after signing
Two-Hearts Jun 11, 2024
29d77ea
fix tests
Two-Hearts Jun 11, 2024
9e9ee89
update
Two-Hearts Jun 11, 2024
02dce64
fix test
Two-Hearts Jun 11, 2024
f309851
update
Two-Hearts Jun 14, 2024
43b2412
updated tspclient-go
Two-Hearts Jun 18, 2024
066645f
clean up
Two-Hearts Jun 20, 2024
9bbc44d
added more tests
Two-Hearts Jun 20, 2024
66dbd61
added more tests
Two-Hearts Jun 20, 2024
a57701f
fix tests
Two-Hearts Jun 20, 2024
817296a
update
Two-Hearts Jun 20, 2024
b2551ef
tsa root cert pool
Two-Hearts Jun 21, 2024
7211f7a
tsa root cert pool
Two-Hearts Jun 21, 2024
e751e91
updated timestamp
Two-Hearts Jun 21, 2024
4eb5f5f
updated root cert pool
Two-Hearts Jun 24, 2024
28b8054
updated root cert pool
Two-Hearts Jun 24, 2024
64bf87a
clean up
Two-Hearts Jun 25, 2024
a24facd
updated tspclient-go
Two-Hearts Jun 27, 2024
81332af
Merge branch 'notaryproject:main' into tsa
Two-Hearts Jun 28, 2024
d7680b1
updated tspclient-go
Two-Hearts Jun 28, 2024
4470a8e
Merge branch 'notaryproject:main' into tsa
Two-Hearts Jun 28, 2024
7ee9155
updated per code review
Two-Hearts Jun 28, 2024
44714e2
update
Two-Hearts Jun 28, 2024
906d41a
update
Two-Hearts Jun 28, 2024
de8a46c
update
Two-Hearts Jun 28, 2024
c3a9244
clean up
Two-Hearts Jul 1, 2024
42d5b83
updated per code review
Two-Hearts Jul 1, 2024
4cb711b
added tests
Two-Hearts Jul 1, 2024
89251f1
update
Two-Hearts Jul 1, 2024
66dd339
updated tspclient-go
Two-Hearts Jul 2, 2024
8c1e9cd
updated tspclient-go
Two-Hearts Jul 2, 2024
a810785
update
Two-Hearts Jul 2, 2024
0830984
clean up
Two-Hearts Jul 2, 2024
46cda71
update
Two-Hearts Jul 3, 2024
7f0c505
Merge branch 'notaryproject:main' into tsa
Two-Hearts Jul 3, 2024
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
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ go 1.21
require (
github.com/fxamacker/cbor/v2 v2.6.0
github.com/golang-jwt/jwt/v4 v4.5.0
github.com/notaryproject/tspclient-go v0.0.0-20240627050441-dcff9b7c23fe
github.com/veraison/go-cose v1.1.0
golang.org/x/crypto v0.23.0
)
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ github.com/fxamacker/cbor/v2 v2.6.0 h1:sU6J2usfADwWlYDAFhZBQ6TnLFBHxgesMrQfQgk1t
github.com/fxamacker/cbor/v2 v2.6.0/go.mod h1:pxXPTn3joSm21Gbwsv0w9OSA2y1HFR9qXEeXQVeNoDQ=
github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg=
github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
github.com/notaryproject/tspclient-go v0.0.0-20240627050441-dcff9b7c23fe h1:1psX5fHzB0ZGshHkaGlERh0eBX4EapizcVyQwX+YydE=
github.com/notaryproject/tspclient-go v0.0.0-20240627050441-dcff9b7c23fe/go.mod h1:LGyA/6Kwd2FlM0uk8Vc5il3j0CddbWSHBj/4kxQDbjs=
github.com/veraison/go-cose v1.1.0 h1:AalPS4VGiKavpAzIlBjrn7bhqXiXi4jbMYY/2+UC+4o=
github.com/veraison/go-cose v1.1.0/go.mod h1:7ziE85vSq4ScFTg6wyoMXjucIGOf4JkFEZi/an96Ct4=
github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
Expand Down
31 changes: 31 additions & 0 deletions internal/oid.go
Two-Hearts marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright The Notary Project Authors.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package oid

import "encoding/asn1"

// KeyUsage (id-ce-keyUsage) is defined in RFC 5280
//
// Reference: https://www.rfc-editor.org/rfc/rfc5280.html#section-4.2.1.3
var KeyUsage = asn1.ObjectIdentifier{2, 5, 29, 15}

// ExtKeyUsage (id-ce-extKeyUsage) is defined in RFC 5280
//
// Reference: https://www.rfc-editor.org/rfc/rfc5280.html#section-4.2.1.12
var ExtKeyUsage = asn1.ObjectIdentifier{2, 5, 29, 37}

// TimeStamping (id-kp-timeStamping) is defined in RFC 3161 2.3
//
// Reference: https://datatracker.ietf.org/doc/html/rfc3161#section-2.3
var TimeStamping = asn1.ObjectIdentifier{1, 3, 6, 1, 5, 5, 7, 3, 8}
11 changes: 9 additions & 2 deletions revocation/ocsp/ocsp.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import (
// Options specifies values that are needed to check OCSP revocation
type Options struct {
CertChain []*x509.Certificate
Timestamp bool // when set to true, check revocation of a timestamp certificate chain
Two-Hearts marked this conversation as resolved.
Show resolved Hide resolved
SigningTime time.Time
HTTPClient *http.Client
}
Expand All @@ -64,8 +65,14 @@ func CheckStatus(opts Options) ([]*result.CertRevocationResult, error) {
// Since this is using authentic signing time, signing time may be zero.
// Thus, it is better to pass nil here than fail for a cert's NotBefore
// being after zero time
if err := coreX509.ValidateCodeSigningCertChain(opts.CertChain, nil); err != nil {
return nil, result.InvalidChainError{Err: err}
if opts.Timestamp {
if err := coreX509.ValidateTimeStampingCertChain(opts.CertChain, nil); err != nil {
Two-Hearts marked this conversation as resolved.
Show resolved Hide resolved
return nil, result.InvalidChainError{Err: err}
}
} else {
if err := coreX509.ValidateCodeSigningCertChain(opts.CertChain, nil); err != nil {
return nil, result.InvalidChainError{Err: err}
}
}

certResults := make([]*result.CertRevocationResult, len(opts.CertChain))
Expand Down
17 changes: 17 additions & 0 deletions revocation/ocsp/ocsp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,7 @@ func TestCheckStatusErrors(t *testing.T) {
noHTTPLeaf.OCSPServer = []string{"ldap://ds.example.com:123/chain_ocsp/0"}
noHTTPChain := []*x509.Certificate{noHTTPLeaf, revokableTuples[1].Cert, revokableTuples[2].Cert}

timestampSigningCertErr := result.InvalidChainError{Err: errors.New("timestamp signing certificate with subject \"CN=Notation Test Revokable RSA Chain Cert 3,O=Notary,L=Seattle,ST=WA,C=US\" must have and only have TimeStamping as extended key usage")}
backwardsChainErr := result.InvalidChainError{Err: errors.New("leaf certificate with subject \"CN=Notation Test Revokable RSA Chain Cert Root,O=Notary,L=Seattle,ST=WA,C=US\" is self-signed. Certificate chain must not contain self-signed leaf certificate")}
chainRootErr := result.InvalidChainError{Err: errors.New("root certificate with subject \"CN=Notation Test Revokable RSA Chain Cert 2,O=Notary,L=Seattle,ST=WA,C=US\" is not self-signed. Certificate chain must end with a valid self-signed root certificate")}
expiredRespErr := GenericError{Err: errors.New("expired OCSP response")}
Expand Down Expand Up @@ -531,6 +532,22 @@ func TestCheckStatusErrors(t *testing.T) {
}
})

t.Run("check codesigning cert with timestamp set to true", func(t *testing.T) {
opts := Options{
CertChain: okChain,
Timestamp: true,
SigningTime: time.Now(),
HTTPClient: http.DefaultClient,
}
certResults, err := CheckStatus(opts)
if err == nil || err.Error() != timestampSigningCertErr.Error() {
t.Errorf("Expected CheckStatus to fail with %v, but got: %v", timestampSigningCertErr, err)
}
if certResults != nil {
t.Error("Expected certResults to be nil when there is an error")
}
})

t.Run("timeout", func(t *testing.T) {
timeoutClient := &http.Client{Timeout: 1 * time.Nanosecond}
opts := Options{
Expand Down
17 changes: 17 additions & 0 deletions revocation/revocation.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,20 @@ func (r *revocation) Validate(certChain []*x509.Certificate, signingTime time.Ti
// TODO: add CRL support
// https://github.com/notaryproject/notation-core-go/issues/125
}

// ValidateTimestampCertChain checks the revocation status for a TSA certificate
// chain using OCSP and returns an array of CertRevocationResults that contain
// the results and any errors that are encountered during the process
//
// TODO: add CRL support
// https://github.com/notaryproject/notation-core-go/issues/125
func ValidateTimestampCertChain(certChain []*x509.Certificate, signingTime time.Time, httpClient *http.Client) ([]*result.CertRevocationResult, error) {
return ocsp.CheckStatus(ocsp.Options{
CertChain: certChain,
Timestamp: true,
SigningTime: signingTime,
HTTPClient: httpClient,
})
// TODO: add CRL support
// https://github.com/notaryproject/notation-core-go/issues/125
}
Two-Hearts marked this conversation as resolved.
Show resolved Hide resolved
197 changes: 197 additions & 0 deletions revocation/revocation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,203 @@ func TestCheckRevocationStatusForChain(t *testing.T) {
})
}

func TestCheckRevocationStatusForTimestampChain(t *testing.T) {
zeroTime := time.Time{}
testChain := testhelper.GetRevokableRSATimestampChain(6)
revokableChain := make([]*x509.Certificate, 6)
for i, tuple := range testChain {
revokableChain[i] = tuple.Cert
revokableChain[i].NotBefore = zeroTime
}

t.Run("empty chain", func(t *testing.T) {
certResults, err := ValidateTimestampCertChain([]*x509.Certificate{}, time.Now(), &http.Client{Timeout: 5 * time.Second})
expectedErr := result.InvalidChainError{Err: errors.New("chain does not contain any certificates")}
if err == nil || err.Error() != expectedErr.Error() {
t.Errorf("Expected CheckStatus to fail with %v, but got: %v", expectedErr, err)
}
if certResults != nil {
t.Error("Expected certResults to be nil when there is an error")
}
})
t.Run("check non-revoked chain", func(t *testing.T) {
client := testhelper.MockClient(testChain, []ocsp.ResponseStatus{ocsp.Good}, nil, true)
certResults, err := ValidateTimestampCertChain(revokableChain, time.Now(), client)
if err != nil {
t.Errorf("Expected CheckStatus to succeed, but got error: %v", err)
}
expectedCertResults := []*result.CertRevocationResult{
getOKCertResult(revokableChain[0].OCSPServer[0]),
getOKCertResult(revokableChain[1].OCSPServer[0]),
getOKCertResult(revokableChain[2].OCSPServer[0]),
getOKCertResult(revokableChain[3].OCSPServer[0]),
getOKCertResult(revokableChain[4].OCSPServer[0]),
getRootCertResult(),
}
validateEquivalentCertResults(certResults, expectedCertResults, t)
})
t.Run("check chain with 1 Unknown cert", func(t *testing.T) {
// 3rd cert will be unknown, the rest will be good
client := testhelper.MockClient(testChain, []ocsp.ResponseStatus{ocsp.Good, ocsp.Good, ocsp.Unknown, ocsp.Good}, nil, true)
certResults, err := ValidateTimestampCertChain(revokableChain, time.Now(), client)
if err != nil {
t.Errorf("Expected CheckStatus to succeed, but got error: %v", err)
}
expectedCertResults := []*result.CertRevocationResult{
getOKCertResult(revokableChain[0].OCSPServer[0]),
getOKCertResult(revokableChain[1].OCSPServer[0]),
{
Result: result.ResultUnknown,
ServerResults: []*result.ServerResult{
result.NewServerResult(result.ResultUnknown, revokableChain[2].OCSPServer[0], revocationocsp.UnknownStatusError{}),
},
},
getOKCertResult(revokableChain[3].OCSPServer[0]),
getOKCertResult(revokableChain[4].OCSPServer[0]),
getRootCertResult(),
}
validateEquivalentCertResults(certResults, expectedCertResults, t)
})
t.Run("check OCSP with 1 revoked cert", func(t *testing.T) {
// 3rd cert will be revoked, the rest will be good
client := testhelper.MockClient(testChain, []ocsp.ResponseStatus{ocsp.Good, ocsp.Good, ocsp.Revoked, ocsp.Good}, nil, true)
certResults, err := ValidateTimestampCertChain(revokableChain, time.Now(), client)
if err != nil {
t.Errorf("Expected CheckStatus to succeed, but got error: %v", err)
}
expectedCertResults := []*result.CertRevocationResult{
getOKCertResult(revokableChain[0].OCSPServer[0]),
getOKCertResult(revokableChain[1].OCSPServer[0]),
{
Result: result.ResultRevoked,
ServerResults: []*result.ServerResult{
result.NewServerResult(result.ResultRevoked, revokableChain[2].OCSPServer[0], revocationocsp.RevokedError{}),
},
},
getOKCertResult(revokableChain[3].OCSPServer[0]),
getOKCertResult(revokableChain[4].OCSPServer[0]),
getRootCertResult(),
}
validateEquivalentCertResults(certResults, expectedCertResults, t)
})
t.Run("check OCSP with 1 unknown and 1 revoked cert", func(t *testing.T) {
// 3rd cert will be unknown, 5th will be revoked, the rest will be good
client := testhelper.MockClient(testChain, []ocsp.ResponseStatus{ocsp.Good, ocsp.Good, ocsp.Unknown, ocsp.Good, ocsp.Revoked, ocsp.Good}, nil, true)
certResults, err := ValidateTimestampCertChain(revokableChain, time.Now(), client)
if err != nil {
t.Errorf("Expected CheckStatus to succeed, but got error: %v", err)
}
expectedCertResults := []*result.CertRevocationResult{
getOKCertResult(revokableChain[0].OCSPServer[0]),
getOKCertResult(revokableChain[1].OCSPServer[0]),
{
Result: result.ResultUnknown,
ServerResults: []*result.ServerResult{
result.NewServerResult(result.ResultUnknown, revokableChain[2].OCSPServer[0], revocationocsp.UnknownStatusError{}),
},
},
getOKCertResult(revokableChain[3].OCSPServer[0]),
{
Result: result.ResultRevoked,
ServerResults: []*result.ServerResult{
result.NewServerResult(result.ResultRevoked, revokableChain[4].OCSPServer[0], revocationocsp.RevokedError{}),
},
},
getRootCertResult(),
}
validateEquivalentCertResults(certResults, expectedCertResults, t)
})
t.Run("check OCSP with 1 future revoked cert", func(t *testing.T) {
revokedTime := time.Now().Add(time.Hour)
// 3rd cert will be future revoked, the rest will be good
client := testhelper.MockClient(testChain, []ocsp.ResponseStatus{ocsp.Good, ocsp.Good, ocsp.Revoked, ocsp.Good}, &revokedTime, true)
certResults, err := ValidateTimestampCertChain(revokableChain, time.Now(), client)
if err != nil {
t.Errorf("Expected CheckStatus to succeed, but got error: %v", err)
}
expectedCertResults := []*result.CertRevocationResult{
getOKCertResult(revokableChain[0].OCSPServer[0]),
getOKCertResult(revokableChain[1].OCSPServer[0]),
getOKCertResult(revokableChain[2].OCSPServer[0]),
getOKCertResult(revokableChain[3].OCSPServer[0]),
getOKCertResult(revokableChain[4].OCSPServer[0]),
getRootCertResult(),
}
validateEquivalentCertResults(certResults, expectedCertResults, t)
})
t.Run("check OCSP with 1 unknown and 1 future revoked cert", func(t *testing.T) {
revokedTime := time.Now().Add(time.Hour)
// 3rd cert will be unknown, 5th will be future revoked, the rest will be good
client := testhelper.MockClient(testChain, []ocsp.ResponseStatus{ocsp.Good, ocsp.Good, ocsp.Unknown, ocsp.Good, ocsp.Revoked, ocsp.Good}, &revokedTime, true)
certResults, err := ValidateTimestampCertChain(revokableChain, time.Now(), client)
if err != nil {
t.Errorf("Expected CheckStatus to succeed, but got error: %v", err)
}
expectedCertResults := []*result.CertRevocationResult{
getOKCertResult(revokableChain[0].OCSPServer[0]),
getOKCertResult(revokableChain[1].OCSPServer[0]),
{
Result: result.ResultUnknown,
ServerResults: []*result.ServerResult{
result.NewServerResult(result.ResultUnknown, revokableChain[2].OCSPServer[0], revocationocsp.UnknownStatusError{}),
},
},
getOKCertResult(revokableChain[3].OCSPServer[0]),
getOKCertResult(revokableChain[4].OCSPServer[0]),
getRootCertResult(),
}
validateEquivalentCertResults(certResults, expectedCertResults, t)
})
t.Run("check OCSP with 1 revoked cert before signing time", func(t *testing.T) {
// 3rd cert will be revoked, the rest will be good
client := testhelper.MockClient(testChain, []ocsp.ResponseStatus{ocsp.Good, ocsp.Good, ocsp.Revoked, ocsp.Good}, nil, true)
certResults, err := ValidateTimestampCertChain(revokableChain, time.Now().Add(time.Hour), client)
if err != nil {
t.Errorf("Expected CheckStatus to succeed, but got error: %v", err)
}
expectedCertResults := []*result.CertRevocationResult{
getOKCertResult(revokableChain[0].OCSPServer[0]),
getOKCertResult(revokableChain[1].OCSPServer[0]),
{
Result: result.ResultRevoked,
ServerResults: []*result.ServerResult{
result.NewServerResult(result.ResultRevoked, revokableChain[2].OCSPServer[0], revocationocsp.RevokedError{}),
},
},
getOKCertResult(revokableChain[3].OCSPServer[0]),
getOKCertResult(revokableChain[4].OCSPServer[0]),
getRootCertResult(),
}
validateEquivalentCertResults(certResults, expectedCertResults, t)
})
t.Run("check OCSP with 1 revoked cert after zero signing time", func(t *testing.T) {
revokedTime := time.Now().Add(time.Hour)
// 3rd cert will be revoked, the rest will be good
client := testhelper.MockClient(testChain, []ocsp.ResponseStatus{ocsp.Good, ocsp.Good, ocsp.Revoked, ocsp.Good}, &revokedTime, true)
if !zeroTime.IsZero() {
t.Errorf("exected zeroTime.IsZero() to be true")
}
certResults, err := ValidateTimestampCertChain(revokableChain, time.Now().Add(time.Hour), client)
if err != nil {
t.Errorf("Expected CheckStatus to succeed, but got error: %v", err)
}
expectedCertResults := []*result.CertRevocationResult{
getOKCertResult(revokableChain[0].OCSPServer[0]),
getOKCertResult(revokableChain[1].OCSPServer[0]),
{
Result: result.ResultRevoked,
ServerResults: []*result.ServerResult{
result.NewServerResult(result.ResultRevoked, revokableChain[2].OCSPServer[0], revocationocsp.RevokedError{}),
},
},
getOKCertResult(revokableChain[3].OCSPServer[0]),
getOKCertResult(revokableChain[4].OCSPServer[0]),
getRootCertResult(),
}
validateEquivalentCertResults(certResults, expectedCertResults, t)
})
}

func TestCheckRevocationErrors(t *testing.T) {
leafCertTuple := testhelper.GetRSALeafCertificate()
rootCertTuple := testhelper.GetRSARootCertificate()
Expand Down
6 changes: 3 additions & 3 deletions signature/cose/conformance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func TestConformance(t *testing.T) {

// testSign does conformance check on COSE_Sign1_Tagged
func testSign(t *testing.T, sign1 *sign1) {
signRequest, err := getSignReq(sign1)
signRequest, err := getSignReq()
if err != nil {
t.Fatalf("getSignReq() failed. Error = %s", err)
}
Expand Down Expand Up @@ -90,7 +90,7 @@ func testSign(t *testing.T, sign1 *sign1) {
// testVerify does conformance check by decoding COSE_Sign1_Tagged object
// into Sign1Message
func testVerify(t *testing.T, sign1 *sign1) {
signRequest, err := getSignReq(sign1)
signRequest, err := getSignReq()
if err != nil {
t.Fatalf("getSignReq() failed. Error = %s", err)
}
Expand Down Expand Up @@ -124,7 +124,7 @@ func testVerify(t *testing.T, sign1 *sign1) {
verifySignerInfo(&content.SignerInfo, signRequest, t)
}

func getSignReq(sign1 *sign1) (*signature.SignRequest, error) {
func getSignReq() (*signature.SignRequest, error) {
certs := []*x509.Certificate{testhelper.GetRSALeafCertificate().Cert, testhelper.GetRSARootCertificate().Cert}
signer, err := signature.NewLocalSigner(certs, testhelper.GetRSALeafCertificate().PrivateKey)
if err != nil {
Expand Down
Loading
Loading