当前位置: 首页 > 知识库问答 >
问题:

拉拉维尔护照 JWT 身份验证失败

阎璞瑜
2023-03-14

突然,当尝试通过护照创建JWT时,我开始在生产中遇到此错误,运行在Ubuntu / apache2上。据我所知,服务器上没有任何更改,没有安装,没有部署,它只是停止工作。

PHP 7.3

OpenSSL 1.0.1f

Laravel 5.8

production.ERROR: There was an error while creating the signature: error:04066044:rsa routines:rsa_ossl_private_encrypt:internal error {"exception":"[object] (InvalidArgumentException(code: 0): There was an error while creating the signature: error:04066044:rsa routines:rsa_ossl_private_encrypt:internal error at /api/vendor/lcobucci/jwt/src/Signer/OpenSSL.php:27)
[stacktrace]
#0 /api/vendor/lcobucci/jwt/src/Signer/BaseSigner.php(36): Lcobucci\\JWT\\Signer\\OpenSSL->createHash('eyJ0eXAiOiJKV1Q...', Object(Lcobucci\\JWT\\Signer\\Key))
#1 /api/vendor/lcobucci/jwt/src/Builder.php(470): Lcobucci\\JWT\\Signer\\BaseSigner->sign('eyJ0eXAiOiJKV1Q...', Object(Lcobucci\\JWT\\Signer\\Key))
#2 /api/vendor/lcobucci/jwt/src/Builder.php(450): Lcobucci\\JWT\\Builder->createSignature(Array, Object(Lcobucci\\JWT\\Signer\\Rsa\\Sha256), Object(Lcobucci\\JWT\\Signer\\Key))
#3 /api/vendor/league/oauth2-server/src/Entities/Traits/AccessTokenTrait.php(41): Lcobucci\\JWT\\Builder->getToken()
#4 /api/vendor/league/oauth2-server/src/ResponseTypes/BearerTokenResponse.php(28): Laravel\\Passport\\Bridge\\AccessToken->convertToJWT(Object(League\\OAuth2\\Server\\CryptKey))
#5 /api/vendor/league/oauth2-server/src/AuthorizationServer.php(202): League\\OAuth2\\Server\\ResponseTypes\\BearerTokenResponse->generateHttpResponse(Object(Zend\\Diactoros\\Response))
#6 /api/vendor/laravel/passport/src/Http/Controllers/AccessTokenController.php(63): League\\OAuth2\\Server\\AuthorizationServer->respondToAccessTokenRequest(Object(Zend\\Diactoros\\ServerRequest), Object(Zend\\Diactoros\\Response))
#7 /api/vendor/laravel/passport/src/Http/Controllers/HandlesOAuthErrors.php(28): Laravel\\Passport\\Http\\Controllers\\AccessTokenController->Laravel\\Passport\\Http\\Controllers\\{closure}()
#8 /api/vendor/laravel/passport/src/Http/Controllers/AccessTokenController.php(65): Laravel\\Passport\\Http\\Controllers\\AccessTokenController->withErrorHandling(Object(Closure))
#9 /api/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(48): Laravel\\Passport\\Http\\Controllers\\AccessTokenController->issueToken(Object(Zend\\Diactoros\\ServerRequest))
#10 /api/vendor/laravel/framework/src/Illuminate/Routing/Route.php(219): Illuminate\\Routing\\ControllerDispatcher->dispatch(Object(Illuminate\\Routing\\Route), Object(Laravel\\Passport\\Http\\Controllers\\AccessTokenController), 'issueToken')
#11 /api/vendor/laravel/framework/src/Illuminate/Routing/Route.php(176): Illuminate\\Routing\\Route->runController()
#12 /api/vendor/laravel/framework/src/Illuminate/Routing/Router.php(680): Illuminate\\Routing\\Route->run()
#13 /api/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#14 /api/vendor/laravel/framework/src/Illuminate/Routing/Middleware/ThrottleRequests.php(58): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#15 /api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\\Routing\\Middleware\\ThrottleRequests->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#16 /api/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#17 /api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(104): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#18 /api/vendor/laravel/framework/src/Illuminate/Routing/Router.php(682): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#19 /api/vendor/laravel/framework/src/Illuminate/Routing/Router.php(657): Illuminate\\Routing\\Router->runRouteWithinStack(Object(Illuminate\\Routing\\Route), Object(Illuminate\\Http\\Request))
#20 /api/vendor/laravel/framework/src/Illuminate/Routing/Router.php(623): Illuminate\\Routing\\Router->runRoute(Object(Illuminate\\Http\\Request), Object(Illuminate\\Routing\\Route))
#21 /api/vendor/laravel/framework/src/Illuminate/Routing/Router.php(612): Illuminate\\Routing\\Router->dispatchToRoute(Object(Illuminate\\Http\\Request))
#22 /api/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(176): Illuminate\\Routing\\Router->dispatch(Object(Illuminate\\Http\\Request))
#23 /api/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}(Object(Illuminate\\Http\\Request))

我还注意到这个错误的另一个版本。没有什么变化,所以我不知道为什么会出现这种错误。

注意这一点:rsa routines:RSA_setup_blinding:BN lib

production.ERROR: There was an error while creating the signature: error:04088003:rsa routines:RSA_setup_blinding:BN lib {"exception":"[object] (InvalidArgumentException(code: 0): There was an error while creating the signature: error:04088003:rsa routines:RSA_setup_blinding:BN lib at /api/vendor/lcobucci/jwt/src/Signer/OpenSSL.php:27)
[stacktrace]
#0 /api/vendor/lcobucci/jwt/src/Signer/BaseSigner.php(36): Lcobucci\\JWT\\Signer\\OpenSSL->createHash('eyJ0eXAiOiJKV1Q...', Object(Lcobucci\\JWT\\Signer\\Key))
#1 /api/vendor/lcobucci/jwt/src/Builder.php(470): Lcobucci\\JWT\\Signer\\BaseSigner->sign('eyJ0eXAiOiJKV1Q...', Object(Lcobucci\\JWT\\Signer\\Key))
#2 /api/vendor/lcobucci/jwt/src/Builder.php(450): Lcobucci\\JWT\\Builder->createSignature(Array, Object(Lcobucci\\JWT\\Signer\\Rsa\\Sha256), Object(Lcobucci\\JWT\\Signer\\Key))
#3 /api/vendor/league/oauth2-server/src/Entities/Traits/AccessTokenTrait.php(41): Lcobucci\\JWT\\Builder->getToken()
#4 /api/vendor/league/oauth2-server/src/ResponseTypes/BearerTokenResponse.php(28): Laravel\\Passport\\Bridge\\AccessToken->convertToJWT(Object(League\\OAuth2\\Server\\CryptKey))
#5 /api/vendor/league/oauth2-server/src/AuthorizationServer.php(202): League\\OAuth2\\Server\\ResponseTypes\\BearerTokenResponse->generateHttpResponse(Object(Zend\\Diactoros\\Response))
#6 /api/vendor/laravel/passport/src/Http/Controllers/AccessTokenController.php(63): League\\OAuth2\\Server\\AuthorizationServer->respondToAccessTokenRequest(Object(Zend\\Diactoros\\ServerRequest), Object(Zend\\Diactoros\\Response))
#7 /api/vendor/laravel/passport/src/Http/Controllers/HandlesOAuthErrors.php(28): Laravel\\Passport\\Http\\Controllers\\AccessTokenController->Laravel\\Passport\\Http\\Controllers\\{closure}()
#8 /api/vendor/laravel/passport/src/Http/Controllers/AccessTokenController.php(65): Laravel\\Passport\\Http\\Controllers\\AccessTokenController->withErrorHandling(Object(Closure))
#9 /api/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(48): Laravel\\Passport\\Http\\Controllers\\AccessTokenController->issueToken(Object(Zend\\Diactoros\\ServerRequest))
#10 /api/vendor/laravel/framework/src/Illuminate/Routing/Route.php(219): Illuminate\\Routing\\ControllerDispatcher->dispatch(Object(Illuminate\\Routing\\Route), Object(Laravel\\Passport\\Http\\Controllers\\AccessTokenController), 'issueToken')
#11 /api/vendor/laravel/framework/src/Illuminate/Routing/Route.php(176): Illuminate\\Routing\\Route->runController()
#12 /api/vendor/laravel/framework/src/Illuminate/Routing/Router.php(680): Illuminate\\Routing\\Route->run()
#13 /api/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#14 /api/vendor/laravel/framework/src/Illuminate/Routing/Middleware/ThrottleRequests.php(58): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#15 /api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\\Routing\\Middleware\\ThrottleRequests->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#16 /api/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#17 /api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(104): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#18 /api/vendor/laravel/framework/src/Illuminate/Routing/Router.php(682): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#19 /api/vendor/laravel/framework/src/Illuminate/Routing/Router.php(657): Illuminate\\Routing\\Router->runRouteWithinStack(Object(Illuminate\\Routing\\Route), Object(Illuminate\\Http\\Request))
#20 /api/vendor/laravel/framework/src/Illuminate/Routing/Router.php(623): Illuminate\\Routing\\Router->runRoute(Object(Illuminate\\Http\\Request), Object(Illuminate\\Routing\\Route))
#21 /api/vendor/laravel/framework/src/Illuminate/Routing/Router.php(612): Illuminate\\Routing\\Router->dispatchToRoute(Object(Illuminate\\Http\\Request))
#22 /api/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(176): Illuminate\\Routing\\Router->dispatch(Object(Illuminate\\Http\\Request))
#23 /api/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}(Object(Illuminate\\Http\\Request))
#24 /api/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))

共有1个答案

郭志
2023-03-14

我今天有同样的问题。花了很多时间,没有找到解决方案。这个算法对我有帮助

  1. sudo certbot
  2. 选择需要的域,然后输入'2'两次以更新ssl证书
  3. 然后从存储文件夹中删除密钥,也从数据库表中删除oauth_clients
  4. php工匠护照:安装
  5. 检查存储文件夹中密钥的权限
  6. sudo服务apache2重启

在那之后,拉拉维尔护照开始登录用户。对我来说,证书似乎有些问题,因为没有证书更新的同一堆命令不能修复身份验证工作。

 类似资料:
  • 我有点困惑于认识到和包之间的差异。它们实际上通过令牌服务于相同的API身份验证目的吗?只要Laravel Pasport是在5.3中引入的,在最新版本中是否应该使用Pasport而不是包?

  • 我目前正在研究构建SaaS构建管理工具。我想知道的是,如果我使用laravel passport作为api令牌,我如何为用户分配角色,例如: SuperAdmin:可以创建项目|可以创建新用户并为用户分配角色。 管理员:可以查看项目。 因为我希望能够根据用户权限隐藏前端上的元素。 例如,如果我使用传统的laravel应用程序,我可以使用委托和刀片指令@role('admin')来显示基于用户权限类

  • 我对拉威尔望远镜的部分有点困惑。 我有一个用户模型和表。 如何为用户分配用户、客户和/或管理员的角色。 我有一个带有vue和laravel api后端的水疗中心。我用https://laravel.com/docs/5.3/passport#consuming-使用javascript创建api 我如何分配哪个用户模型具有哪些作用域? 还是范围与角色不同? 您将如何实现这一点? 提前谢谢!

  • 拉拉维尔8中的照片没有以html格式显示“替代文本显示”。在Windows文件资源管理器中,我发现每张照片都是一个文件夹,其中包含照片的名称,例如“myphoto.jpg”,此文件夹中有一个“.tmp”文件。目标文件夹是“上传/发布”,当我在浏览器中检查照片时,链接显示正确。这是一张照片的链接示例:“http://localhost/laravel/blog/uploads/posts/16571

  • 我正在开发一个具有自己的身份验证和授权机制的REST应用程序。我想使用JSON Web Tokens进行身份验证。以下是有效且安全的实现吗? < li >将开发一个REST API来接受用户名和密码并进行认证。要使用的HTTP方法是POST,因此没有缓存。此外,在传输时还会有安全SSL < li >在认证时,将创建两个JWTs访问令牌和刷新令牌。刷新令牌将具有更长的有效期。这两个令牌都将写入coo

  • 所以我正在尝试为我的网站实现一个支付解决方案,经过相当多的研究,我仍然缺乏一个完整的解决方案。我正在运行Laravel 5.0,需要一般购物车付款功能。我想我会发布这篇文章,试图创建一个参考,以帮助其他可能有这个问题的人。我已经把测试事务放到了Paypal的沙箱中,这似乎是砖墙的所在,但是一个完整的概述会很有帮助。我将列出我需要克服的问题,以便解决一些问题。 完成支付解决方案实施需要解决的问题 >