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

Problem with SocketHttpClient constructor in src/Transport/Client.php #30

Open
wash34000 opened this issue Jul 16, 2021 · 0 comments
Open

Comments

@wash34000
Copy link

wash34000 commented Jul 16, 2021

Hello,

I found a problem when I wanted to connect to a print server using HTTPS and a self-signed certificate.

        $client = new Client("printer", "edsfsdfgdsfdsfgdsfg", [
            "remote_socket" => "XXX.XXX.XXX.XXX:631",
            "ssl" => true,
            'stream_context_options' => [
                'ssl' => [
                    'allow_self_signed' => false,
                    'verify_peer' => false,
                    'verify_peer_name' => false
                ]
            ],
        ]);

My stream_context_optionsparameters was not working.

I found the solution in file /src/Transport/Client.php on line 73 :
$socketClient = new SocketHttpClient($messageFactory, $socketClientOptions);
replaced by :
$socketClient = new SocketHttpClient($messageFactory, null, $socketClientOptions);

because the SocketHttpClient constructor is :

    /**
     * Constructor.
     *
     * @param array $config {
     *
     *    @var string $remote_socket          Remote entrypoint (can be a tcp or unix domain address)
     *    @var int    $timeout                Timeout before canceling request
     *    @var array  $stream_context_options Context options as defined in the PHP documentation
     *    @var array  $stream_context_param   Context params as defined in the PHP documentation
     *    @var bool   $ssl                    Use ssl, default to scheme from request, false if not present
     *    @var int    $write_buffer_size      Buffer when writing the request body, defaults to 8192
     *    @var int    $ssl_method             Crypto method for ssl/tls, see PHP doc, defaults to STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT
     * }
     */
    public function __construct($config1 = [], $config2 = null, array $config = [])
    {
        if (\is_array($config1)) {
            $this->config = $this->configure($config1);

            return;
        }

        @trigger_error('Passing a Psr\Http\Message\ResponseFactoryInterface and a Psr\Http\Message\StreamFactoryInterface to SocketClient is deprecated, and will be removed in 3.0, you should only pass config options.', E_USER_DEPRECATED);

        $this->config = $this->configure($config);
    }

Kind regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant