Added "Verify ssl certificate" setting in domain configuration popup (Closes #332)

This commit is contained in:
RainLoop Team 2014-10-07 01:47:21 +04:00
parent c8bd765e12
commit 49f6c8bbe9
11 changed files with 87 additions and 34 deletions

View file

@ -210,8 +210,8 @@
};
RemoteAdminStorage.prototype.createOrUpdateDomain = function (fCallback,
bCreate, sName, sIncHost, iIncPort, sIncSecure, bIncShortLogin,
sOutHost, iOutPort, sOutSecure, bOutShortLogin, bOutAuth, sWhiteList)
bCreate, sName, sIncHost, iIncPort, sIncSecure, bIncVerifySsl, bIncShortLogin,
sOutHost, iOutPort, sOutSecure, bOutShortLogin, bOutVerifySsl, bOutAuth, sWhiteList)
{
this.defaultRequest(fCallback, 'AdminDomainSave', {
'Create': bCreate ? '1' : '0',
@ -219,10 +219,12 @@
'IncHost': sIncHost,
'IncPort': iIncPort,
'IncSecure': sIncSecure,
'IncVerifySsl': bIncVerifySsl ? '1' : '0',
'IncShortLogin': bIncShortLogin ? '1' : '0',
'OutHost': sOutHost,
'OutPort': iOutPort,
'OutSecure': sOutSecure,
'OutVerifySsl': bOutVerifySsl ? '1' : '0',
'OutShortLogin': bOutShortLogin ? '1' : '0',
'OutAuth': bOutAuth ? '1' : '0',
'WhiteList': sWhiteList
@ -230,17 +232,19 @@
};
RemoteAdminStorage.prototype.testConnectionForDomain = function (fCallback, sName,
sIncHost, iIncPort, sIncSecure,
sOutHost, iOutPort, sOutSecure, bOutAuth)
sIncHost, iIncPort, sIncSecure, bIncVerifySsl,
sOutHost, iOutPort, sOutSecure, bOutVerifySsl, bOutAuth)
{
this.defaultRequest(fCallback, 'AdminDomainTest', {
'Name': sName,
'IncHost': sIncHost,
'IncPort': iIncPort,
'IncSecure': sIncSecure,
'IncVerifySsl': bIncVerifySsl ? '1' : '0',
'OutHost': sOutHost,
'OutPort': iOutPort,
'OutSecure': sOutSecure,
'OutVerifySsl': bOutVerifySsl ? '1' : '0',
'OutAuth': bOutAuth ? '1' : '0'
});
};

View file

@ -63,10 +63,12 @@
this.imapServer = ko.observable('');
this.imapPort = ko.observable('' + Consts.Values.ImapDefaulPort);
this.imapSecure = ko.observable(Enums.ServerSecure.None);
this.imapVerifySsl = ko.observable(false);
this.imapShortLogin = ko.observable(false);
this.smtpServer = ko.observable('');
this.smtpPort = ko.observable('' + Consts.Values.SmtpDefaulPort);
this.smtpSecure = ko.observable(Enums.ServerSecure.None);
this.smtpVerifySsl = ko.observable(false);
this.smtpShortLogin = ko.observable(false);
this.smtpAuth = ko.observable(true);
this.whiteList = ko.observable('');
@ -102,10 +104,12 @@
this.imapServer(),
Utils.pInt(this.imapPort()),
this.imapSecure(),
this.imapVerifySsl(),
this.imapShortLogin(),
this.smtpServer(),
Utils.pInt(this.smtpPort()),
this.smtpSecure(),
this.smtpVerifySsl(),
this.smtpShortLogin(),
this.smtpAuth(),
this.whiteList()
@ -124,9 +128,11 @@
this.imapServer(),
Utils.pInt(this.imapPort()),
this.imapSecure(),
this.imapVerifySsl(),
this.smtpServer(),
Utils.pInt(this.smtpPort()),
this.smtpSecure(),
this.smtpVerifySsl(),
this.smtpAuth()
);
}, this.canBeTested);
@ -273,10 +279,12 @@
this.imapServer(Utils.trim(oDomain.IncHost));
this.imapPort('' + Utils.pInt(oDomain.IncPort));
this.imapSecure(Utils.trim(oDomain.IncSecure));
this.imapVerifySsl(!!oDomain.IncVerifySsl);
this.imapShortLogin(!!oDomain.IncShortLogin);
this.smtpServer(Utils.trim(oDomain.OutHost));
this.smtpPort('' + Utils.pInt(oDomain.OutPort));
this.smtpSecure(Utils.trim(oDomain.OutSecure));
this.smtpVerifySsl(!!oDomain.OutVerifySsl);
this.smtpShortLogin(!!oDomain.OutShortLogin);
this.smtpAuth(!!oDomain.OutAuth);
this.whiteList(Utils.trim(oDomain.WhiteList));
@ -304,10 +312,12 @@
this.imapServer('');
this.imapPort('' + Consts.Values.ImapDefaulPort);
this.imapSecure(Enums.ServerSecure.None);
this.imapVerifySsl(false);
this.imapShortLogin(false);
this.smtpServer('');
this.smtpPort('' + Consts.Values.SmtpDefaulPort);
this.smtpSecure(Enums.ServerSecure.None);
this.smtpVerifySsl(false);
this.smtpShortLogin(false);
this.smtpAuth(true);
this.whiteList('');

View file

@ -1,7 +1,9 @@
imap_host = "imap.gmail.com"
imap_port = 993
imap_secure = "SSL"
imap_verify_ssl = Off
smtp_host = "smtp.gmail.com"
smtp_port = 465
smtp_secure = "SSL"
smtp_verify_ssl = Off
smtp_auth = On

View file

@ -1,7 +1,9 @@
imap_host = "imap-mail.outlook.com"
imap_port = 993
imap_secure = "SSL"
imap_verify_ssl = Off
smtp_host = "smtp-mail.outlook.com"
smtp_port = 587
smtp_secure = "TLS"
smtp_verify_ssl = Off
smtp_auth = On

View file

@ -1,7 +1,9 @@
imap_host = "imap.qq.com"
imap_port = 993
imap_secure = "SSL"
imap_verify_ssl = Off
smtp_host = "smtp.qq.com"
smtp_port = 465
smtp_secure = "SSL"
smtp_verify_ssl = Off
smtp_auth = On

View file

@ -1,7 +1,9 @@
imap_host = "imap.mail.yahoo.com"
imap_port = 993
imap_secure = "SSL"
imap_verify_ssl = Off
smtp_host = "smtp.mail.yahoo.com"
smtp_port = 465
smtp_secure = "SSL"
smtp_verify_ssl = Off
smtp_auth = On

View file

@ -123,6 +123,7 @@ class Utils
*/
public static function ConvertSystemString($sSrt)
{
$sSrt = \trim($sSrt);
if (!empty($sSrt) && !\MailSo\Base\Utils::IsUtf8($sSrt))
{
$sCharset = \MailSo\Base\Utils::DetectSystemCharset();
@ -282,7 +283,7 @@ class Utils
// {
// $sIconvOptions .= '//TRANSLIT';
// }
$mResult = @\iconv(\strtoupper($sInputFromEncoding), \strtoupper($sInputToEncoding).$sIconvOptions, $sInputString);
if (false === $mResult)
{
@ -430,7 +431,7 @@ class Utils
{
return true;
}
return !\preg_match('/[^\x09\x10\x13\x0A\x0D\x20-\x7E]/', $sValue);
}
@ -521,7 +522,7 @@ class Utils
{
$sIncomingCharset = \MailSo\Base\Enumerations\Charset::UTF_8;
}
$sValue = \MailSo\Base\Utils::ConvertEncoding($sValue, $sIncomingCharset,
\MailSo\Base\Enumerations\Charset::UTF_8);
}
@ -614,7 +615,7 @@ class Utils
{
$aParts[$iIndex][2] = \MailSo\Base\Enumerations\Charset::UTF_8;
}
$sValue = \str_replace($aParts[$iIndex][0],
\MailSo\Base\Utils::ConvertEncoding($aParts[$iIndex][1], $aParts[$iIndex][2], \MailSo\Base\Enumerations\Charset::UTF_8),
$sValue);
@ -627,7 +628,7 @@ class Utils
{
$sMainCharset = \MailSo\Base\Enumerations\Charset::UTF_8;
}
$sValue = \MailSo\Base\Utils::ConvertEncoding($sValue, $sMainCharset, \MailSo\Base\Enumerations\Charset::UTF_8);
}
@ -712,7 +713,7 @@ class Utils
$iNlen = \strlen($sAttrName);
$iVlen = \strlen($sValue);
if (\strlen($sAttrName) + $iVlen > $iLen - 3)
{
$sections = array();
@ -728,7 +729,7 @@ class Utils
{
$sections[$i] = ' '.$sAttrName.'*'.$i.'*='.$sections[$i];
}
return \implode(";\r\n", $sections);
}
else
@ -746,7 +747,7 @@ class Utils
{
$sAttrName = \trim($sAttrName);
$sValue = \trim($sValue);
if (0 < \strlen($sValue) && !\MailSo\Base\Utils::IsAscii($sValue))
{
if (!empty($_SERVER['HTTP_USER_AGENT']) && 0 < \strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE'))

View file

@ -220,10 +220,10 @@ abstract class NetClient
$this->iSecurityType = $iSecurityType;
$this->bSecure = \MailSo\Net\Enumerations\ConnectionSecurityType::UseSSL(
$this->iConnectedPort, $this->iSecurityType);
$this->sConnectedHost = \in_array(\strtolower(\substr($this->sConnectedHost, 0, 6)), array('ssl://', 'tcp://')) ?
\substr($this->sConnectedHost, 6) : $this->sConnectedHost;
$this->sConnectedHost = ($this->bSecure ? 'ssl://' : 'tcp://').$this->sConnectedHost;
// $this->sConnectedHost = ($this->bSecure ? 'ssl://' : '').$this->sConnectedHost;
@ -546,7 +546,7 @@ abstract class NetClient
{
$this->oLogger->Write('Socket: ['.$oException->getSocketCode().'] '.$oException->getSocketMessage(), $iDescType, $this->getLogName());
}
$this->oLogger->WriteException($oException, $iDescType, $this->getLogName());
}

View file

@ -78,27 +78,29 @@ class Domain
* @param string $sIncHost
* @param int $iIncPort
* @param int $iIncSecure
* @param bool $bIncVerifySsl
* @param bool $bIncShortLogin
* @param string $sOutHost
* @param int $iOutPort
* @param int $iOutSecure
* @param bool $bOutVerifySsl
* @param bool $bOutShortLogin
* @param bool $bOutAuth
* @param string $sWhiteList = ''
*/
private function __construct($sName, $sIncHost, $iIncPort, $iIncSecure, $bIncShortLogin,
$sOutHost, $iOutPort, $iOutSecure, $bOutShortLogin, $bOutAuth, $sWhiteList = '')
private function __construct($sName, $sIncHost, $iIncPort, $iIncSecure, $bIncVerifySsl, $bIncShortLogin,
$sOutHost, $iOutPort, $iOutSecure, $bOutVerifySsl, $bOutShortLogin, $bOutAuth, $sWhiteList = '')
{
$this->sName = $sName;
$this->sIncHost = $sIncHost;
$this->iIncPort = $iIncPort;
$this->iIncSecure = $iIncSecure;
$this->bIncVerifySsl = false;
$this->bIncVerifySsl = !!$bIncVerifySsl;
$this->bIncShortLogin = $bIncShortLogin;
$this->sOutHost = $sOutHost;
$this->iOutPort = $iOutPort;
$this->iOutSecure = $iOutSecure;
$this->bOutVerifySsl = false;
$this->bOutVerifySsl = !!$bOutVerifySsl;
$this->bOutShortLogin = $bOutShortLogin;
$this->bOutAuth = $bOutAuth;
$this->sWhiteList = \trim($sWhiteList);
@ -109,10 +111,12 @@ class Domain
* @param string $sIncHost
* @param int $iIncPort
* @param int $iIncSecure
* @param bool $bIncVerifySsl
* @param bool $bIncShortLogin
* @param string $sOutHost
* @param int $iOutPort
* @param int $iOutSecure
* @param bool $bOutVerifySsl
* @param bool $bOutShortLogin
* @param bool $bOutAuth
* @param string $sWhiteList = ''
@ -120,13 +124,13 @@ class Domain
* @return \RainLoop\Domain
*/
public static function NewInstance($sName,
$sIncHost, $iIncPort, $iIncSecure, $bIncShortLogin,
$sOutHost, $iOutPort, $iOutSecure, $bOutShortLogin, $bOutAuth,
$sIncHost, $iIncPort, $iIncSecure, $bIncVerifySsl, $bIncShortLogin,
$sOutHost, $iOutPort, $iOutSecure, $bOutVerifySsl, $bOutShortLogin, $bOutAuth,
$sWhiteList = '')
{
return new self($sName,
$sIncHost, $iIncPort, $iIncSecure, $bIncShortLogin,
$sOutHost, $iOutPort, $iOutSecure, $bOutShortLogin, $bOutAuth,
$sIncHost, $iIncPort, $iIncSecure, $bIncVerifySsl, $bIncShortLogin,
$sOutHost, $iOutPort, $iOutSecure, $bOutVerifySsl, $bOutShortLogin, $bOutAuth,
$sWhiteList);
}
@ -148,11 +152,15 @@ class Domain
$iIncSecure = self::StrConnectionSecurityTypeToCons(
!empty($aDomain['imap_secure']) ? $aDomain['imap_secure'] : '');
$bIncVerifySsl = isset($aDomain['imap_verify_ssl']) ? (bool) $aDomain['smtp_verify_ssl'] : false;;
$sOutHost = (string) $aDomain['smtp_host'];
$iOutPort = (int) $aDomain['smtp_port'];
$iOutSecure = self::StrConnectionSecurityTypeToCons(
!empty($aDomain['smtp_secure']) ? $aDomain['smtp_secure'] : '');
$bOutVerifySsl = isset($aDomain['smtp_verify_ssl']) ? (bool) $aDomain['smtp_verify_ssl'] : false;
$bOutAuth = isset($aDomain['smtp_auth']) ? (bool) $aDomain['smtp_auth'] : true;
$sWhiteList = (string) (isset($aDomain['white_list']) ? $aDomain['white_list'] : '');
@ -160,8 +168,8 @@ class Domain
$bOutShortLogin = isset($aDomain['smtp_short_login']) ? (bool) $aDomain['smtp_short_login'] : false;
$oDomain = self::NewInstance($sName,
$sIncHost, $iIncPort, $iIncSecure, $bIncShortLogin,
$sOutHost, $iOutPort, $iOutSecure, $bOutShortLogin, $bOutAuth,
$sIncHost, $iIncPort, $iIncSecure, $bIncVerifySsl, $bIncShortLogin,
$sOutHost, $iOutPort, $iOutSecure, $bOutVerifySsl, $bOutShortLogin, $bOutAuth,
$sWhiteList);
}
@ -183,7 +191,7 @@ class Domain
$this->sIncHost = \trim($this->sIncHost);
$this->sOutHost = \trim($this->sOutHost);
$this->sWhiteList = \trim($this->sWhiteList);
if ($this->iIncPort <= 0)
{
$this->iIncPort = 143;
@ -194,7 +202,7 @@ class Domain
$this->iOutPort = 25;
}
}
/**
* @return string
*/
@ -205,10 +213,12 @@ class Domain
'imap_host = "'.$this->encodeIniString($this->sIncHost).'"',
'imap_port = '.$this->iIncPort,
'imap_secure = "'.self::ConstConnectionSecurityTypeToStr($this->iIncSecure).'"',
'imap_verify_ssl = '.($this->bIncVerifySsl ? 'On' : 'Off'),
'imap_short_login = '.($this->bIncShortLogin ? 'On' : 'Off'),
'smtp_host = "'.$this->encodeIniString($this->sOutHost).'"',
'smtp_port = '.$this->iOutPort,
'smtp_secure = "'.self::ConstConnectionSecurityTypeToStr($this->iOutSecure).'"',
'smtp_verify_ssl = '.($this->bOutVerifySsl ? 'On' : 'Off'),
'smtp_short_login = '.($this->bOutShortLogin ? 'On' : 'Off'),
'smtp_auth = '.($this->bOutAuth ? 'On' : 'Off'),
'white_list = "'.$this->encodeIniString($this->sWhiteList).'"'
@ -260,10 +270,12 @@ class Domain
* @param string $sIncHost
* @param int $iIncPort
* @param int $iIncSecure
* @param bool $bIncVerifySsl
* @param bool $bIncShortLogin
* @param string $sOutHost
* @param int $iOutPort
* @param int $iOutSecure
* @param bool $bOutVerifySsl
* @param bool $bOutShortLogin
* @param bool $bOutAuth
* @param string $sWhiteList = ''
@ -271,17 +283,19 @@ class Domain
* @return \RainLoop\Domain
*/
public function UpdateInstance(
$sIncHost, $iIncPort, $iIncSecure, $bIncShortLogin,
$sOutHost, $iOutPort, $iOutSecure, $bOutShortLogin, $bOutAuth,
$sIncHost, $iIncPort, $iIncSecure, $bIncVerifySsl, $bIncShortLogin,
$sOutHost, $iOutPort, $iOutSecure, $bOutVerifySsl, $bOutShortLogin, $bOutAuth,
$sWhiteList = '')
{
$this->sIncHost = \MailSo\Base\Utils::IdnToAscii($sIncHost);
$this->iIncPort = $iIncPort;
$this->iIncSecure = $iIncSecure;
$this->bIncVerifySsl = !!$bIncVerifySsl;
$this->bIncShortLogin = $bIncShortLogin;
$this->sOutHost = \MailSo\Base\Utils::IdnToAscii($sOutHost);
$this->iOutPort = $iOutPort;
$this->iOutSecure = $iOutSecure;
$this->bOutVerifySsl = !!$bOutVerifySsl;
$this->bOutShortLogin = $bOutShortLogin;
$this->bOutAuth = $bOutAuth;
$this->sWhiteList = \trim($sWhiteList);
@ -299,7 +313,7 @@ class Domain
/**
* @param string $sRealDomainName = ''
*
*
* @return string
*/
public function IncHost($sRealDomainName = '')
@ -432,10 +446,12 @@ class Domain
'IncHost' => $bAjax ? \MailSo\Base\Utils::IdnToUtf8($this->IncHost()) : $this->IncHost(),
'IncPort' => $this->IncPort(),
'IncSecure' => $this->IncSecure(),
'IncVerifySsl' => $this->IncVerifySsl(),
'IncShortLogin' => $this->IncShortLogin(),
'OutHost' => $bAjax ? \MailSo\Base\Utils::IdnToUtf8($this->OutHost()) : $this->OutHost(),
'OutPort' => $this->OutPort(),
'OutSecure' => $this->OutSecure(),
'OutVerifySsl' => $this->OutVerifySsl(),
'OutShortLogin' => $this->OutShortLogin(),
'OutAuth' => $this->OutAuth(),
'WhiteList' => $this->WhiteList()

View file

@ -115,10 +115,12 @@ class Domain extends \RainLoop\Providers\AbstractProvider
$sIncHost = (string) $oActions->GetActionParam('IncHost', '');
$iIncPort = (int) $oActions->GetActionParam('IncPort', 143);
$iIncSecure = (int) $oActions->GetActionParam('IncSecure', \MailSo\Net\Enumerations\ConnectionSecurityType::NONE);
$bIncVerifySsl = '1' === (string) $oActions->GetActionParam('IncVerifySsl', '0');
$bIncShortLogin = '1' === (string) $oActions->GetActionParam('IncShortLogin', '0');
$sOutHost = (string) $oActions->GetActionParam('OutHost', '');
$iOutPort = (int) $oActions->GetActionParam('OutPort', 25);
$iOutSecure = (int) $oActions->GetActionParam('OutSecure', \MailSo\Net\Enumerations\ConnectionSecurityType::NONE);
$bOutVerifySsl = '1' === (string) $oActions->GetActionParam('OutVerifySsl', '0');
$bOutShortLogin = '1' === (string) $oActions->GetActionParam('OutShortLogin', '0');
$bOutAuth = '1' === (string) $oActions->GetActionParam('OutAuth', '1');
$sWhiteList = (string) $oActions->GetActionParam('WhiteList', '');
@ -140,16 +142,16 @@ class Domain extends \RainLoop\Providers\AbstractProvider
else
{
$oDomain->UpdateInstance(
$sIncHost, $iIncPort, $iIncSecure, $bIncShortLogin,
$sOutHost, $iOutPort, $iOutSecure, $bOutShortLogin, $bOutAuth,
$sIncHost, $iIncPort, $iIncSecure, $bIncVerifySsl, $bIncShortLogin,
$sOutHost, $iOutPort, $iOutSecure, $bOutVerifySsl, $bOutShortLogin, $bOutAuth,
$sWhiteList);
}
}
else
{
$oDomain = \RainLoop\Domain::NewInstance(0 < strlen($sNameForTest) ? $sNameForTest : $sName,
$sIncHost, $iIncPort, $iIncSecure, $bIncShortLogin,
$sOutHost, $iOutPort, $iOutSecure, $bOutShortLogin, $bOutAuth,
$sIncHost, $iIncPort, $iIncSecure, $bIncVerifySsl, $bIncShortLogin,
$sOutHost, $iOutPort, $iOutSecure, $bOutVerifySsl, $bOutShortLogin, $bOutAuth,
$sWhiteList);
}
}

View file

@ -47,6 +47,12 @@
<option value="1">SSL/TLS</option>
<option value="2">STARTTLS</option>
</select>
&nbsp;&nbsp;&nbsp;&nbsp;
<label class="inline" data-bind="visible: '1' === imapSecure(), click: function () { imapVerifySsl(!imapVerifySsl()); }">
<i data-bind="css: imapVerifySsl() ? 'icon-checkbox-checked' : 'icon-checkbox-unchecked'"></i>
&nbsp;&nbsp;
Verify ssl certificate
</label>
</div>
</div>
<br />
@ -88,6 +94,12 @@
<option value="1">SSL/TLS</option>
<option value="2">STARTTLS</option>
</select>
&nbsp;&nbsp;&nbsp;&nbsp;
<label class="inline" data-bind="visible: '1' === smtpSecure(), click: function () { smtpVerifySsl(!smtpVerifySsl()); }">
<i data-bind="css: smtpVerifySsl() ? 'icon-checkbox-checked' : 'icon-checkbox-unchecked'"></i>
&nbsp;&nbsp;
Verify ssl certificate
</label>
</div>
</div>
<br />