зеркало из https://github.com/mozilla/pjs.git
fix STARTTLS handling, sr=mscott 325379
This commit is contained in:
Родитель
b2ca71d56f
Коммит
89ca85aaa9
|
@ -190,6 +190,10 @@ NS_IMETHODIMP nsImapIncomingServer::SetKey(const char * aKey) // override nsMsg
|
|||
if (otherUsersNamespace && PL_strlen(otherUsersNamespace))
|
||||
hostSession->SetNamespaceFromPrefForHost(aKey, otherUsersNamespace,
|
||||
kOtherUsersNamespace);
|
||||
PRInt32 capability;
|
||||
rv = GetCapabilityPref(&capability);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
hostSession->SetCapabilityForHost(aKey, capability);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
|
|
@ -723,7 +723,6 @@ nsresult nsImapProtocol::SetupWithUrl(nsIURI * aURL, nsISupports* aConsumer)
|
|||
PRUint32 capability = kCapabilityUndefined;
|
||||
|
||||
m_hostSessionList->GetCapabilityForHost(GetImapServerKey(), capability);
|
||||
GetServerStateParser().SetCapabilityFlag(capability);
|
||||
|
||||
PRBool shuttingDown;
|
||||
(void) server->GetUseSecAuth(&m_useSecAuth);
|
||||
|
@ -798,10 +797,13 @@ nsresult nsImapProtocol::SetupWithUrl(nsIURI * aURL, nsISupports* aConsumer)
|
|||
if (NS_FAILED(rv) && m_socketType == nsIMsgIncomingServer::tryTLS)
|
||||
{
|
||||
connectionType = nsnull;
|
||||
m_socketType = nsIMsgIncomingServer::defaultSocket;
|
||||
rv = socketService->CreateTransport(&connectionType, connectionType != nsnull,
|
||||
*socketHost, socketPort, proxyInfo,
|
||||
getter_AddRefs(m_transport));
|
||||
}
|
||||
// remember so we can know whether we can issue a start tls or not...
|
||||
m_connectionType = connectionType;
|
||||
if (m_transport && m_mockChannel)
|
||||
{
|
||||
// Ensure that the socket can get the notification callbacks
|
||||
|
@ -1370,7 +1372,8 @@ PRBool nsImapProtocol::ProcessCurrentURL()
|
|||
}
|
||||
else
|
||||
{
|
||||
if ((m_socketType == nsIMsgIncomingServer::tryTLS
|
||||
if (m_connectionType.Equals("starttls")
|
||||
&& (m_socketType == nsIMsgIncomingServer::tryTLS
|
||||
&& (GetServerStateParser().GetCapabilityFlag() & kHasStartTLSCapability))
|
||||
|| m_socketType == nsIMsgIncomingServer::alwaysUseTLS)
|
||||
{
|
||||
|
@ -1391,7 +1394,20 @@ PRBool nsImapProtocol::ProcessCurrentURL()
|
|||
{
|
||||
rv = sslControl->StartTLS();
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
Capability();
|
||||
PRInt32 capabilityFlag = GetServerStateParser().GetCapabilityFlag();
|
||||
// Courier imap doesn't return STARTTLS capability if we've done
|
||||
// a STARTTLS! But we need to remember this capability so we'll
|
||||
// try to use STARTTLS next time.
|
||||
if (!(capabilityFlag & kHasStartTLSCapability))
|
||||
{
|
||||
capabilityFlag |= kHasStartTLSCapability;
|
||||
GetServerStateParser().SetCapabilityFlag(capabilityFlag);
|
||||
m_hostSessionList->SetCapabilityForHost(GetImapServerKey(), capabilityFlag);
|
||||
CommitCapability();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (NS_FAILED(rv))
|
||||
|
@ -1412,7 +1428,14 @@ PRBool nsImapProtocol::ProcessCurrentURL()
|
|||
m_transport->Close(rv);
|
||||
}
|
||||
}
|
||||
|
||||
// in this case, we didn't know the server supported TLS when
|
||||
// we created the socket, so we're going to retry with
|
||||
// STARTTLS.
|
||||
else if (m_socketType == nsIMsgIncomingServer::tryTLS
|
||||
&& (GetServerStateParser().GetCapabilityFlag() & kHasStartTLSCapability))
|
||||
{
|
||||
return RetryUrl();
|
||||
}
|
||||
logonFailed = !TryToLogon();
|
||||
}
|
||||
} // if death signal not received
|
||||
|
|
|
@ -367,7 +367,8 @@ private:
|
|||
PRBool m_imapThreadIsRunning;
|
||||
void ImapThreadMainLoop(void);
|
||||
PRInt32 m_connectionStatus;
|
||||
|
||||
nsCString m_connectionType;
|
||||
|
||||
PRBool m_nextUrlReadyToRun;
|
||||
nsWeakPtr m_server;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче