Commit 2c9ff51c authored by Sietse Ringers's avatar Sietse Ringers
Browse files

Add missing error checks

parent 62966ab9
......@@ -179,7 +179,6 @@ func Base64Decode(b []byte) ([]byte, error) {
encodings = []*base64.Encoding{base64.RawStdEncoding, base64.URLEncoding, base64.RawURLEncoding, base64.StdEncoding}
)
for _, encoding := range encodings {
err = nil
if bts, err = encoding.DecodeString(string(b)); err == nil {
break
}
......
......@@ -188,18 +188,20 @@ func getJwt(t *testing.T, request irma.SessionRequest, sessiontype string, alg j
tok := jwt.NewWithClaims(jwt.SigningMethodRS256, jwtcontents)
tok.Header["kid"] = "requestor1"
j, err = tok.SignedString(sk)
require.NoError(t, err)
case jwt.SigningMethodHS256:
tok := jwt.NewWithClaims(jwt.SigningMethodHS256, jwtcontents)
tok.Header["kid"] = "requestor3"
bts, err := base64.StdEncoding.DecodeString(JwtServerConfiguration.Requestors["requestor3"].AuthenticationKey)
require.NoError(t, err)
j, err = tok.SignedString(bts)
require.NoError(t, err)
case jwt.SigningMethodNone:
tok := jwt.NewWithClaims(jwt.SigningMethodNone, jwtcontents)
tok.Header["kid"] = kid
j, err = tok.SignedString(jwt.UnsafeAllowNoneSignatureType)
require.NoError(t, err)
}
require.NoError(t, err)
return j
}
......
......@@ -153,7 +153,8 @@ func postRequest(serverurl string, request irma.RequestorRequest, name, authmeth
transport.SetHeader("Authentication", key)
err = transport.Post("session", qr, request)
case "hmac", "rsa":
jwtstr, err := signRequest(request, name, authmethod, key)
var jwtstr string
jwtstr, err = signRequest(request, name, authmethod, key)
if err != nil {
return nil, nil, err
}
......
......@@ -44,9 +44,9 @@ Careful: this command could fail and invalidate or destroy your scheme manager d
case 2:
sk = args[0]
confpath, err = filepath.Abs(args[1])
if err != nil {
return errors.WrapPrefix(err, "Invalid path", 0)
}
}
if err != nil {
return errors.WrapPrefix(err, "Invalid path", 0)
}
privatekey, err := readPrivateKey(sk)
......
......@@ -52,6 +52,9 @@ func updateSchemeManager(paths []string) error {
for _, path := range paths {
path, err := filepath.Abs(path)
if err != nil {
return err
}
irmaconf, manager := filepath.Dir(path), filepath.Base(path)
conf, err := irma.NewConfiguration(irmaconf)
......
......@@ -1355,6 +1355,9 @@ func (conf *Configuration) CheckKeys() error {
continue
}
latest, err := conf.PublicKey(issuerid, indices[len(indices)-1])
if err != nil {
return err
}
now := time.Now().Unix()
if latest == nil || latest.ExpiryDate < now {
conf.Warnings = append(conf.Warnings, fmt.Sprintf("Issuer %s has no nonexpired public keys", issuerid.String()))
......
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