private function composeStreamSocket()
    {
        $ctx = stream_context_create();

        //Already checked if certificate exists.
        $certificate = $this->config['certificate'];
        stream_context_set_option($ctx, 'ssl', 'local_cert', $certificate);

        if (isset($this->config['passPhrase'])) {
            $passPhrase = $this->config['passPhrase'];
            if (!empty($passPhrase)) {
                stream_context_set_option($ctx, 'ssl', 'passphrase', $passPhrase);
            }
        }

        if (isset($this->config['passFile'])) {
            $passFile = $this->config['passFile'];
            if (file_exists($passFile)) {
                stream_context_set_option($ctx, 'ssl', 'local_pk', $passFile);
            }
        }

        return $ctx;
    }