PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, March 3, 2022

[FIXED] Laravel - Broacasting with pusher - Invalid Signature

 March 03, 2022     laravel-5, pusher     No comments   

Issue

I just started using pusher because I had problems with redis and socket.io. For that I followed the documentation of Laravel, I created an account on pusher and insert the keys in the file .env.

BROADCAST_DRIVER=pusher
CACHE_DRIVER=file
SESSION_DRIVER=file
SESSION_LIFETIME=120
QUEUE_DRIVER=database

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

PUSHER_APP_ID=XXXXX
PUSHER_APP_KEY=XXXXXXXXXXXXX
PUSHER_APP_SECRET=XXXXXXXXXXXXXX
PUSHER_APP_CLUSTER=eu

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

Then I created an event that implements the should broadcast interface

<?php

namespace App\Events;

use Illuminate\Broadcasting\Channel;
use Illuminate\Queue\SerializesModels;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;

class IncrementAddingOrderCounter implements ShouldBroadcast
{
    use Dispatchable, InteractsWithSockets, SerializesModels;
    public $length;
    public $value;

    /**
     * Create a new event instance.
     *
     * @param $length
     * @param $value
     */
    public function __construct($length, $value)
    {
        $this->length = $length;
        $this->value = $value;
    }

    /**
     * Get the channels the event should broadcast on.
     *
     * @return \Illuminate\Broadcasting\Channel|array
     */
    public function broadcastOn()
    {
        return new Channel('add.order');
    }

    public function broadcastAs()
    {
        return 'increment.order';
    }
}

Afterwards I emit the event with

event(new IncrementAddingOrderCounter(count($parsedData), $size));

But the execution of the event failed

queue error and if I look in my logs I see this error

[2018-07-26 04:21:26] local.ERROR: Invalid signature: you should have sent HmacSHA256Hex("POST\n/apps/xxxxxx/events\nauth_key=xxxxxxxxxx&auth_timestamp=xxxxxxxx&auth_version=1.0&body_md5=xxxxxxxxxxxx", your_secret_key), but you sent "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
 {"exception":"[object] (Illuminate\\Broadcasting\\BroadcastException(code: 0): Invalid signature: you should have sent HmacSHA256Hex(\"POST\
/apps/567300/events\
auth_key=xxxxxxxxxx&auth_timestamp=xxxxxxx&auth_version=1.0&body_md5=xxxxxxxxxxxx\", your_secret_key), but you sent \"xxxxxxxxxxxxxxx\"
 at /home/oza/lab/php/Client1_GestionCommerce/vendor/laravel/framework/src/Illuminate/Broadcasting/Broadcasters/PusherBroadcaster.php:116)
[stacktrace]

Does anyone have a solution on that because I search on the internet and I can not find anything


Solution

If you're sending the wrong signature, that usually means they key/secret/app id/cluster are not configured correctly. Can you double check these? You also potentially published a sensitive key in your post - I recommend obscuring it and generating a new id/key/secret combo (can be done from the Pusher dashboard!).



Answered By - kn100
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing