首页 > 解决方案 > oauth-private.key 在 laravel 中不存在或不可读

问题描述

我从使用护照库的 Laravel Framework 6.13.1 编写的 gitlab 克隆了一个项目。像往常一样,我首先执行了composer install但我得到了这个错误:

   LogicException  : Key path "file://C:\xampp\htdocs\myproject\storage\oauth-private.key" does not exist or is not readable

  at C:\xampp\htdocs\myproject\vendor\league\oauth2-server\src\CryptKey.php:48
    44|             $keyPath = 'file://' . $keyPath;
    45|         }
    46|
    47|         if (!file_exists($keyPath) || !is_readable($keyPath)) {
  > 48|             throw new LogicException(sprintf('Key path "%s" does not exist or is not readable', $keyPath));
    49|         }
    50|
    51|         if ($keyPermissionsCheck === true) {
    52|             // Verify the permissions of the key

  Exception trace:

  1   League\OAuth2\Server\CryptKey::__construct("file://C:\xampp\htdocs\myproject\storage\oauth-private.key")
      C:\xampp\htdocs\note-server\vendor\laravel\passport\src\PassportServiceProvider.php:248

  2   Laravel\Passport\PassportServiceProvider::makeCryptKey("private")
      C:\xampp\htdocs\note-server\vendor\laravel\passport\src\PassportServiceProvider.php:214

现在我无法运行 php artisan 命令我得到了同样的错误

问题出在哪里?为什么我得到这个错误?我在互联网上搜索,有人说运行php artisan passport:install或其他命令,但我现在无法运行php artiasan,因为出现了同样的错误

标签: phplaravel

解决方案


由于/storage/*.key位于.gitignore中,因此如果您拉取项目,则运行时可能会丢失密钥

 php artisan passport:keys

将为您生成新密钥。


推荐阅读