+ while(KeepUpdating == TRUE){
+
+ COConnectResult ConnectResponse = ConnObjectIter->second->Connect(false);
+
+ bool ExitLoop = FALSE;
+
+ while (ExitLoop == FALSE){
+
+ if (ConnObjectIter->second->SSLVerify() == COSSL_UNABLETOVERIFY){
+
+ frmMainPtrGet->PauseAllTimers();
+
+#if defined(__APPLE__)
+
+ ConnObjectIter->second->BypassSSLVerification(true);
+
+ COConnectResult ConnectionSSLResult = ConnObjectIter->second->Connect(false);
+
+ ConnObjectIter->second->BypassSSLVerification(false);
+
+ int SSLResult = DisplayTrustPanel(ConnObjectIter->second->BuildSSLCollection(), AccountNameFriendly);
+
+ if (SSLResult != NSOKButton){
+
+ frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 1, ConnObjectIter->second->BuildSSLCollection());
+ iter->second = 2;
+ break;
+
+ } else {
+
+ frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnObjectIter->second->BuildSSLCollection());
+
+ }
+
+#elif defined(__WIN32__)
+
+ ConnObjectIter->second->BypassSSLVerification(true);
+
+ COConnectResult ConnectionSSLResult = ConnObjectIter->second->Connect(false);
+
+ ConnObjectIter->second->BypassSSLVerification(false);
+
+ BOOL ModifiedCertificateData = false;
+ CRYPTUI_VIEWCERTIFICATE_STRUCTW CertificateData = BuildCertificateData(ConnObjectIter->second, (HWND)frmMainPtrGet->GetHandle());
+
+ if (!CryptUIDlgViewCertificate(&CertificateData, &ModifiedCertificateData)) {
+ wxMessageBox(_("An error occured while trying to open the certificate dialog."), _("Error opening Certificate Information dialog"));
+ }
+
+ if (ModifiedCertificateData == false) {
+
+ frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 1, ConnObjectIter->second->BuildSSLCollection());
+ iter->second = 2;
+ break;
+
+ } else {
+
+ frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnObjectIter->second->BuildSSLCollection());
+
+ }
+
+#else
+
+ bool UsingSSLBypass = false;
+ int SSLResult = 0;
+
+ // Connect again and fetch SSL certificate information.
+
+ ConnObjectIter->second->BypassSSLVerification(true);
+
+ COConnectResult ConnectionSSLResult = ConnObjectIter->second->Connect(false);
+
+ ConnObjectIter->second->BypassSSLVerification(false);
+
+ SSLInvalidCertNotifObjString SSLICNProcData;
+
+ SSLCertCollectionString certcol = ConnObjectIter->second->BuildSSLCollection();
+
+ bool *PauseMode = new bool;
+ QRNotif qrn;
+
+ *PauseMode = TRUE;
+ qrn.QResponse = &SSLResult;
+ qrn.PausePtr = PauseMode;
+
+ SSLICNProcData.CertCollection = certcol;
+ SSLICNProcData.QRNotifData = &qrn;
+ SSLICNProcData.AccountName = AccountNameFriendly;
+
+ wxCommandEvent event(INVALIDSSLCERTSTRING);
+ event.SetClientData(&SSLICNProcData);
+ wxPostEvent(frmMainPtrGet, event);
+
+ while (*PauseMode == TRUE){
+ //nanosleep(&n1, &n2);
+ SleepFor(250000000);
+ }
+
+ // Process the response from the user.
+
+ if (SSLResult == 1){
+
+ // Accept the Certificate.
+
+ UsingSSLBypass = true;
+ ConnObjectIter->second->BypassSSLVerification(true);
+
+ COConnectResult TestConnectionResult = ConnObjectIter->second->Connect(true);
+ WriteServerCertificate(AccountDir, certcol);
+
+ ConnObjectIter->second->BypassSSLVerification(false);
+
+ } else if (SSLResult == 2){
+
+ // Reject the certificate, abort the task and mark as failed.
+
+ iter->second = 2;
+ break;
+
+ }
+
+#endif
+
+ frmMainPtrGet->ResumeAllTimers();
+ ExitLoop = true;
+
+ } else if (ConnectResponse == COCONNECT_AUTHFAIL){
+
+ ConnectResponse = ConnObjectIter->second->Connect(true);
+
+ if (ConnectResponse == COCONNECT_OK){
+
+ ExitLoop = true;
+ break;
+
+ } else {
+
+ ExitLoop = true;
+ iter->second = 2;
+ break;
+
+ }
+
+ } else if (ConnectResponse == COCONNECT_OK){
+
+ ConnectResponse = ConnObjectIter->second->Connect(true);
+
+ ExitLoop = true;
+ break;
+
+ } else {
+
+ ExitLoop = true;
+ iter->second = 2;
+ break;
+
+ }
+
+ }
+
+ if (iter->second == 2 || iter->second == 3 || iter->second == 4){
+ break;
+ }