JAXLSocketClient::crypt PHP Method

crypt() public method

public crypt ( )
    public function crypt()
    {
        // set blocking (since tls negotiation fails if stream is non-blocking)
        stream_set_blocking($this->fd, true);
        $ret = stream_socket_enable_crypto($this->fd, true, STREAM_CRYPTO_METHOD_TLS_CLIENT);
        if ($ret == false) {
            $ret = stream_socket_enable_crypto($this->fd, true, STREAM_CRYPTO_METHOD_SSLv3_CLIENT);
            if ($ret == false) {
                $ret = stream_socket_enable_crypto($this->fd, true, STREAM_CRYPTO_METHOD_SSLv2_CLIENT);
                if ($ret == false) {
                    $ret = stream_socket_enable_crypto($this->fd, true, STREAM_CRYPTO_METHOD_SSLv23_CLIENT);
                }
            }
        }
        // switch back to non-blocking
        stream_set_blocking($this->fd, false);
        return $ret;
    }