• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

problem using api rpc xml call (curl error number 51)

F

fidel@

Guest
hi, all

i'm trying to connect to a plesk 8.1.1 using php curl and i'm using a couple of samples that i've seen overthere (for example, http://download1.swsoft.com/Plesk/Plesk8.1/Doc/plesk-8.1-api-rpc/)

======================

$headers = array(
'HTTP_AUTH_LOGIN: ********',
'HTTP_AUTH_PASSWD: *********',
'Content-Type: text/xml'
);

$data =<<<EOF
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<packet version="1.4.0.0">
...
...
</packet>
EOF;

$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_URL, 'https://***.***.***.***:8443/enterprise/control/agent.php');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt ( $ch, CURLOPT_VERBOSE, 1 );
$result = curl_exec($ch);
if ( $result == CURL_OK ) print_r ( curl_getinfo ( $ch ) );
else print "\n\n-----\n" . "cURL error number:" . curl_errno ( $ch ) . "\n\ncURL error:" . curl_error ( $ch );
curl_close($ch);

======================

$data =<<<EOF
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<packet version="1.4.0.0">
...
...
</packet>
EOF;

$crida = "POST /enterprise/control/agent.php HTTP/1.1\r\n";
$crida .= "Host: ***.***.***.***:8443\r\n";
$crida .= "Accept: */*\r\n";
$crida .= "HTTP_AUTH_LOGIN: ********\r\n";
$crida .= "HTTP_AUTH_PASSWD: *********\r\n";
$crida .= "Pragma: no-cache\r\n";
$crida .= "Content-Length: " . strlen ( $data ) . "\r\n";
$crida .= "Content-Type: text/xml\r\n\r\n";
$crida .= $data . "\r\n";

$ch = curl_init ( 'https://***.***.***.***:8443/enterprise/control/agent.php' );
curl_setopt ( $ch, CURLOPT_SSL_VERIFYHOST, 2 );
curl_setopt ( $ch, CURLOPT_SSL_VERIFYPEER, 1 );
curl_setopt ( $ch, CURLOPT_CUSTOMREQUEST, $crida );
curl_setopt ( $ch, CURLOPT_VERBOSE, 1 );
curl_setopt ( $ch, CURLOPT_NOPROGRESS, 0 );
curl_setopt ( $ch, CURLOPT_LOW_SPEED_LIMIT, 1 );
curl_setopt ( $ch, CURLOPT_LOW_SPEED_TIME, 600 );
curl_setopt ( $ch, CURLOPT_TIMEOUT, 600 );
set_time_limit( 0 );
$result = curl_exec ( $ch );
if ( $result == CURL_OK ) print_r ( curl_getinfo ( $ch ) );
else print "\n\n-----\n" . "cURL error number:" . curl_errno ( $ch ) . "\n\ncURL error:" . curl_error ( $ch );
curl_close ( $ch );

==============================

i've tried it using 'host name' and 'host ip', and i also have tried it using '1.5.0.0' and older protocol versions

it never works and i allways recieve the next error response:

cURL error number: 51

cURL error: SSL: certificate subject name '********.**********.com' does not match target host name '***.***.***.***'

have you got any idea about what i am doing wrong? can anybody help me?

thank you very much in advance & best regards

fidel
 
hi all,

i autoresponse to myself:

both php are ok (more or less), the problem was with the machine where i was executing these phps from... it had no connection to my plesk servers from there (because of some firewall rules or something like that, i don't exactly know, i'll talk with my system administrator).

i've executed them from another machine and everything worked as expected.

anyway... sorry and thanks!
 
Back
Top