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

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

Merged
merged 2 commits into from
Oct 31, 2023

Conversation

GeorgII-web
Copy link
Contributor

@GeorgII-web GeorgII-web commented Jul 18, 2023

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

@GeorgII-web GeorgII-web changed the title Patch-2 Fix for creating a stream context from a custom user parameters Jul 18, 2023
@GeorgII-web GeorgII-web marked this pull request as ready for review July 18, 2023 08:55
@github-actions
Copy link

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
Copy link

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

@github-actions github-actions bot closed this Oct 30, 2023
@mihaileu mihaileu reopened this Oct 31, 2023
@mihaileu mihaileu merged commit abe69ad into php-amqplib:master Oct 31, 2023
0 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants