}
+void frmInvalidSSLCertificate::LoadDataNew(SSLCertCollection CertDataInc,
+ wxString DomainNameInc)
+{
+
+ AccountName = DomainNameInc;
+ CertData = CertDataInc;
+
+ lblSSLText->SetLabel(wxT("An invalid SSL certificate was received from the server ") + AccountName + (" account.\n\n") +
+ wxT("Click on one of the following buttons:\n\n") +
+ wxT("- Accept to accept the SSL certificate for this session and future sessions until the certificate changes.\n") +
+ wxT("- Reject to not use this certificate and disconnect.\n") +
+ wxT("- View Certificates to review the certificates that were received.")
+ );
+
+}
+
int frmInvalidSSLCertificate::GetResult()
{
/** Constructor */
frmInvalidSSLCertificate( wxWindow* parent );
void LoadData(SSLCertCollection CertDataInc, wxString AccountNameInc);
+ void LoadDataNew(SSLCertCollection CertDataInc, wxString DomainNameInc);
int GetResult();
//// end generated class members
#include "carddav/carddav.h"
#include "common/dirs.h"
+#include "frmInvalidSSLCertificate.h"
frmNewAccount::frmNewAccount( wxWindow* parent )
:
lblServerConnResult->SetLabel(_("Testing..."));
UseSSL = chkUseSSL->GetValue();
-
CardDAVConn.SetupConnection(txtServerAddress->GetValue(),
wxAtoi(txtServerPort->GetValue()),
txtUsername->GetValue(),
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();