dunglas / mercure

🪽 An open, easy, fast, reliable and battery-efficient solution for real-time communications
https://mercure.rocks
GNU Affero General Public License v3.0
3.98k stars 296 forks source link

How to disable SSL with symfony mercure ? #559

Closed TheoD02 closed 3 years ago

TheoD02 commented 3 years ago

Hey,

I'm stuck with the SSL certificate, during an update the http_client of symfony redirects me from http to https.

Via mercure we use SERVER_NAME:80 how to configure it directly for use with symfony CLI?

Error :

14:41:11 INFO      [http_client] Request: "POST http://127.0.0.1:8000/.well-known/mercure"
14:41:11 INFO      [http_client] Redirecting: "308 https://127.0.0.1/.well-known/mercure"

In Hub.php line 104:

  [Symfony\Component\Mercure\Exception\RuntimeException]  
  Failed to send an update.                               

Exception trace:
  at C:\Users\TheoD\Documents\Projects\deemon-php-gui\vendor\symfony\mercure\src\Hub.php:104
 Symfony\Component\Mercure\Hub->publish() at C:\Users\TheoD\Documents\Projects\deemon-php-gui\src\Command\DeemixStartCommand.php:57
 App\Command\DeemixStartCommand->execute() at C:\Users\TheoD\Documents\Projects\deemon-php-gui\vendor\symfony\console\Command\Command.php:299
 Symfony\Component\Console\Command\Command->run() at C:\Users\TheoD\Documents\Projects\deemon-php-gui\vendor\symfony\console\Application.php:996
 Symfony\Component\Console\Application->doRunCommand() at C:\Users\TheoD\Documents\Projects\deemon-php-gui\vendor\symfony\framework-bundle\Console\Application.php:96
 Symfony\Bundle\FrameworkBundle\Console\Application->doRunCommand() at C:\Users\TheoD\Documents\Projects\deemon-php-gui\vendor\symfony\console\Application.php:295
 Symfony\Component\Console\Application->doRun() at C:\Users\TheoD\Documents\Projects\deemon-php-gui\vendor\symfony\framework-bundle\Console\Application.php:82
 Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at C:\Users\TheoD\Documents\Projects\deemon-php-gui\vendor\symfony\console\Application.php:167
 Symfony\Component\Console\Application->run() at C:\Users\TheoD\Documents\Projects\deemon-php-gui\src\Message\StartDeemixHandler.php:24
 App\Message\StartDeemixHandler->__invoke() at C:\Users\TheoD\Documents\Projects\deemon-php-gui\vendor\symfony\messenger\Middleware\HandleMessageMiddleware.php:63
 Symfony\Component\Messenger\Middleware\HandleMessageMiddleware->handle() at C:\Users\TheoD\Documents\Projects\deemon-php-gui\vendor\symfony\messenger\Middleware\SendMessageMiddleware.php:74
 Symfony\Component\Messenger\Middleware\SendMessageMiddleware->handle() at C:\Users\TheoD\Documents\Projects\deemon-php-gui\vendor\symfony\messenger\Middleware\FailedMessageProcessingMiddleware.php:34
 Symfony\Component\Messenger\Middleware\FailedMessageProcessingMiddleware->handle() at C:\Users\TheoD\Documents\Projects\deemon-php-gui\vendor\symfony\messenger\Middleware\DispatchAfterCurrentBusMiddleware.php:68
 Symfony\Component\Messenger\Middleware\DispatchAfterCurrentBusMiddleware->handle() at C:\Users\TheoD\Documents\Projects\deemon-php-gui\vendor\symfony\messenger\Middleware\RejectRedeliveredMessageMiddleware.php:48
 Symfony\Component\Messenger\Middleware\RejectRedeliveredMessageMiddleware->handle() at C:\Users\TheoD\Documents\Projects\deemon-php-gui\vendor\symfony\messenger\Middleware\AddBusNameStampMiddleware.php:37
 Symfony\Component\Messenger\Middleware\AddBusNameStampMiddleware->handle() at C:\Users\TheoD\Documents\Projects\deemon-php-gui\vendor\symfony\messenger\Middleware\TraceableMiddleware.php:43
 Symfony\Component\Messenger\Middleware\TraceableMiddleware->handle() at C:\Users\TheoD\Documents\Projects\deemon-php-gui\vendor\symfony\messenger\MessageBus.php:77
 Symfony\Component\Messenger\MessageBus->dispatch() at C:\Users\TheoD\Documents\Projects\deemon-php-gui\vendor\symfony\messenger\TraceableMessageBus.php:41
 Symfony\Component\Messenger\TraceableMessageBus->dispatch() at C:\Users\TheoD\Documents\Projects\deemon-php-gui\vendor\symfony\messenger\RoutableMessageBus.php:54
 Symfony\Component\Messenger\RoutableMessageBus->dispatch() at C:\Users\TheoD\Documents\Projects\deemon-php-gui\vendor\symfony\messenger\Worker.php:131
 Symfony\Component\Messenger\Worker->handleMessage() at C:\Users\TheoD\Documents\Projects\deemon-php-gui\vendor\symfony\messenger\Worker.php:94
 Symfony\Component\Messenger\Worker->run() at C:\Users\TheoD\Documents\Projects\deemon-php-gui\vendor\symfony\messenger\Command\ConsumeMessagesCommand.php:209
 Symfony\Component\Messenger\Command\ConsumeMessagesCommand->execute() at C:\Users\TheoD\Documents\Projects\deemon-php-gui\vendor\symfony\console\Command\Command.php:299
 Symfony\Component\Console\Command\Command->run() at C:\Users\TheoD\Documents\Projects\deemon-php-gui\vendor\symfony\console\Application.php:996
 Symfony\Component\Console\Application->doRunCommand() at C:\Users\TheoD\Documents\Projects\deemon-php-gui\vendor\symfony\framework-bundle\Console\Application.php:96
 Symfony\Bundle\FrameworkBundle\Console\Application->doRunCommand() at C:\Users\TheoD\Documents\Projects\deemon-php-gui\vendor\symfony\console\Application.php:295
 Symfony\Component\Console\Application->doRun() at C:\Users\TheoD\Documents\Projects\deemon-php-gui\vendor\symfony\framework-bundle\Console\Application.php:82
 Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at C:\Users\TheoD\Documents\Projects\deemon-php-gui\vendor\symfony\console\Application.php:167
 Symfony\Component\Console\Application->run() at C:\Users\TheoD\Documents\Projects\deemon-php-gui\vendor\symfony\runtime\Runner\Symfony\ConsoleApplicationRunner.php:56
 Symfony\Component\Runtime\Runner\Symfony\ConsoleApplicationRunner->run() at C:\Users\TheoD\Documents\Projects\deemon-php-gui\vendor\autoload_runtime.php:35
 require_once() at C:\Users\TheoD\Documents\Projects\deemon-php-gui\bin\console:11

In CommonResponseTrait.php line 151:

  [Symfony\Component\HttpClient\Exception\TransportException]             
  fopen(): SSL operation failed with code 1. OpenSSL Error messages:      
  error:14094438:SSL routines:ssl3_read_bytes:tlsv1 alert internal error  

Thanks !

Lustmored commented 3 years ago

I have just spent a few hours debugging it. In the end you only need one directive - auto_https off. My full docker-compose example:

    mercure:
        image: dunglas/mercure
        command: caddy run -config /etc/caddy/Caddyfile.dev
        environment:
            MERCURE_EXTRA_DIRECTIVES: |
                anonymous
                auto_https off
                cors_origins https://project.wip
                demo
                publish_origins *
            MERCURE_PUBLISHER_JWT_KEY: "!ChangeMe!"
            MERCURE_SUBSCRIBER_JWT_KEY: "!ChangeMe!"
            SERVER_NAME: ":80"
        ports: ["80"]