mirror of
https://github.com/friendica/friendica
synced 2025-04-28 19:44:23 +02:00
Improved check for invalid certificates
This commit is contained in:
parent
896fd3fc91
commit
abe3fd7605
4 changed files with 25 additions and 41 deletions
|
@ -68,6 +68,13 @@ class HttpClient implements ICanSendHttpRequests
|
|||
$this->profiler->startRecording('network');
|
||||
$this->logger->debug('Request start.', ['url' => $url, 'method' => $method]);
|
||||
|
||||
$host = parse_url($url, PHP_URL_HOST);
|
||||
if(!filter_var($host, FILTER_VALIDATE_IP) && !@dns_get_record($host . '.', DNS_A + DNS_AAAA)) {
|
||||
$this->logger->debug('URL cannot be resolved.', ['url' => $url, 'callstack' => System::callstack(20)]);
|
||||
$this->profiler->stopRecording();
|
||||
return CurlResult::createErrorCurl($url);
|
||||
}
|
||||
|
||||
if (Network::isLocalLink($url)) {
|
||||
$this->logger->info('Local link', ['url' => $url, 'callstack' => System::callstack(20)]);
|
||||
}
|
||||
|
@ -125,6 +132,10 @@ class HttpClient implements ICanSendHttpRequests
|
|||
$conf[RequestOptions::TIMEOUT] = $opts[HttpClientOptions::TIMEOUT];
|
||||
}
|
||||
|
||||
if (isset($opts[HttpClientOptions::VERIFY])) {
|
||||
$conf[RequestOptions::VERIFY] = $opts[HttpClientOptions::VERIFY];
|
||||
}
|
||||
|
||||
if (!empty($opts[HttpClientOptions::BODY])) {
|
||||
$conf[RequestOptions::BODY] = $opts[HttpClientOptions::BODY];
|
||||
}
|
||||
|
|
|
@ -52,6 +52,12 @@ class HttpClientOptions
|
|||
* content_length: (int) maximum File content length
|
||||
*/
|
||||
const CONTENT_LENGTH = 'content_length';
|
||||
|
||||
/**
|
||||
* verify: (bool|string, default=true) Describes the SSL certificate
|
||||
*/
|
||||
const VERIFY = 'verify';
|
||||
|
||||
/**
|
||||
* body: (mixed) Setting the body for sending data
|
||||
*/
|
||||
|
|
|
@ -167,6 +167,10 @@ class CurlResult implements ICanHandleHttpResponses
|
|||
$this->isSuccess = false;
|
||||
}
|
||||
|
||||
if (empty($this->returnCode) && empty($this->header) && empty($this->body)) {
|
||||
$this->isSuccess = false;
|
||||
}
|
||||
|
||||
if (!$this->isSuccess) {
|
||||
Logger::debug('debug', ['info' => $this->info]);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue