Skip to content

stream_context_create have no proxy option in ssl #158

Open
@famfamfam

Description

Describe the bug
stream_context_create ssl context have no proxy option, so proxy doesn't working.

Used config

Code to Reproduce

$client = $cm->make([
    'host' => 'imap.somehost.com',
    'port' => 993,
    'encryption' => 'ssl',
    'validate_cert' => true,
    'username' => '[email protected]',
    'password' => 'Password',
    'protocol' => 'imap',
    'proxy' => [
        'socket' => "tcp://proxy.com:3444",
        'request_fulluri' => false,
        'username' => "my_username",
        'password' => "secret_password",
    ]
]);

Bigged code

/**
     * Prepare socket options
     * @var string $transport
     *
     * @return array
     */
    private function defaultSocketOptions($transport) {
        $options = [];
        if ($this->encryption != false) {
            $options["ssl"] = [
                'verify_peer_name' => $this->getCertValidation(),
                'verify_peer'      => $this->getCertValidation(),
            ];
        }

        if ($this->proxy["socket"] != null) {
            $options[$transport]["proxy"] = $this->proxy["socket"];
            $options[$transport]["request_fulluri"] = $this->proxy["request_fulluri"];

            if ($this->proxy["username"] != null) {
                $auth = base64_encode($this->proxy["username"].':'.$this->proxy["password"]);

                $options[$transport]["header"] = [
                    "Proxy-Authorization: Basic $auth"
                ];
            }
        }

        return $options;
    }

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop / Server (please complete the following information):

  • OS: all
  • PHP: 7
  • Version last

Additional context
Add any other context about the problem here.

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions