I am having an issue sending updates to the Caddy-based Mercure Hub with both the Symfony Mercure\HubInterface and the "pure" PHP example.
When attempting to publish an update (following the official Symfony/Mercure tutorial), I get the error "Failed to send an update", with the TransportException:
"SSL certificate problem: unable to get local issuer certificate for "https://localhost/.well-known/mercure".
When trying to publish with the "pure" PHP example: https://github.com/dunglas/mercure/blob/main/examples/publish/php.php
I get the error:
"Warning: file_get_contents(https://localhost/.well-known/mercure): Failed to open stream: operation failed in /"path"/test.php on line 13"
Everything works when I run the CURL example (https://mercure.rocks/docs/getting-started) in Terminal:
curl -d 'topic=https://example.com/books/1' -d 'data={"foo": "updated value"}' -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJtZXJjdXJlIjp7InB1Ymxpc2giOlsiKiJdLCJzdWJzY3JpYmUiOlsiaHR0cHM6Ly9leGFtcGxlLmNvbS9teS1wcml2YXRlLXRvcGljIiwie3NjaGVtZX06Ly97K2hvc3R9L2RlbW8vYm9va3Mve2lkfS5qc29ubGQiLCIvLndlbGwta25vd24vbWVyY3VyZS9zdWJzY3JpcHRpb25zey90b3BpY317L3N1YnNjcmliZXJ9Il0sInBheWxvYWQiOnsidXNlciI6Imh0dHBzOi8vZXhhbXBsZS5jb20vdXNlcnMvZHVuZ2xhcyIsInJlbW90ZUFkZHIiOiIxMjcuMC4wLjEifX19.z5YrkHwtkz3O_nOnhC_FP7_bmeISe3eykAkGbAl5K7c' -X POST https://localhost/.well-known/mercure
Does anyone know what causes this issue and how to resolve it?
I am using Symfony 6 (running the symfonyCLI local dev server) with the Mercure Hub binary on a MacBook Pro M1, running it in dev mode with the command:
MERCURE_PUBLISHER_JWT_KEY='!ChangeMe!' \
MERCURE_SUBSCRIBER_JWT_KEY='!ChangeMe!' \
./mercure run -config Caddyfile.dev
I have tried running the symfonyCLI server with --no-tls, that did not work either.
try add in framework.yaml
framework:
http_client:
default_options:
verify_peer: false