tcpclient : manage the SSL CRYPTO options
git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@4148 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
@@ -57,14 +57,14 @@ class tcpclient
|
|||||||
while (empty ($this->ipv4) && empty ($this->ipv6) && $i < 10)
|
while (empty ($this->ipv4) && empty ($this->ipv6) && $i < 10)
|
||||||
{
|
{
|
||||||
$nsRecords = @dns_get_record ($ipOrName, DNS_A + DNS_AAAA);
|
$nsRecords = @dns_get_record ($ipOrName, DNS_A + DNS_AAAA);
|
||||||
if ($nsRecords === false)
|
if ($nsRecords === false || $nsRecords == array ())
|
||||||
{
|
{
|
||||||
// There is some problems with CNAME if they are not defined.
|
// There is some problems with CNAME if they are not defined.
|
||||||
// So enter in this case only if there is no other solution
|
// So enter in this case only if there is no other solution
|
||||||
$nsRecords = @dns_get_record ($ipOrName, DNS_CNAME);
|
$nsRecords = @dns_get_record ($ipOrName, DNS_CNAME);
|
||||||
if ($nsRecords === false)
|
if ($nsRecords === false || $nsRecords == array ())
|
||||||
throw new \Exception ("Can not find the IP for $ipOrName : ".
|
throw new \Exception ("Can not find the IP for $ipOrName : ".
|
||||||
"DNS Error (No A, AAAA, CNAME entries)", 500);
|
"DNS Error (No A, AAAA, CNAME entries)", 404);
|
||||||
}
|
}
|
||||||
foreach ($nsRecords as $val)
|
foreach ($nsRecords as $val)
|
||||||
{
|
{
|
||||||
@@ -79,10 +79,10 @@ class tcpclient
|
|||||||
}
|
}
|
||||||
if ($i >= 10)
|
if ($i >= 10)
|
||||||
throw new \Exception ("Can not find the IP for $ipOrName : ".
|
throw new \Exception ("Can not find the IP for $ipOrName : ".
|
||||||
"CNAME loop", 500);
|
"CNAME loop", 404);
|
||||||
if (empty ($this->ipv4) && empty ($this->ipv6))
|
if (empty ($this->ipv4) && empty ($this->ipv6))
|
||||||
throw new \Exception ("Can not find the IP for $ipOrName : ".
|
throw new \Exception ("Can not find the IP for $ipOrName : ".
|
||||||
"No A or AAAA record", 500);
|
"No A or AAAA record", 404);
|
||||||
}
|
}
|
||||||
$port = intval ($port);
|
$port = intval ($port);
|
||||||
if ($port < 0 || $port > 65535)
|
if ($port < 0 || $port > 65535)
|
||||||
@@ -154,16 +154,14 @@ class tcpclient
|
|||||||
* @return false if the client can not found a encryption method with the
|
* @return false if the client can not found a encryption method with the
|
||||||
* server
|
* server
|
||||||
*/
|
*/
|
||||||
public function cryptoEnable ($val,
|
public function cryptoEnable ($val, $cryptoMethod = null, $options = array ())
|
||||||
$cryptoMethod = STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT|
|
|
||||||
STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT,
|
|
||||||
$options = array ())
|
|
||||||
{
|
{
|
||||||
if ($this->socket === null)
|
if ($this->socket === null)
|
||||||
throw new \Exception ("Can not send to server $this->ipOrName : ".
|
throw new \Exception ("Can not send to server $this->ipOrName : ".
|
||||||
"The server is not connected", 500);
|
"The server is not connected", 500);
|
||||||
if ($cryptoMethod === null)
|
if ($cryptoMethod === null)
|
||||||
$cryptoMethod = STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT|
|
$cryptoMethod = STREAM_CRYPTO_METHOD_TLSv1_0_CLIENT|
|
||||||
|
STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT|
|
||||||
STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT;
|
STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT;
|
||||||
$optionsBase = array ("ssl" => array (
|
$optionsBase = array ("ssl" => array (
|
||||||
"peer_name" => $this->ipOrName,
|
"peer_name" => $this->ipOrName,
|
||||||
|
|||||||
Reference in New Issue
Block a user