Commit 2921f80b authored by Sietse Ringers's avatar Sietse Ringers

feat: update revocation db from remote

parent d26dd7a1
......@@ -243,10 +243,8 @@ func (s *Server) handlePostRevocationRecords(
if err != nil {
return nil, server.RemoteError(server.ErrorUnknown, err.Error()) // TODO error type
}
for _, r := range records {
if err = db.Add(r.Message, r.PublicKeyIndex); err != nil {
return nil, server.RemoteError(server.ErrorUnknown, err.Error()) // TODO error type
}
if err = db.AddRecords(records); err != nil {
return nil, server.RemoteError(server.ErrorUnknown, err.Error()) // TODO error type
}
return nil, nil
}
......
......@@ -109,7 +109,7 @@ func (s *Server) validateIssuanceRequest(request *irma.IssuanceRequest) error {
if len(cred.RevocationKey) == 0 {
return errors.New("revocationKey field unset on revocable credential")
}
if exists, err := db.KeyExists([]byte(cred.RevocationKey)); err != nil {
if exists, err := db.IssuanceRecordExists([]byte(cred.RevocationKey)); err != nil {
return err
} else if exists {
return errors.New("revocationKey already used")
......
......@@ -571,7 +571,32 @@ func (ks *issuerKeystore) PublicKey(counter uint) (*revocation.PublicKey, error)
return rpk, nil
}
func (conf *Configuration) RevocationUpdates(credid CredentialTypeIdentifier, index uint64) ([]*revocation.Record, error) {
var records []*revocation.Record
err := NewHTTPTransport(conf.CredentialTypes[credid].RevocationServer).
Get(fmt.Sprintf("/-/revocation/records/%s/%d", credid, index), &records)
if err != nil {
return nil, err
}
return records, nil
}
func (conf *Configuration) RevocationUpdateDB(credid CredentialTypeIdentifier) error {
db, err := conf.RevocationDB(credid)
if err != nil {
return err
}
records, err := conf.RevocationUpdates(credid, db.Current.Index+1)
if err != nil {
return err
}
return db.AddRecords(records)
}
func (conf *Configuration) RevocationDB(credid CredentialTypeIdentifier) (*revocation.DB, error) {
if _, known := conf.CredentialTypes[credid]; !known {
return nil, errors.New("unknown credential type")
}
if conf.revDBs == nil {
conf.revDBs = make(map[CredentialTypeIdentifier]*revocation.DB)
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment