{"record":{"id":"60ab88808eca01ae","repo":"goharbor/harbor","slug":"failed-to-load-the-key-for-encryption-decryption","errorCode":null,"errorMessage":"failed to load the key for encryption/decryption： %v","messagePattern":"failed to load the key for encryption/decryption： (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/pkg/oidc/secret.go","lineNumber":98,"sourceCode":"\nvar m SecretManager = &defaultManager{\n\tmetaDao: dao.NewMetaDao(),\n}\n\n// VerifySecret verifies the secret and the token associated with it, it refreshes the token in the DB if it's\n// refreshed during the verification.  It returns a populated user model based on the ID token associated with the secret.\nfunc (dm *defaultManager) VerifySecret(ctx context.Context, username string, secret string) (*UserInfo, error) {\n\tlog.Debugf(\"Verifying the secret for user: %s\", username)\n\toidcUser, err := dm.metaDao.GetByUsername(ctx, username)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get oidc user info, error: %v\", err)\n\t}\n\tif oidcUser == nil {\n\t\treturn nil, fmt.Errorf(\"user is not onboarded as OIDC user, username: %s\", username)\n\t}\n\tkey, err := keyLoader.encryptKey()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to load the key for encryption/decryption： %v\", err)\n\t}\n\tplainSecret, err := utils.ReversibleDecrypt(oidcUser.Secret, key)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to decrypt secret from DB: %v\", err)\n\t}\n\tif subtle.ConstantTimeCompare([]byte(secret), []byte(plainSecret)) != 1 {\n\t\treturn nil, verifyError(fmt.Errorf(\"secret mismatch, username: %s\", username))\n\t}\n\ttokenStr, err := utils.ReversibleDecrypt(oidcUser.Token, key)\n\tif err != nil {\n\t\treturn nil, verifyError(err)\n\t}\n\ttoken := &Token{}\n\terr = json.Unmarshal(([]byte)(tokenStr), token)\n\tif err != nil {\n\t\treturn nil, verifyError(err)\n\t}\n\tif !token.Valid() {","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/goharbor/harbor/blob/7b2fd08cc568955cca339afeefab27372840d936/src/pkg/oidc/secret.go#L80-L116","documentation":"Error \"failed to load the key for encryption/decryption： %v\" thrown in goharbor/harbor.","triggerScenarios":"Thrown at src/pkg/oidc/secret.go:98 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7b2fd08cc568955cca339afeefab27372840d936","analyzedAt":"2026-08-16T00:00:10.961Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}