Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Started getting InvalidArgumentException "Unable to load the key." #160

Open
trevorgehman opened this issue Feb 1, 2023 · 4 comments
Open

Comments

@trevorgehman
Copy link

Have been working fine except when we updated from 0.14.2 to 0.14.5.

I believe it is due to #158

Here is what we're doing:

       $options = [
            'key_id' => '***',
            'team_id' =>  '***',
            'app_bundle_id' =>  '***',
            'private_key_content' =>  '***',
        ];

        $tokenString = Token::create($options)->get(); // <-- Exception is thrown here

        $authProvider = Token::useExisting($tokenString, $options);

        $client = new Client($authProvider, config('apns.live'));

        // Create notifications here

        $client->addNotifications($notifications);

        $client->push();
@edamov
Copy link
Owner

edamov commented Feb 3, 2023

@trevorgehman Could you please send the text of exception?

@trevorgehman
Copy link
Author

trevorgehman commented Feb 3, 2023

Sure thing. @edamov

We downgraded back to 0.14.2 and everything works properly again. We double checked to make sure it's not a caching issue as well.

InvalidArgumentException Unable to load the key. 
    vendor/web-token/jwt-key-mgmt/KeyConverter/KeyConverter.php:214 Jose\Component\KeyManagement\KeyConverter\KeyConverter::tryToLoadECKey
    vendor/web-token/jwt-key-mgmt/KeyConverter/KeyConverter.php:194 Jose\Component\KeyManagement\KeyConverter\KeyConverter::loadKeyFromPEM
    vendor/web-token/jwt-key-mgmt/KeyConverter/KeyConverter.php:122 Jose\Component\KeyManagement\KeyConverter\KeyConverter::loadFromKey
    vendor/web-token/jwt-key-mgmt/JWKFactory.php:281 Jose\Component\KeyManagement\JWKFactory::createFromKey
    vendor/edamov/pushok/src/AuthProvider/Token.php:195 Pushok\AuthProvider\Token::generatePrivateECKey
    vendor/edamov/pushok/src/AuthProvider/Token.php:240 Pushok\AuthProvider\Token::generate
    vendor/edamov/pushok/src/AuthProvider/Token.php:111 Pushok\AuthProvider\Token::create
    app/Services/Pushok/PushokClient.php:23 Clearstream\Services\Pushok\PushokClient::Clearstream\Services\Pushok\{closure}
    vendor/laravel/framework/src/Illuminate/Cache/Repository.php:397 Illuminate\Cache\Repository::remember
    vendor/laravel/framework/src/Illuminate/Cache/CacheManager.php:419 Illuminate\Cache\CacheManager::__call
    vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:338 Illuminate\Support\Facades\Facade::__callStatic
    app/Services/Pushok/PushokClient.php:24 Clearstream\Services\Pushok\PushokClient::__construct
    [internal] ReflectionClass::newInstanceArgs
    vendor/laravel/framework/src/Illuminate/Container/Container.php:929 Illuminate\Container\Container::build
    vendor/laravel/framework/src/Illuminate/Container/Container.php:770 Illuminate\Container\Container::resolve
    vendor/laravel/framework/src/Illuminate/Foundation/Application.php:856 Illuminate\Foundation\Application::resolve
    vendor/laravel/framework/src/Illuminate/Container/Container.php:706 Illuminate\Container\Container::make
    vendor/laravel/framework/src/Illuminate/Foundation/Application.php:841 Illuminate\Foundation\Application::make
    vendor/laravel/framework/src/Illuminate/Foundation/helpers.php:120 app
    vendor/laravel/framework/src/Illuminate/Foundation/helpers.php:777 resolve
    app/Listeners/SendReplyIOsPushNotification.php:59 Clearstream\Listeners\SendReplyIOsPushNotification::handle
    vendor/laravel/framework/src/Illuminate/Events/CallQueuedListener.php:107 Illuminate\Events\CallQueuedListener::handle
    vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:36 Illuminate\Container\BoundMethod::Illuminate\Container\{closure}
    vendor/laravel/framework/src/Illuminate/Container/Util.php:41 Illuminate\Container\Util::unwrapIfClosure
    vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:93 Illuminate\Container\BoundMethod::callBoundMethod
    vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:37 Illuminate\Container\BoundMethod::call
    vendor/laravel/framework/src/Illuminate/Container/Container.php:661 Illuminate\Container\Container::call
    vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php:128 Illuminate\Bus\Dispatcher::Illuminate\Bus\{closure}
    vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:141 Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure}
    vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:116 Illuminate\Pipeline\Pipeline::then
    vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php:132 Illuminate\Bus\Dispatcher::dispatchNow
    vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php:124 Illuminate\Queue\CallQueuedHandler::Illuminate\Queue\{closure}
    vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:141 Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure}
    vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:116 Illuminate\Pipeline\Pipeline::then
    vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php:126 Illuminate\Queue\CallQueuedHandler::dispatchThroughMiddleware
    vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php:70 Illuminate\Queue\CallQueuedHandler::call
    vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php:98 Illuminate\Queue\Jobs\Job::fire
    vendor/laravel/framework/src/Illuminate/Queue/Worker.php:425 Illuminate\Queue\Worker::process
    vendor/laravel/framework/src/Illuminate/Queue/Worker.php:375 Illuminate\Queue\Worker::runJob
    vendor/laravel/framework/src/Illuminate/Queue/Worker.php:173 Illuminate\Queue\Worker::daemon
    vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php:147 Illuminate\Queue\Console\WorkCommand::runWorker
    vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php:130 Illuminate\Queue\Console\WorkCommand::handle
    vendor/laravel/horizon/src/Console/WorkCommand.php:51 Laravel\Horizon\Console\WorkCommand::handle
    vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:36 Illuminate\Container\BoundMethod::Illuminate\Container\{closure}
    vendor/laravel/framework/src/Illuminate/Container/Util.php:41 Illuminate\Container\Util::unwrapIfClosure
    vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:93 Illuminate\Container\BoundMethod::callBoundMethod
    vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:37 Illuminate\Container\BoundMethod::call
    vendor/laravel/framework/src/Illuminate/Container/Container.php:661 Illuminate\Container\Container::call
    vendor/laravel/framework/src/Illuminate/Console/Command.php:183 Illuminate\Console\Command::execute
    vendor/symfony/console/Command/Command.php:312 Symfony\Component\Console\Command\Command::run
    vendor/laravel/framework/src/Illuminate/Console/Command.php:153 Illuminate\Console\Command::run
    vendor/symfony/console/Application.php:1022 Symfony\Component\Console\Application::doRunCommand
    vendor/symfony/console/Application.php:314 Symfony\Component\Console\Application::doRun
    vendor/symfony/console/Application.php:168 Symfony\Component\Console\Application::run
    vendor/laravel/framework/src/Illuminate/Console/Application.php:102 Illuminate\Console\Application::run
    vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:155 Illuminate\Foundation\Console\Kernel::handle
    artisan:37 [main]

CleanShot 2023-02-03 at 08 38 20@2x

@mha1der
Copy link

mha1der commented Mar 2, 2023

I had the same problem. I think the problem is v3.0 of jwt-key-mgmt - seems to be fixed with newer versions (web-token/jwt-key-mgmt@c2444ff)

@paulandroshchuk
Copy link

Any chance this difference can be the reason?

CleanShot 2023-05-04 at 17 45 11@2x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants