From 9a1029861ca4bdc4afe6ea46c3c737cb8a37105b Mon Sep 17 00:00:00 2001 From: Captain ALM Date: Sun, 9 Jun 2024 21:20:46 +0100 Subject: [PATCH] Update go mod sum Fix up KeyStore --- go.sum | 3 +-- key_store.go | 11 +++++------ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/go.sum b/go.sum index 59f20a5..551cfd8 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,4 @@ -github.com/1f349/rsa-helper v0.0.0-20240608023351-e4382c728b17 h1:cgJDS14TTM8hvg1qNhXFj3IfFEZ99IXR00D8gcwbY98= -github.com/1f349/rsa-helper v0.0.0-20240608023351-e4382c728b17/go.mod h1:VUQ++1tYYhYrXeOmVFkQ82BegR24HQEJHl5lHbjg7yg= +github.com/1f349/rsa-helper v0.0.1 h1:Ec/MXHR2eIpLgIR69eqhCV2o8OOBs2JZNAkEhW7HQks= github.com/1f349/rsa-helper v0.0.1/go.mod h1:VUQ++1tYYhYrXeOmVFkQ82BegR24HQEJHl5lHbjg7yg= github.com/becheran/wildmatch-go v1.0.0 h1:mE3dGGkTmpKtT4Z+88t8RStG40yN9T+kFEGj2PZFSzA= github.com/becheran/wildmatch-go v1.0.0/go.mod h1:gbMvj0NtVdJ15Mg/mH9uxk2R1QCistMyU7d9KFzroX4= diff --git a/key_store.go b/key_store.go index 49cc6df..c2d00ee 100644 --- a/key_store.go +++ b/key_store.go @@ -50,7 +50,8 @@ func NewMJwtKeyStoreFromDirectory(directory, keyPrvExt, keyPubExt string) (KeySt if kID == "" { continue } - if path.Ext(entry.Name()) == "."+keyPrvExt { + pExt := path.Ext(entry.Name()) + if pExt == "."+keyPrvExt { // Load rsa private key with the file name as the kID (Up to the first .) key, err2 := rsaprivate.Read(path.Join(directory, entry.Name())) if err2 == nil { @@ -58,7 +59,7 @@ func NewMJwtKeyStoreFromDirectory(directory, keyPrvExt, keyPubExt string) (KeySt ks.storePub[kID] = &key.PublicKey } errs = append(errs, err2) - } else if path.Ext(entry.Name()) == "."+keyPubExt { + } else if pExt == "."+keyPubExt { // Load rsa public key with the file name as the kID (Up to the first .) key, err2 := rsapublic.Read(path.Join(directory, entry.Name())) if err2 == nil { @@ -71,8 +72,7 @@ func NewMJwtKeyStoreFromDirectory(directory, keyPrvExt, keyPubExt string) (KeySt errs = append(errs, err2) } } - err = errors.Join(errs...) - return ks, err + return ks, errors.Join(errs...) } // ExportKeyStore saves all the keys stored in the specified KeyStore into a directory with the specified @@ -102,8 +102,7 @@ func ExportKeyStore(ks KeyStore, directory, keyPrvExt, keyPubExt string) error { errs = append(errs, err2) } } - err = errors.Join(errs...) - return err + return errors.Join(errs...) } // SetKey adds a new rsa.PrivateKey with the specified kID to the KeyStore.