fix: ignore undecryptable keys from view (#1528)

This commit is contained in:
Livio Amstutz 2021-04-06 13:49:16 +02:00 committed by GitHub
parent a393d549fb
commit efc90b382c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,10 +1,12 @@
package model
import (
"github.com/caos/zitadel/internal/domain"
"time"
"github.com/caos/logging"
"github.com/caos/zitadel/internal/crypto"
"github.com/caos/zitadel/internal/domain"
"github.com/caos/zitadel/internal/errors"
)
@ -90,15 +92,16 @@ func SigningKeyFromKeyView(key *KeyView, alg crypto.EncryptionAlgorithm) (*Signi
}
func PublicKeysFromKeyView(keys []*KeyView, alg crypto.EncryptionAlgorithm) ([]*PublicKey, error) {
converted := make([]*PublicKey, len(keys))
var err error
for i, key := range keys {
converted[i], err = PublicKeyFromKeyView(key, alg)
convertedKeys := make([]*PublicKey, 0, len(keys))
for _, key := range keys {
converted, err := PublicKeyFromKeyView(key, alg)
if err != nil {
return nil, err
logging.Log("MODEL-adB3f").WithError(err).Debug("cannot convert to public key") //TODO: change log level to warning when keys can be revoked
continue
}
convertedKeys = append(convertedKeys, converted)
}
return converted, nil
return convertedKeys, nil
}
func PublicKeyFromKeyView(key *KeyView, alg crypto.EncryptionAlgorithm) (*PublicKey, error) {