Answer the question
In order to leave comments, you need to log in
When checking some domains for SSL, the PHP script gets stuck in a loop. Can you help with a question?
I'm new to PHP, I wrote a simple script to check domains for SSL, but when checking some sites (for example, site.com), the script loops or something and the response is quite long.
Script code:
//Сбор информации с формы
echo '<pre>';
$forma = explode("\n", $_GET[textarea]);// считываем значения с формы построчно
foreach($forma as $domens){// элементы массива присваиваем переменной $domens
$punyc = rtrim($domens);// удаляем лишний пробел, на который я потратил уйму времени, чтобы его заметить :)
$domen = idn_to_ascii($punyc);// кодирует кириллическе домены в punycode
$http_url = "http://".$domen;
$https_url = "https://".$domen;
//Curl - запрос
$curl_start = curl_init($https_url); //Инициируем работу cUrl
curl_setopt($curl_start, CURLOPT_RETURNTRANSFER, true); //Отключаем выхлоп от "curl_exec" на экран
curl_setopt($curl_start, CURLOPT_CERTINFO, 1); // Врубаем выхлоп certinfo
curl_setopt($curl_start, CURLOPT_SSL_VERIFYPEER, true); //Результат проверки SSL-сертификата
curl_setopt($curl_start, CURLOPT_SSL_VERIFYHOST, 2);
curl_exec($curl_start);
$curl_info = curl_getinfo($curl_start); //Сбор необходимой информации
$curl_code = $curl_info["http_code"]; //Код ответа сервера
$curl_url = $curl_info["url"]; //URL указанный в форме, но с http:// - добавляется cUrl'ом
$curl_redirect = $curl_info["redirect_url"]; //Редирект, если таковой есть
#var_dump ($curl_info);
$null_redirect = $curl_redirect == ""; //Если редирект с https:// никуда не выполняется
if ($null_redirect !== ""){
switch ($curl_redirect) {
case $null_redirect:
echo "Редиректа нет";
break;
case $curl_redirect:
echo "Выполняется редирект на '$curl_redirect'";
break;
}
}
$curl_ssl = $curl_info["certinfo"];
foreach ($curl_ssl as $ssl){
$ssl_info = $ssl['Issuer'];
$ssl_start = $ssl["Start date"];
$ssl_expire = $ssl["Expire date"];
echo "Домен: <b>$https_url</b>, \n";
echo "Информация о сертификате $ssl_info, \n";
echo "Выпущен $ssl_start, \n";
echo "Истекает $ssl_expire, \n";
var_dump ($domen);
}
curl_close($curl_start);
}
connect(5, {sa_family=AF_INET, sin_port=htons(443), sin_addr=inet_addr("204.74.99.100")}, 16) = -1 EINPROGRESS (Operation now in progress)
poll([{fd=5, events=POLLOUT|POLLWRNORM}], 1, 0) = 0 (Timeout)
rt_sigaction(SIGPIPE, {sa_handler=SIG_IGN, sa_mask=[PIPE], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7f4458429040}, NULL, 8) = 0
poll([{fd=5, events=POLLOUT}], 1, 199) = 0 (Timeout)
rt_sigaction(SIGPIPE, NULL, {sa_handler=SIG_IGN, sa_mask=[PIPE], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7f4458429040}, 8) = 0
rt_sigaction(SIGPIPE, {sa_handler=SIG_IGN, sa_mask=[PIPE], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7f4458429040}, NULL, 8) = 0
poll([{fd=5, events=POLLOUT|POLLWRNORM}], 1, 0) = 0 (Timeout)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question