Added "Allow self signed certificates" setting

Updated recaptcha plugin
This commit is contained in:
RainLoop Team 2015-01-06 01:41:22 +04:00
parent 46187d0749
commit 833f40c115
35 changed files with 363 additions and 273 deletions

View file

@ -136,6 +136,7 @@ class ImapClient extends \MailSo\Net\NetClient
* @param int $iPort = 143
* @param int $iSecurityType = \MailSo\Net\Enumerations\ConnectionSecurityType::AUTO_DETECT
* @param bool $bVerifySsl = false
* @param bool $bAllowSelfSigned = true
*
* @return \MailSo\Imap\ImapClient
*
@ -144,11 +145,12 @@ class ImapClient extends \MailSo\Net\NetClient
* @throws \MailSo\Imap\Exceptions\Exception
*/
public function Connect($sServerName, $iPort = 143,
$iSecurityType = \MailSo\Net\Enumerations\ConnectionSecurityType::AUTO_DETECT, $bVerifySsl = false)
$iSecurityType = \MailSo\Net\Enumerations\ConnectionSecurityType::AUTO_DETECT,
$bVerifySsl = false, $bAllowSelfSigned = true)
{
$this->aTagTimeouts['*'] = \microtime(true);
parent::Connect($sServerName, $iPort, $iSecurityType, $bVerifySsl);
parent::Connect($sServerName, $iPort, $iSecurityType, $bVerifySsl, $bAllowSelfSigned);
$this->parseResponseWithValidation('*', true);

View file

@ -195,6 +195,7 @@ abstract class NetClient
* @param int $iPort
* @param int $iSecurityType = \MailSo\Net\Enumerations\ConnectionSecurityType::AUTO_DETECT
* @param bool $bVerifySsl = false
* @param bool $bAllowSelfSigned = true
*
* @return void
*
@ -203,7 +204,8 @@ abstract class NetClient
* @throws \MailSo\Net\Exceptions\SocketCanNotConnectToHostException
*/
public function Connect($sServerName, $iPort,
$iSecurityType = \MailSo\Net\Enumerations\ConnectionSecurityType::AUTO_DETECT, $bVerifySsl = false)
$iSecurityType = \MailSo\Net\Enumerations\ConnectionSecurityType::AUTO_DETECT,
$bVerifySsl = false, $bAllowSelfSigned = true)
{
if (!\MailSo\Base\Validator::NotEmptyString($sServerName, true) || !\MailSo\Base\Validator::PortInt($iPort))
{
@ -251,12 +253,14 @@ abstract class NetClient
// $iErrorNo, $sErrorStr, $this->iConnectTimeOut);
$bVerifySsl = !!$bVerifySsl;
$bAllowSelfSigned = $bVerifySsl ? !!$bAllowSelfSigned : true;
$aStreamContextSettings = array(
'ssl' => array(
'verify_host' => $bVerifySsl,
'verify_peer' => $bVerifySsl,
'verify_peer_name' => $bVerifySsl,
'allow_self_signed' => !$bVerifySsl
'allow_self_signed' => $bAllowSelfSigned
)
);

View file

@ -63,6 +63,7 @@ class Pop3Client extends \MailSo\Net\NetClient
* @param int $iPort = 110
* @param int $iSecurityType = \MailSo\Net\Enumerations\ConnectionSecurityType::AUTO_DETECT
* @param bool $bVerifySsl = false
* @param bool $bAllowSelfSigned = null
*
* @return \MailSo\Pop3\Pop3Client
*
@ -71,11 +72,13 @@ class Pop3Client extends \MailSo\Net\NetClient
* @throws \MailSo\Pop3\Exceptions\ResponseException
*/
public function Connect($sServerName, $iPort = 110,
$iSecurityType = \MailSo\Net\Enumerations\ConnectionSecurityType::AUTO_DETECT, $bVerifySsl = false)
$iSecurityType = \MailSo\Net\Enumerations\ConnectionSecurityType::AUTO_DETECT,
$bVerifySsl = false, $bAllowSelfSigned = null)
{
$this->iRequestTime = microtime(true);
parent::Connect($sServerName, $iPort, $iSecurityType, $bVerifySsl);
parent::Connect($sServerName, $iPort, $iSecurityType, $bVerifySsl, $bAllowSelfSigned);
$this->validateResponse();
if (\MailSo\Net\Enumerations\ConnectionSecurityType::UseStartTLS(

View file

@ -51,6 +51,7 @@ class PoppassdClient extends \MailSo\Net\NetClient
* @param int $iPort = 106
* @param int $iSecurityType = \MailSo\Net\Enumerations\ConnectionSecurityType::AUTO_DETECT
* @param bool $bVerifySsl = false
* @param bool $bAllowSelfSigned = true
*
* @return \MailSo\Poppassd\PoppassdClient
*
@ -59,11 +60,13 @@ class PoppassdClient extends \MailSo\Net\NetClient
* @throws \MailSo\Poppassd\Exceptions\ResponseException
*/
public function Connect($sServerName, $iPort = 106,
$iSecurityType = \MailSo\Net\Enumerations\ConnectionSecurityType::AUTO_DETECT, $bVerifySsl = false)
$iSecurityType = \MailSo\Net\Enumerations\ConnectionSecurityType::AUTO_DETECT,
$bVerifySsl = false, $bAllowSelfSigned = true)
{
$this->iRequestTime = \microtime(true);
parent::Connect($sServerName, $iPort, $iSecurityType, $bVerifySsl);
parent::Connect($sServerName, $iPort, $iSecurityType, $bVerifySsl, $bAllowSelfSigned);
$this->validateResponse();
return $this;

View file

@ -26,12 +26,12 @@ class ManageSieveClient extends \MailSo\Net\NetClient
* @var array
*/
private $aCapa;
/**
* @var int
*/
private $iRequestTime;
/**
* @access protected
*/
@ -55,7 +55,7 @@ class ManageSieveClient extends \MailSo\Net\NetClient
/**
* @param string $sCapa
*
*
* @return bool
*/
public function IsSupported($sCapa)
@ -72,7 +72,7 @@ class ManageSieveClient extends \MailSo\Net\NetClient
{
return $this->IsSupported('SIEVE') && \in_array(\strtoupper($sModule), $this->aModules);
}
/**
* @param string $sAuth
*
@ -88,6 +88,7 @@ class ManageSieveClient extends \MailSo\Net\NetClient
* @param int $iPort
* @param int $iSecurityType = \MailSo\Net\Enumerations\ConnectionSecurityType::AUTO_DETECT
* @param bool $bVerifySsl = false
* @param bool $bAllowSelfSigned = true
*
* @return \MailSo\Sieve\ManageSieveClient
*
@ -96,12 +97,13 @@ class ManageSieveClient extends \MailSo\Net\NetClient
* @throws \MailSo\Sieve\Exceptions\ResponseException
*/
public function Connect($sServerName, $iPort,
$iSecurityType = \MailSo\Net\Enumerations\ConnectionSecurityType::AUTO_DETECT, $bVerifySsl = false)
$iSecurityType = \MailSo\Net\Enumerations\ConnectionSecurityType::AUTO_DETECT,
$bVerifySsl = false, $bAllowSelfSigned = true)
{
$this->iRequestTime = microtime(true);
parent::Connect($sServerName, $iPort, $iSecurityType, $bVerifySsl);
parent::Connect($sServerName, $iPort, $iSecurityType, $bVerifySsl, $bAllowSelfSigned);
$mResponse = $this->parseResponse();
$this->validateResponse($mResponse);
$this->parseStartupResponse($mResponse);
@ -122,7 +124,7 @@ class ManageSieveClient extends \MailSo\Net\NetClient
new \MailSo\Net\Exceptions\SocketUnsuppoterdSecureConnectionException('STARTTLS is not supported'),
\MailSo\Log\Enumerations\Type::ERROR, true);
}
return $this;
}
@ -254,7 +256,7 @@ class ManageSieveClient extends \MailSo\Net\NetClient
return $aResult;
}
/**
* @return array
*
@ -273,7 +275,7 @@ class ManageSieveClient extends \MailSo\Net\NetClient
/**
* @return \MailSo\Sieve\ManageSieveClient
*
*
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Sieve\Exceptions\NegativeResponseException
*/
@ -286,7 +288,7 @@ class ManageSieveClient extends \MailSo\Net\NetClient
/**
* @param string $sScriptName
*
*
* @return string
*
* @throws \MailSo\Net\Exceptions\Exception
@ -365,10 +367,10 @@ class ManageSieveClient extends \MailSo\Net\NetClient
public function SetActiveScript($sScriptName)
{
$this->sendRequestWithCheck('SETACTIVE "'.$sScriptName.'"');
return $this;
}
/**
* @param string $sScriptName
*
@ -409,7 +411,7 @@ class ManageSieveClient extends \MailSo\Net\NetClient
/**
* @param string $sScriptName
*
*
* @return bool
*
* @throws \MailSo\Net\Exceptions\Exception
@ -419,7 +421,7 @@ class ManageSieveClient extends \MailSo\Net\NetClient
{
return $sScriptName === $this->GetActiveScriptName();
}
/**
* @param string $sLine
* @return array|false
@ -532,7 +534,7 @@ class ManageSieveClient extends \MailSo\Net\NetClient
/**
* @param string $sLine
*
*
* @return string
*/
private function convertEndOfLine($sLine)
@ -560,7 +562,7 @@ class ManageSieveClient extends \MailSo\Net\NetClient
return $sLine;
}
/**
* @return array|bool
*/
@ -572,7 +574,7 @@ class ManageSieveClient extends \MailSo\Net\NetClient
do
{
$this->getNextBuffer();
$sLine = $this->sResponseBuffer;
if (false === $sLine)
{
@ -620,7 +622,7 @@ class ManageSieveClient extends \MailSo\Net\NetClient
/**
* @param \MailSo\Log\Logger $oLogger
*
*
* @return \MailSo\Sieve\ManageSieveClient
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException

View file

@ -129,7 +129,7 @@ class SmtpClient extends \MailSo\Net\NetClient
{
$sEhloHost = empty($_SERVER['HTTP_HOST']) ? '' : \trim($_SERVER['HTTP_HOST']);
}
if (empty($sEhloHost))
{
$sEhloHost = \function_exists('gethostname') ? \gethostname() : 'localhost';
@ -151,6 +151,7 @@ class SmtpClient extends \MailSo\Net\NetClient
* @param string $sEhloHost = '[127.0.0.1]'
* @param int $iSecurityType = \MailSo\Net\Enumerations\ConnectionSecurityType::AUTO_DETECT
* @param bool $bVerifySsl = false
* @param bool $bAllowSelfSigned = true
*
* @return \MailSo\Smtp\SmtpClient
*
@ -159,11 +160,13 @@ class SmtpClient extends \MailSo\Net\NetClient
* @throws \MailSo\Smtp\Exceptions\ResponseException
*/
public function Connect($sServerName, $iPort = 25, $sEhloHost = '[127.0.0.1]',
$iSecurityType = \MailSo\Net\Enumerations\ConnectionSecurityType::AUTO_DETECT, $bVerifySsl = false)
$iSecurityType = \MailSo\Net\Enumerations\ConnectionSecurityType::AUTO_DETECT,
$bVerifySsl = false, $bAllowSelfSigned = true)
{
$this->iRequestTime = microtime(true);
parent::Connect($sServerName, $iPort, $iSecurityType, $bVerifySsl);
parent::Connect($sServerName, $iPort, $iSecurityType, $bVerifySsl, $bAllowSelfSigned);
$this->validateResponse(220);
$this->preLoginStartTLSAndEhloProcess($sEhloHost);
@ -184,7 +187,7 @@ class SmtpClient extends \MailSo\Net\NetClient
public function Login($sLogin, $sPassword)
{
$sLogin = \MailSo\Base\Utils::IdnToAscii($sLogin);
if ($this->IsAuthSupported('LOGIN'))
{
try
@ -313,7 +316,7 @@ class SmtpClient extends \MailSo\Net\NetClient
{
$sFrom = \MailSo\Base\Utils::IdnToAscii($sFrom, true);
$sCmd = 'FROM:<'.$sFrom.'>';
$sSizeIfSupported = (string) $sSizeIfSupported;
if (0 < \strlen($sSizeIfSupported) && \is_numeric($sSizeIfSupported) && $this->IsSupported('SIZE'))
{
@ -538,7 +541,7 @@ class SmtpClient extends \MailSo\Net\NetClient
{
$this->sendRequestWithCheck('STARTTLS', 220);
$this->EnableCrypto();
$this->ehloOrHelo($sEhloHost);
}
else if (\MailSo\Net\Enumerations\ConnectionSecurityType::STARTTLS === $this->iSecurityType)

View file

@ -1247,7 +1247,9 @@ class Actions
$aResult['AdminDomain'] = APP_SITE;
$aResult['UseTokenProtection'] = (bool) $oConfig->Get('security', 'csrf_protection', true);
$aResult['EnabledPlugins'] = (bool) $oConfig->Get('plugins', 'enable', false);
$aResult['VerifySslCertificate'] = !!$oConfig->Get('ssl', 'verify_certificate', false);
$aResult['AllowSelfSigned'] = !!$oConfig->Get('ssl', 'allow_self_signed', true);
$aDrivers = \class_exists('PDO') ? \PDO::getAvailableDrivers() : array();
$aResult['MySqlIsSupported'] = \is_array($aDrivers) ? \in_array('mysql', $aDrivers) : false;
@ -2613,6 +2615,8 @@ class Actions
});
$this->setConfigFromParams($oConfig, 'VerifySslCertificate', 'ssl', 'verify_certificate', 'bool');
$this->setConfigFromParams($oConfig, 'AllowSelfSigned', 'ssl', 'allow_self_signed', 'bool');
$this->setConfigFromParams($oConfig, 'UseLocalProxyForExternalImages', 'labs', 'use_local_proxy_for_external_images', 'bool');
$this->setConfigFromParams($oConfig, 'AllowLanguagesOnSettings', 'webmail', 'allow_languages_on_settings', 'bool');
@ -3100,8 +3104,10 @@ class Actions
$oImapClient->SetTimeOuts($iConnectionTimeout);
$iTime = \microtime(true);
$oImapClient->Connect($oDomain->IncHost(), $oDomain->IncPort(),
$oDomain->IncSecure(), !!$this->Config()->Get('ssl', 'verify_certificate'));
$oImapClient->Connect($oDomain->IncHost(), $oDomain->IncPort(), $oDomain->IncSecure(),
!!$this->Config()->Get('ssl', 'verify_certificate', false),
!!$this->Config()->Get('ssl', 'allow_self_signed', true)
);
$iImapTime = \microtime(true) - $iTime;
$oImapClient->Disconnect();
@ -3139,8 +3145,10 @@ class Actions
$iTime = \microtime(true);
$oSmtpClient->Connect($oDomain->OutHost(), $oDomain->OutPort(),
\MailSo\Smtp\SmtpClient::EhloHelper(),
$oDomain->OutSecure(), !!$this->Config()->Get('ssl', 'verify_certificate'));
\MailSo\Smtp\SmtpClient::EhloHelper(), $oDomain->OutSecure(),
!!$this->Config()->Get('ssl', 'verify_certificate', false),
!!$this->Config()->Get('ssl', 'allow_self_signed', true)
);
$iSmtpTime = \microtime(true) - $iTime;
$oSmtpClient->Disconnect();

View file

@ -122,6 +122,7 @@ class Application extends \RainLoop\Config\AbstractConfig
'ssl' => array(
'verify_certificate' => array(false, 'Require verification of SSL certificate used.'),
'allow_self_signed' => array(true, 'Allow self-signed certificates. Requires verify_certificate.'),
'cafile' => array('', 'Location of Certificate Authority file on local filesystem (/etc/ssl/certs/ca-certificates.crt)'),
'capath' => array('', 'capath must be a correctly hashed certificate directory. (/etc/ssl/certs/)'),
),

View file

@ -346,7 +346,8 @@ class Account extends \RainLoop\Account // for backward compatibility
'Password' => $this->Password(),
'ProxyAuthUser' => $this->ProxyAuthUser(),
'ProxyAuthPassword' => $this->ProxyAuthPassword(),
'VerifySsl' => !!$oConfig->Get('ssl', 'verify_certificate'),
'VerifySsl' => !!$oConfig->Get('ssl', 'verify_certificate', false),
'AllowSelfSigned' => !!$oConfig->Get('ssl', 'allow_self_signed', true),
'UseAuthPlainIfSupported' => !!$oConfig->Get('labs', 'use_imap_auth_plain')
);
@ -358,7 +359,8 @@ class Account extends \RainLoop\Account // for backward compatibility
{
$oMailClient
->Connect($aImapCredentials['Host'], $aImapCredentials['Port'],
$aImapCredentials['Secure'], $aImapCredentials['VerifySsl']);
$aImapCredentials['Secure'], $aImapCredentials['VerifySsl'], $aImapCredentials['AllowSelfSigned']);
}
$oPlugins->RunHook('event.imap-pre-login', array($this, $aImapCredentials['UseAuth'], $aImapCredentials));
@ -410,7 +412,8 @@ class Account extends \RainLoop\Account // for backward compatibility
'Password' => $this->Password(),
'ProxyAuthUser' => $this->ProxyAuthUser(),
'ProxyAuthPassword' => $this->ProxyAuthPassword(),
'VerifySsl' => !!$oConfig->Get('ssl', 'verify_certificate')
'VerifySsl' => !!$oConfig->Get('ssl', 'verify_certificate', false),
'AllowSelfSigned' => !!$oConfig->Get('ssl', 'allow_self_signed', true)
);
$oPlugins->RunHook('filter.smtp-credentials', array($this, &$aSmtpCredentials));
@ -421,8 +424,9 @@ class Account extends \RainLoop\Account // for backward compatibility
if ($aSmtpCredentials['UseConnect'] && !$aSmtpCredentials['UsePhpMail'] && $oSmtpClient)
{
$oSmtpClient->Connect($aSmtpCredentials['Host'], $aSmtpCredentials['Port'],
$aSmtpCredentials['Ehlo'], $aSmtpCredentials['Secure'], $aSmtpCredentials['VerifySsl']);
$oSmtpClient->Connect($aSmtpCredentials['Host'], $aSmtpCredentials['Port'], $aSmtpCredentials['Ehlo'],
$aSmtpCredentials['Secure'], $aSmtpCredentials['VerifySsl'], $aSmtpCredentials['AllowSelfSigned']
);
}
$oPlugins->RunHook('event.smtp-post-connect', array($this, $aSmtpCredentials['UseConnect'], $aSmtpCredentials));

View file

@ -171,7 +171,9 @@ class Manager
\file_exists($sPathName.'/index.php'))
{
$aList[] = array(
$sName, @\file_get_contents($sPathName.'/VERSION')
$sName,
\file_exists($sPathName.'/VERSION') ?
\file_get_contents($sPathName.'/VERSION') : '0.0'
);
}
}

View file

@ -31,17 +31,36 @@
</div>
<div class="control-group">
<div class="controls">
<div data-bind="component: {
name: 'Checkbox',
params: { value: verifySslCertificate, label: 'Require verification of SSL certificate used (IMAP/SMTP)', inline: true }
}"></div>
&nbsp;&nbsp;
<span style="color:red">(unstable)</span>
<a href="#" target="_blank" class="g-ui-link" data-bind="link: phpInfoLink()">Show PHP information</a>
</div>
</div>
</div>
<div class="form-horizontal">
<div class="legend">
SSL
</div>
<div class="control-group">
<div class="controls">
<a href="#" target="_blank" class="g-ui-link" data-bind="link: phpInfoLink()">Show PHP information</a>
<div data-bind="component: {
name: 'Checkbox',
params: {
value: verifySslCertificate,
label: 'Require verification of SSL certificate used (IMAP/SMTP)',
inline: true
}
}"></div>
&nbsp;&nbsp;
<span style="color:red">(unstable)</span>
<br />
<div data-bind="component: {
name: 'Checkbox',
params: {
enable: verifySslCertificate,
value: allowSelfSigned,
label: 'Allow self signed certificates'
}
}"></div>
</div>
</div>
</div>