Отправить запрос по https и ip-адресу сервера

На сайте реализована отправка POST-запроса через curl на ip-адрес сервера. Но запрос отправляется по HTTP без SSL. Как это поправить?

try {
    $ch = curl_init("XXX.XXX.XXX.XXX/{path}");
    if ($ch === false) {
        throw new Exception('failed to initialize');
    }
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Host: ' . $domain));
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($query));
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
    curl_setopt($ch, CURLOPT_TIMEOUT, 30);
    $result = curl_exec($ch);
    // Check the return value of curl_exec(), too
    if ($result === false) {
        throw new Exception(curl_error($ch), curl_errno($ch));
    }
    curl_close($ch);
} catch (Exception $e) {
    trigger_error(sprintf(
        'Curl failed with error #%d: %s',
        $e->getCode(), $e->getMessage()),
        E_USER_ERROR
    );
    exit();
}

Ответы (0 шт):