Search code examples
laravellaravel-passport

Laravel API Authentication (Passport); ErrorException in CryptKey.php


ErrorException in CryptKey.php line 57:

Key file "file://C:\wamp\www\project\public_html\storage\oauth-private.key" permissions are not correct, should be 600 or 660 instead of 666

My Configuration as follows:

  • Windows 10 64bit
  • WampServer 3.1.0
  • Apache 2.4.27
  • PHP 7.0.23
  • Laravel Framework version 5.3.31
  • composer require laravel/passport=~1.0

Any idea how to solve it?


Solution

  • You can turn off file checking permissions on line 57

    your CryptKey Path is vendor/league/oauth2-server/src/CryptKey.php

    on line number 48 turn it to false or comment the following block in your CryptKey.php

       if ($keyPermissionsCheck === true) {
            // Verify the permissions of the key
            $keyPathPerms = decoct(fileperms($keyPath) & 0777);
            if (in_array($keyPathPerms, ['600', '660'], true) === false) {
                trigger_error(sprintf(
                    'Key file "%s" permissions are not correct, should be 600 or 660 instead of %s',
                    $keyPath,
                    $keyPathPerms
                ), E_USER_NOTICE);
            }
        }
    

    keyPermissionsCheck set it to false.

    Hope this helps.