php-amqplib / RabbitMqBundle

RabbitMQ Bundle for the Symfony web framework
MIT License
1.22k stars 470 forks source link

Fix for creating a stream context from a custom user parameters #711

Closed GeorgII-web closed 1 year ago

GeorgII-web commented 1 year ago

What: Fix for dynamic using of ssl_context => verify_peer option. In my case it was Local\AWS environment and there was no option to use one yml config for both environments.

How to reproduce: On using custom class for an option connection_parameters_provider: App\Service\ConnectionParametersProviderService I'm deciding to use or not SSL

if ($this->verifyPeer !== null) {
   return ['ssl_context' => ['verify_peer' => $this->verifyPeer]];
}
return [];

But RabbitMq/AMQPConnectionFactory.php tries to create stream context for SSL options before it gets it from custom Connection parameters from users class, and there is no stream context for it.

In total, parameters looks like (invalid):

[
  ...
  "ssl_context" => array:1 [
    "verify_peer" => true
  ]
  "context" => []
]

instead of (valid):

[
  ...
  "ssl_context" => array:1 [
    "verify_peer" => true
  ]
  "context" => stream-context resource @1392
    options: array:1 [
      "ssl" => array:1 [
        "verify_peer" => true
      ]
    ]
  }
]

The fix: Change the order of getting an user parameters and creating a stream context

github-actions[bot] commented 1 year ago

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] commented 1 year ago

This PR was closed because it has been stalled for 10 days with no activity.