Skip to content

Commit a71c194

Browse files
committed
demo-ing revocation: include revoked/expired VCs in wallet.List(), always update statuslist credential
1 parent bcdb76b commit a71c194

3 files changed

Lines changed: 14 additions & 24 deletions

File tree

vcr/holder/sql_wallet.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ package holder
2020

2121
import (
2222
"context"
23-
"errors"
2423
"fmt"
2524
"time"
2625

@@ -128,13 +127,15 @@ func (h sqlWallet) List(_ context.Context, holderDID did.DID) ([]vc.VerifiableCr
128127
// now validate credentials and remove invalid ones
129128
validCredentials := make([]vc.VerifiableCredential, 0, len(credentials))
130129
for _, credential := range credentials {
130+
validCredentials = append(validCredentials, credential)
131+
// TODO: Disabled for now in project GF, because we want to actively demo with expired credentials.
131132
// we only want to check expiration and revocation status
132-
if err = h.verifier.Verify(credential, true, false, nil); err == nil {
133-
validCredentials = append(validCredentials, credential)
134-
} else if !errors.Is(err, types.ErrCredentialNotValidAtTime) && !errors.Is(err, types.ErrRevoked) {
135-
// a possible technical error has occurred that should be logged.
136-
log.Logger().WithError(err).WithField(core.LogFieldCredentialID, credential.ID).Warn("unable to verify credential")
137-
}
133+
//if err = h.verifier.Verify(credential, true, false, nil); err == nil {
134+
// validCredentials = append(validCredentials, credential)
135+
//} else if !errors.Is(err, types.ErrCredentialNotValidAtTime) && !errors.Is(err, types.ErrRevoked) {
136+
// // a possible technical error has occurred that should be logged.
137+
// log.Logger().WithError(err).WithField(core.LogFieldCredentialID, credential.ID).Warn("unable to verify credential")
138+
//}
138139
}
139140

140141
return validCredentials, nil

vcr/revocation/statuslist2021_verifier.go

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import (
2525
"io"
2626
"net/http"
2727
"strconv"
28-
"time"
2928

3029
"github.com/nuts-foundation/go-did/vc"
3130
"github.com/nuts-foundation/nuts-node/core"
@@ -102,6 +101,7 @@ func (cs *StatusList2021) Verify(credentialToVerify vc.VerifiableCredential) err
102101
func (cs *StatusList2021) statusList(statusListCredential string) (*credentialRecord, error) {
103102
cr, err := cs.loadCredential(statusListCredential)
104103
if err != nil {
104+
log.Logger().WithError(err).Warnf("Failed to load StatusList2021Credential from database, fetching from issuer (url=%s)", statusListCredential)
105105
// assume any error means we don't have the credential, so try fetching remote
106106
return cs.update(statusListCredential)
107107
}
@@ -111,23 +111,11 @@ func (cs *StatusList2021) statusList(statusListCredential string) (*credentialRe
111111
return cr, nil
112112
}
113113

114-
// TODO: renewal criteria need to be reconsidered if we add other purposes. A 'suspension' may have been canceled
115-
// renew expired certificates
116-
if (cr.Expires != nil && time.Unix(*cr.Expires, 0).Before(time.Now())) || // expired
117-
time.Unix(cr.CreatedAt, 0).Add(cs.maxAge).Before(time.Now()) { // older than 15 min
118-
crUpdated, err := cs.update(statusListCredential)
119-
if err == nil {
120-
return crUpdated, nil
121-
}
122-
// use known StatusList2021Credential if we can't fetch a new one, even if it is older/expired
123-
if cr.Expires != nil && time.Unix(*cr.Expires, 0).Before(time.Now()) {
124-
// log warning if using expired StatusList2021Credential
125-
log.Logger().WithError(err).WithField(core.LogFieldCredentialSubject, statusListCredential).
126-
Info("Validating credentialStatus using expired StatusList2021Credential")
127-
}
114+
// PROJECT-GF: for demo purposes, we always update the statuslist credentials, so we can demo revocation.
115+
crUpdated, err := cs.update(statusListCredential)
116+
if err == nil {
117+
return crUpdated, nil
128118
}
129-
130-
// return credentialRecord, which could be outdated but is the best information available.
131119
return cr, nil
132120
}
133121

vcr/revocation/statuslist2021_verifier_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ func TestStatusList2021_statusList(t *testing.T) {
132132
return *cr, cir
133133
}
134134
t.Run("ok - known credential", func(t *testing.T) {
135+
t.Skip("PROJECT-GF: for demo purposes, we always update the statuslist credentials, so we can demo revocation.")
135136
cs, entry, _ := testSetup(t, false)
136137
cs.client = nil // panics if attempts to update
137138
expectedCR, _ := makeRecords(entry.StatusListCredential)

0 commit comments

Comments
 (0)