Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Bring up Invalid SSL Certificate Dialog when creating an account (incomplete)
[xestiaab/.git] / source / frmNewAccount.cpp
index 1681134..4eb1259 100644 (file)
@@ -6,6 +6,7 @@
 
 #include "carddav/carddav.h"
 #include "common/dirs.h"
+#include "frmInvalidSSLCertificate.h"
 
 frmNewAccount::frmNewAccount( wxWindow* parent )
 :
@@ -128,7 +129,6 @@ void frmNewAccount::ProcessNext( wxCommandEvent& event )
         lblServerConnResult->SetLabel(_("Testing..."));
         
         UseSSL = chkUseSSL->GetValue();
-        
         CardDAVConn.SetupConnection(txtServerAddress->GetValue(),
                                     wxAtoi(txtServerPort->GetValue()),
                                     txtUsername->GetValue(),
@@ -136,6 +136,40 @@ void frmNewAccount::ProcessNext( wxCommandEvent& event )
                                     UseSSL);
         CardDAVConn.SetupResultBools(&ServerResult, &ServerAction);
         
+               // Verify SSL trust first before doing anything.
+
+               if (UseSSL == TRUE){
+
+                       CURLcode sslcode = CardDAVConn.SSLVerifyTest();
+
+                       if (sslcode == CURLE_OK){
+                               
+
+
+                       } else if (sslcode == CURLE_SSL_CACERT || sslcode == CURLE_SSL_CONNECT_ERROR){
+
+                               // Certificate is more than likely a self-signed or
+                               // expired certificate so display the invalid
+                               // SSL certificate message.
+
+                               frmInvalidSSLCertificate *frmICPtr = new frmInvalidSSLCertificate(this);
+
+                               frmICPtr->LoadDataNew(CardDAVConn.GetSSLVerifyResults(), txtServerAddress->GetValue());
+                               frmICPtr->ShowModal();
+
+                       } else {
+
+                               // Something else happened. Stop the process and
+                               // display an error message instead.
+
+                               lblServerConnResult->SetLabel(_("Failed"));
+                               lblConnectionResultText->SetLabel(_("An error occured whilst connnecting: ") + CardDAVConn.GetErrorMessage() + wxString::Format(wxT(" (%i)\n%s"), sslcode, CardDAVConn.GetErrorBuffer().mb_str()));
+                               return;
+
+                       }
+
+               }
+
         std::thread ConnTest(&CardDAV::Connect, &CardDAVConn);
         
         ConnTest.join();
Xestia Software Development
Yn Maystri
© 2006 - 2019 Xestia Software Development
Software

Xestia Address Book
Xestia Calendar
Development

Xestia Gelforn
Everything else

About
News
Privacy Policy