From: Steve Brokenshire <sbrokenshire@xestia.co.uk>
Date: Wed, 22 Nov 2017 00:23:10 +0000 (+0000)
Subject: CalDAV: WIP CalDAV support
X-Git-Url: http://Server1/repobrowser/?a=commitdiff_plain;h=7ac592fd401bd3a5e8c346827c63b34899a17e64;p=xestiacalendar%2F.git

CalDAV: WIP CalDAV support
---

diff --git a/source/AppXestiaCalendar.cpp b/source/AppXestiaCalendar.cpp
index 591afc4..914f7db 100644
--- a/source/AppXestiaCalendar.cpp
+++ b/source/AppXestiaCalendar.cpp
@@ -598,9 +598,9 @@ frmNewAccountADT::frmNewAccountADT( wxWindow* parent, wxWindowID id, const wxStr
 	lblIsCalDAV->Wrap( -1 );
 	fgSizer34->Add( lblIsCalDAV, 0, wxALL, 5 );
 	
-	lblCardDAVSupportResult = new wxStaticText( tabConn, wxID_ANY, wxT("..."), wxDefaultPosition, wxDefaultSize, 0 );
-	lblCardDAVSupportResult->Wrap( -1 );
-	fgSizer34->Add( lblCardDAVSupportResult, 0, wxALL, 5 );
+	lblCalDAVSupportResult = new wxStaticText( tabConn, wxID_ANY, wxT("..."), wxDefaultPosition, wxDefaultSize, 0 );
+	lblCalDAVSupportResult->Wrap( -1 );
+	fgSizer34->Add( lblCalDAVSupportResult, 0, wxALL, 5 );
 	
 	
 	bSizer323->Add( fgSizer34, 1, wxEXPAND, 5 );
diff --git a/source/AppXestiaCalendar.h b/source/AppXestiaCalendar.h
index a4b3007..328ee47 100644
--- a/source/AppXestiaCalendar.h
+++ b/source/AppXestiaCalendar.h
@@ -228,7 +228,7 @@ class frmNewAccountADT : public wxDialog
 		wxStaticText* lblServerUsernamePassword;
 		wxStaticText* lblAbleToLoginResult;
 		wxStaticText* lblIsCalDAV;
-		wxStaticText* lblCardDAVSupportResult;
+		wxStaticText* lblCalDAVSupportResult;
 		wxStaticLine* m_staticline3;
 		wxStaticText* lblConnectionResultText;
 		wxPanel* tabFinish;
diff --git a/source/Makefile.in b/source/Makefile.in
index f05c050..f14543c 100644
--- a/source/Makefile.in
+++ b/source/Makefile.in
@@ -29,6 +29,7 @@ FORM_EVENTEDITOROBJS=forms/eventeditor/frmEventEditor.o
 FORM_PREFERENCESOBJS=forms/preferences/frmPreferences.o
 FORM_ABOUTOBJS=forms/about/frmAbout.o
 FORM_ACTMGROBJS=forms/actmgr/frmActivityMgr.o
+FORM_INVALIDSSLCERTOBJS=forms/invalidsslcertificate/frmInvalidSSLCertificate.o
 WIDGETSOBJS=widgets/XCCalendarCtrl.o widgets/XCCalendarDay.o \
  widgets/XCCalendarDayEntry.o widgets/XCCalendarMonthView.o \
  widgets/XCCalendarMonthViewDayTitle.o \
@@ -54,7 +55,8 @@ default:
 
 forms: form_mainobjs form_editaccountobjs form_newaccountobjs \
 	form_preferencesobjs form_aboutobjs form_updateobjs \
-	form_calendareditorobjs form_eventeditorobjs form_actmgrobjs
+	form_calendareditorobjs form_eventeditorobjs form_actmgrobjs \
+	form_invalidsslcertificateobjs
 
 xestiacal: mainobjs forms widgetsobjs commonobjs calendarlistobjs \
 	calendarobjs calendareventobjs caldavobjs
@@ -97,6 +99,8 @@ form_aboutobjs: $(FORM_ABOUTOBJS)
 
 form_actmgrobjs: $(FORM_ACTMGROBJS)
 
+form_invalidsslcertificateobjs: $(FORM_INVALIDSSLCERTOBJS)
+
 widgetsobjs: $(WIDGETSOBJS)
 	
 commonobjs: $(COMMONOBJS)
diff --git a/source/common/sslcertstructs.h b/source/common/sslcertstructs.h
new file mode 100644
index 0000000..9f93509
--- /dev/null
+++ b/source/common/sslcertstructs.h
@@ -0,0 +1,54 @@
+// sslcertstructs.h - SSL Certificate structure header.
+//
+// (c) 2012-2015 Xestia Software Development.
+//
+// This file is part of Xestia Address Book.
+//
+// Xestia Address Book is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by the
+// Free Software Foundation, version 3 of the license.
+//
+// Xestia Address Book is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with Xestia Address Book. If not, see <http://www.gnu.org/licenses/>
+
+#ifndef __COMMON_SSLCERTSTRUCTS_H__
+#define __COMMON_SSLCERTSTRUCTS_H__
+
+#include <map>
+#include <string>
+#include <wx/wx.h>
+
+struct SSLCertData{
+
+	std::multimap<wxString, wxString> CertData;
+
+};
+
+struct SSLCertCollection{
+
+	int SuccessCode = 0;
+	
+	std::map<int, SSLCertData> SSLCollection;
+
+};
+
+struct SSLCertDataString{
+
+	std::multimap<std::string, std::string> CertData;
+
+};
+
+struct SSLCertCollectionString{
+
+	int SuccessCode = 0;
+	
+	std::map<int, SSLCertDataString> SSLCollection;
+
+};
+
+#endif
\ No newline at end of file
diff --git a/source/forms/frmInvalidSSLCertificate.cpp b/source/forms/frmInvalidSSLCertificate.cpp
deleted file mode 100644
index 5df2db5..0000000
--- a/source/forms/frmInvalidSSLCertificate.cpp
+++ /dev/null
@@ -1,41 +0,0 @@
-// frmInvalidSSLCertificate.cpp - frmInvalidSSLCertificate form functions
-//
-// (c) 2016-2017 Xestia Software Development.
-//
-// This file is part of Xestia Calendar.
-//
-// Xestia Calendar is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by the
-// Free Software Foundation, version 3 of the license.
-//
-// Xestia Calendar is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License along
-// with Xestia Calendar. If not, see <http://www.gnu.org/licenses/>
-
-#include "frmInvalidSSLCertificate.h"
-
-frmInvalidSSLCertificate::frmInvalidSSLCertificate( wxWindow* parent )
-:
-frmInvalidSSLCertificateADT( parent )
-{
-
-}
-
-void frmInvalidSSLCertificate::Accept( wxCommandEvent& event )
-{
-// TODO: Implement Accept
-}
-
-void frmInvalidSSLCertificate::Reject( wxCommandEvent& event )
-{
-// TODO: Implement Reject
-}
-
-void frmInvalidSSLCertificate::ViewCertificates( wxCommandEvent& event )
-{
-// TODO: Implement ViewCertificates
-}
diff --git a/source/forms/invalidsslcertificate/frmInvalidSSLCertificate.cpp b/source/forms/invalidsslcertificate/frmInvalidSSLCertificate.cpp
new file mode 100644
index 0000000..4c61e9b
--- /dev/null
+++ b/source/forms/invalidsslcertificate/frmInvalidSSLCertificate.cpp
@@ -0,0 +1,142 @@
+// frmInvalidSSLCertificate.cpp - frmInvalidSSLCertificate form functions
+//
+// (c) 2016-2017 Xestia Software Development.
+//
+// This file is part of Xestia Calendar.
+//
+// Xestia Calendar is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by the
+// Free Software Foundation, version 3 of the license.
+//
+// Xestia Calendar is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with Xestia Calendar. If not, see <http://www.gnu.org/licenses/>
+
+#include "frmInvalidSSLCertificate.h"
+
+frmInvalidSSLCertificate::frmInvalidSSLCertificate( wxWindow* parent )
+:
+frmInvalidSSLCertificateADT( parent )
+{
+
+}
+
+void frmInvalidSSLCertificate::Accept( wxCommandEvent& event )
+{
+// TODO: Implement Accept
+}
+
+void frmInvalidSSLCertificate::Reject( wxCommandEvent& event )
+{
+// TODO: Implement Reject
+}
+
+void frmInvalidSSLCertificate::ViewCertificates( wxCommandEvent& event )
+{
+	// Button 'View Certificates' was pressed.
+	
+	/*frmSSLCertificate *frameSSLCert = new frmSSLCertificate ( this );
+	frameSSLCert->StartCertFrom(0);
+	frameSSLCert->SetupCertsString(CertDataString);
+	frameSSLCert->ShowModal();
+		
+	delete frameSSLCert;
+	frameSSLCert = NULL;*/
+}
+
+void frmInvalidSSLCertificate::LoadData(SSLCertCollection CertDataInc, 
+					wxString AccountNameInc)
+{
+
+	// Load the invalid SSL certificate dialog.
+	
+	AccountName = AccountNameInc;
+	CertData = CertDataInc;
+
+	wxString SSLTextLabel;
+	
+	SSLTextLabel.Append(wxString::Format(_("An invalid SSL certificate was received from the server for the '%s' account.\n\n"), AccountName));
+	SSLTextLabel.Append(_("Click on one of the following buttons:\n\n"));
+	SSLTextLabel.Append(_("- Accept to accept the SSL certificate for this session and future sessions until the certificate changes.\n"));
+	SSLTextLabel.Append(_("- Reject to not use this certificate and disconnect (you will be asked again on subsequent reconnections to the server).\n"));
+	SSLTextLabel.Append(_("- View Certificates to review the certificates that were received."));
+	
+	lblSSLText->SetLabel(SSLTextLabel);
+
+}
+
+void frmInvalidSSLCertificate::LoadData(SSLCertCollectionString CertDataInc, 
+					wxString AccountNameInc)
+{
+
+	// Load the invalid SSL certificate dialog.
+	
+	AccountName = AccountNameInc;
+	CertDataString = CertDataInc;
+
+	wxString SSLTextLabel;
+	
+	SSLTextLabel.Append(wxString::Format(_("An invalid SSL certificate was received from the server for the '%s' account.\n\n"), AccountName));
+	SSLTextLabel.Append(_("Click on one of the following buttons:\n\n"));
+	SSLTextLabel.Append(_("- Accept to accept the SSL certificate for this session and future sessions until the certificate changes.\n"));
+	SSLTextLabel.Append(_("- Reject to not use this certificate and disconnect (you will be asked again on subsequent reconnections to the server).\n"));
+	SSLTextLabel.Append(_("- View Certificates to review the certificates that were received."));
+	
+	lblSSLText->SetLabel(SSLTextLabel);
+
+}
+
+void frmInvalidSSLCertificate::LoadDataNew(SSLCertCollection CertDataInc, 
+					wxString DomainNameInc)
+{
+
+	// Load the invalid SSL certificate dialog for a new account.
+	
+	AccountName = DomainNameInc;
+	CertData = CertDataInc;
+	
+	wxString SSLTextLabel;
+	
+	SSLTextLabel.Append(wxString::Format(_("An invalid SSL certificate was received from the server for the '%s' account.\n\n"), AccountName));
+	SSLTextLabel.Append(_("Click on one of the following buttons:\n\n"));
+	SSLTextLabel.Append(_("- Accept to accept the SSL certificate for this session and future sessions until the certificate changes.\n"));
+	SSLTextLabel.Append(_("- Reject to not use this certificate and disconnect.\n"));
+	SSLTextLabel.Append(_("- View Certificates to review the certificates that were received."));
+	
+	lblSSLText->SetLabel(SSLTextLabel);
+	
+}
+
+void frmInvalidSSLCertificate::LoadDataNew(SSLCertCollectionString CertDataInc, 
+					std::string DomainNameInc)
+{
+
+	// Load the invalid SSL certificate dialog for a new account.
+	
+	AccountName = DomainNameInc;
+	CertDataString = CertDataInc;
+	
+	wxString SSLTextLabel;
+	
+	SSLTextLabel.Append(wxString::Format(_("An invalid SSL certificate was received from the server for the '%s' account.\n\n"), AccountName));
+	SSLTextLabel.Append(_("Click on one of the following buttons:\n\n"));
+	SSLTextLabel.Append(_("- Accept to accept the SSL certificate for this session and future sessions until the certificate changes.\n"));
+	SSLTextLabel.Append(_("- Reject to not use this certificate and disconnect.\n"));
+	SSLTextLabel.Append(_("- View Certificates to review the certificates that were received."));
+	
+	lblSSLText->SetLabel(SSLTextLabel);
+	
+}
+
+int frmInvalidSSLCertificate::GetResult()
+{
+
+	// Get the result of which button was pressed in the dialog.
+	
+	return intResult;
+
+}
\ No newline at end of file
diff --git a/source/forms/frmInvalidSSLCertificate.h b/source/forms/invalidsslcertificate/frmInvalidSSLCertificate.h
similarity index 73%
rename from source/forms/frmInvalidSSLCertificate.h
rename to source/forms/invalidsslcertificate/frmInvalidSSLCertificate.h
index a74cbfa..1dc72d4 100644
--- a/source/forms/frmInvalidSSLCertificate.h
+++ b/source/forms/invalidsslcertificate/frmInvalidSSLCertificate.h
@@ -24,7 +24,9 @@
 Subclass of frmInvalidSSLCertificateADT, which is generated by wxFormBuilder.
 */
 
-#include "../AppXestiaCalendar.h"
+#include "../../AppXestiaCalendar.h"
+
+#include "../../common/sslcertstructs.h"
 
 //// end generated include
 
@@ -36,9 +38,19 @@ class frmInvalidSSLCertificate : public frmInvalidSSLCertificateADT
 		void Accept( wxCommandEvent& event );
 		void Reject( wxCommandEvent& event );
 		void ViewCertificates( wxCommandEvent& event );
+	private:
+		SSLCertCollection CertData;
+		SSLCertCollectionString CertDataString;
+		int intResult;
+		wxString AccountName;
 	public:
 		/** Constructor */
 		frmInvalidSSLCertificate( wxWindow* parent );
+		void LoadData(SSLCertCollection CertDataInc, wxString AccountNameInc);
+		void LoadData(SSLCertCollectionString CertDataInc, wxString AccountNameInc);
+		void LoadDataNew(SSLCertCollection CertDataInc, wxString DomainNameInc);
+		void LoadDataNew(SSLCertCollectionString CertDataInc, std::string DomainNameInc);
+		int GetResult();
 	//// end generated class members
 	
 };
diff --git a/source/forms/newaccount/frmNewAccount.cpp b/source/forms/newaccount/frmNewAccount.cpp
index ec9aa1b..fc1ae8a 100644
--- a/source/forms/newaccount/frmNewAccount.cpp
+++ b/source/forms/newaccount/frmNewAccount.cpp
@@ -410,7 +410,7 @@ void frmNewAccount::RunCalDAVTest( wxCommandEvent &event )
 	connData.port = wxAtoi(txtServerPort->GetValue());
 	connData.username = txtUsername->GetValue().ToStdString();
 	connData.password = txtPassword->GetValue().ToStdString();
-	connData.useSSL = chkUseSSL->GetValue() ? true : false);
+	connData.useSSL = chkUseSSL->GetValue() ? true : false;
 
 	CalDAV testConnection;
 	testConnection.SetupConnectionData(&connData);
@@ -423,8 +423,8 @@ void frmNewAccount::RunCalDAVTest( wxCommandEvent &event )
 	
 	// Test the connection.
 	
-	testConnection.SetupConnectionObject();
-	CalDAVServerResult testConnectionResult = testConnection.Connect(false);
+	//testConnection.SetupConnectionObject();
+	CalDAVServerResult testConnectionResult = testConnection.Connect();
 	
 	// If server is using SSL, verify that the SSL connection is valid.
 	
@@ -509,14 +509,14 @@ void frmNewAccount::RunCalDAVTest( wxCommandEvent &event )
 		
 		testConnection.BypassSSLVerification(true);
 		
-		CalDAVServerResult testConnectionResult = testConnection.Connect(false);
+		CalDAVServerResult testConnectionResult = testConnection.Connect();
 		
 		testConnection.BypassSSLVerification(false);
 
 		SSLCertCollectionString certData = testConnection.BuildSSLCollection();
     		frmInvalidSSLCertificate *frmICPtr = new frmInvalidSSLCertificate(this);
 		
-		frmICPtr->LoadDataNew(CertData, txtServerAddress->GetValue().ToStdString());
+		frmICPtr->LoadDataNew(certData, txtServerAddress->GetValue().ToStdString());
 		frmICPtr->ShowModal();
 								
 		int sslResult = frmICPtr->GetResult();
@@ -535,7 +535,7 @@ void frmNewAccount::RunCalDAVTest( wxCommandEvent &event )
 			usingSSLBypass = true;
 			testConnection.BypassSSLVerification(true);
 		
-			CalDAVServerResult testConnectionResult = testConnection.Connect(true);
+			CalDAVServerResult testConnectionResult = testConnection.Connect();
 		
 			testConnection.BypassSSLVerification(false);
 								
@@ -546,17 +546,17 @@ void frmNewAccount::RunCalDAVTest( wxCommandEvent &event )
 			// TODO: Integrate into the code.
 			
 			//lblConnectionResultText->SetLabel(_("An error occured whilst connnecting: ") + CardDAVConn.GetErrorMessage() + wxString::Format(wxT(" (%i)\n%s"), sslcode, CardDAVConn.GetErrorBuffer().mb_str()));
-								
+						
 		}		
 		
 #endif
 	}
 	
-	testConnectionResult = testConnection.Connect(true);
+	testConnectionResult = testConnection.Connect();
 
 	// Get the server prefix if the connection was successful.
 	
-	if (testConnectionResult == COCONNECT_OK){
+	if (testConnectionResult.result == CALDAVQUERYRESULT_OK){
 
 		if (usingSSLBypass == true){
 			testConnection.BypassSSLVerification(true);			
@@ -573,14 +573,14 @@ void frmNewAccount::RunCalDAVTest( wxCommandEvent &event )
 		
 	}
 	
-	testConnectionResult == COCONNECT_OK ? resultData->Connected = true : resultData->Connected = false;
+	testConnectionResult.result == CALDAVQUERYRESULT_OK ? resultData->Connected = true : resultData->Connected = false;
 	
-	resultData->SSLStatus = TestConnection.CanDoSSL();
-	resultData->SSLVerified = TestConnection.SSLVerify();
-	resultData->ValidResponse = TestConnection.HasValidResponse();
-	resultData->AuthPassed = TestConnection.AbleToLogin();
-	resultData->CanProcess = TestConnection.CanDoProcessing();
-	resultData->ErrorMessage = TestConnection.GetErrorMessage();
+	resultData->SSLStatus = testConnection.CanDoSSL();
+	resultData->SSLVerified = testConnection.SSLVerify();
+	resultData->ValidResponse = testConnection.HasValidResponse();
+	resultData->AuthPassed = testConnection.AbleToLogin();
+	resultData->CanProcess = testConnection.CanDoProcessing();
+	resultData->ErrorMessage = testConnection.GetErrorMessage();
 	
 	// Post event back confirming the tests.
 	
diff --git a/source/forms/newaccount/frmNewAccount.h b/source/forms/newaccount/frmNewAccount.h
index 3f02e77..f799979 100644
--- a/source/forms/newaccount/frmNewAccount.h
+++ b/source/forms/newaccount/frmNewAccount.h
@@ -33,8 +33,11 @@ Subclass of frmNewAccountADT, which is generated by wxFormBuilder.
 #include "../../libraries/CalendarDataStorage/CalendarDataStorage.h"
 #include "../objects/CalDAV/CalDAV.h"
 
+#include "../invalidsslcertificate/frmInvalidSSLCertificate.h"
+
 #include "svrblist.h"
 #include "dirs.h"
+#include "sslcertstructs.h"
 
 DECLARE_EVENT_TYPE(UPDATERESULTS, wxID_ANY);
 DECLARE_EVENT_TYPE(RUNCALDAVTEST, wxID_ANY);
diff --git a/source/objects/CalDAV/CalDAV.cpp b/source/objects/CalDAV/CalDAV.cpp
index ecd91bd..25c322e 100644
--- a/source/objects/CalDAV/CalDAV.cpp
+++ b/source/objects/CalDAV/CalDAV.cpp
@@ -1460,7 +1460,94 @@ CalDAVServerResult CalDAV::DeleteEntry(string *calendarEntryHREF){
 	
 }
 
-bool CalDAVObjectValidSettings(CalDAVConnectionData *connData){
+COSSLVerified CalDAV::SSLVerify()
+{
+	return SSLVerified;
+}
+
+void CalDAV::BypassSSLVerification(bool EnableBypass){
+	EnableSSLBypass = EnableBypass;
+	SSLSelfSigned = EnableBypass;
+}
+
+#if defined(__APPLE__)
+
+SecTrustRef CalDAV::BuildSSLCollection(){
+	
+	return CertificateData;
+	
+}
+
+#elif defined(__WIN32__)
+
+PCCERT_CONTEXT CalDAV::BuildSSLCollection(){
+
+	return CertificateData;
+
+}
+
+#else
+
+SSLCertCollectionString CalDAV::BuildSSLCollection(){
+
+	// Build and return the SSL collection.
+	
+	SSLCertCollectionString SSLCertInfo;
+
+	// Grab the certificate data.
+
+	union {
+		struct curl_slist *certdata;
+		struct curl_certinfo *certinfo;
+	} certptr;
+
+	certptr.certdata = NULL;
+	
+	CURLcode result = curl_easy_getinfo(ConnectionSession, CURLINFO_CERTINFO, &certptr.certinfo);
+	
+	std::string CertPropName;
+	std::string CertPropValue;
+	
+	for (int i = 0; i < certptr.certinfo->num_of_certs; i++){
+		
+		struct curl_slist *slist;
+		SSLCertDataString SSLCertDataInc;
+		
+		for (slist = certptr.certinfo->certinfo[i]; slist; slist = slist->next){
+			
+			// Using wxStringTokenizer from wxWidgets.
+			
+			wxStringTokenizer CertDataInc(wxString::FromUTF8(slist->data), ":");
+			
+			// Get first token as the property name.
+			
+			CertPropName = CertDataInc.GetNextToken().ToStdString();
+			
+			// Get remaining tokens as the property value.
+			
+			while(CertDataInc.HasMoreTokens()){
+			
+				CertPropValue.append(CertDataInc.GetNextToken());
+			
+			}
+			
+			SSLCertDataInc.CertData.insert(std::make_pair(CertPropName, CertPropValue));
+			CertPropName.clear();
+			CertPropValue.clear();
+			
+		}
+	
+		SSLCertInfo.SSLCollection.insert(std::make_pair(i, SSLCertDataInc));
+	
+	}
+	
+	return SSLCertInfo;
+
+}
+
+#endif
+
+static bool CalDAVObjectValidSettings(CalDAVConnectionData *connData){
 
 	// Check if the passed CalDAV Connection Data is has
 	// an address set. Return false if nullptr is used.
@@ -1521,7 +1608,7 @@ bool CalDAVObjectValidSettings(CalDAVConnectionData *connData){
 
 }
 
-string BuildServerAddress(CalDAVConnectionData *connData, string uriAddress){
+static string BuildServerAddress(CalDAVConnectionData *connData, string uriAddress){
 	
 	string serverAddress;
 	
@@ -1547,4 +1634,4 @@ string BuildServerAddress(CalDAVConnectionData *connData, string uriAddress){
 	
 	return serverAddress;
 	
-}
\ No newline at end of file
+}
diff --git a/source/objects/CalDAV/CalDAV.h b/source/objects/CalDAV/CalDAV.h
index 148f2d0..7ca237a 100644
--- a/source/objects/CalDAV/CalDAV.h
+++ b/source/objects/CalDAV/CalDAV.h
@@ -30,6 +30,7 @@
 #include "../../common/colour.h"
 #include "../../common/text.h"
 #include "../../common/uuid.h"
+#include "../../common/sslcertstructs.h"
 
 using namespace std;
 
@@ -126,6 +127,17 @@ struct CalDAVSendData{
 	int seek = 0;
 };
 
+// Objects to move to a ConnectionObject-like interface in the future.
+
+enum COSSLVerified {
+	COSSL_UNITTESTFAIL = -1,
+	COSSL_VERIFIED,
+	COSSL_VERIFIED_USER,
+	COSSL_UNABLETOVERIFY,
+	COSSL_NOTAPPLICABLE,
+	COSSL_NORESULT
+};
+
 class CalDAV{
 
 	private:
@@ -150,6 +162,9 @@ class CalDAV{
 		string serverData = "";
 		string serverHeader = "";
 	
+		COSSLVerified SSLVerified;
+		bool EnableSSLBypass = false;
+		bool SSLSelfSigned = false;
 	public:
 		CalDAV();
 		~CalDAV();
@@ -189,13 +204,28 @@ class CalDAV{
 		string GetCalendarHome(string userPrincipalURI);
 		
 		CalDAVServerResult GetEntryETag(string *calendarEntryHREF, string *eTagValue);
-	
+
+		COSSLVerified SSLVerify();
+		void BypassSSLVerification(bool EnableBypass);
+		
+#if defined(__APPLE__)
+    
+		SecTrustRef BuildSSLCollection();
+    
+#elif defined(__WIN32__)
+
+		PCCERT_CONTEXT BuildSSLCollection();
+
+#else
+		SSLCertCollectionString BuildSSLCollection();
+
+#endif
 };
 
 // Subroutines that are used with the 
 // CalDAVConnectionData struct.
 
-bool CalDAVObjectValidSettings(CalDAVConnectionData *connData);
-string BuildServerAddress(CalDAVConnectionData *connData, string uriAddress);
+//bool CalDAVObjectValidSettings(CalDAVConnectionData *connData);
+//string BuildServerAddress(CalDAVConnectionData *connData, string uriAddress);
 
 #endif
diff --git a/source/tests/xestiacalendar_caldav.h b/source/tests/xestiacalendar_caldav.h
index 56f3217..cc2a117 100644
--- a/source/tests/xestiacalendar_caldav.h
+++ b/source/tests/xestiacalendar_caldav.h
@@ -25,7 +25,8 @@ using namespace std;
 string entryCalendarHREFProcessing = "";
 string entryUUID = "";
 
-TEST(CalDAV, BasicTests){
+TEST(CalDAV, BasicTests)
+{
 
 	CalDAVConnectionData connPlain;
 	CalDAVConnectionData connNormal;
@@ -265,7 +266,8 @@ TEST(CalDAV, BasicTests){
 	
 }
 
-TEST(CalDAV, BuildServerAddress){
+TEST(CalDAV, BuildServerAddress)
+{
 
 	CalDAVConnectionData connNormal;
 	ProcessConnectionDataFileResult dataFileResult;
@@ -323,7 +325,8 @@ TEST(CalDAV, BuildServerAddress){
 	
 }
 
-TEST(CalDAV, CalendarServerSupport){
+TEST(CalDAV, CalendarServerSupport)
+{
 	
 	CalDAVConnectionData connNormal;
 
@@ -370,7 +373,8 @@ TEST(CalDAV, CalendarServerSupport){
 	
 }
 
-TEST(CalDAV, GetCalendarHome){
+TEST(CalDAV, GetCalendarHome)
+{
  
 	CalDAVConnectionData connNormal;	
 
@@ -441,7 +445,8 @@ TEST(CalDAV, GetCalendarHome){
   
 }
 
-TEST(CalDAV, ListCalendars){
+TEST(CalDAV, ListCalendars)
+{
 	
 	CalDAVConnectionData connNormal;
 	string currentUserPrincipal;
@@ -505,7 +510,8 @@ TEST(CalDAV, ListCalendars){
 	
 }
 
-TEST(CalDAV, AddCalendar){
+TEST(CalDAV, AddCalendar)
+{
 	
 	CalDAVConnectionData connNormal;
 	string currentUserPrincipal;
@@ -555,7 +561,8 @@ TEST(CalDAV, AddCalendar){
 	
 }
 
-TEST(CalDAV, EditCalendar){
+TEST(CalDAV, EditCalendar)
+{
 	
 	CalDAVConnectionData connNormal;
 	string currentUserPrincipal;
@@ -713,7 +720,8 @@ TEST(CalDAV, EditCalendar){
 	
 }
 
-TEST(CalDAV, DeleteCalendar){
+TEST(CalDAV, DeleteCalendar)
+{
 
 	CalDAVConnectionData connNormal;
 	string currentUserPrincipal;
@@ -806,7 +814,8 @@ TEST(CalDAV, DeleteCalendar){
 	
 }
 
-TEST(CalDAV, AddEntry){
+TEST(CalDAV, AddEntry)
+{
 	
 	CalDAVConnectionData connNormal;
 	string currentUserPrincipal;
@@ -923,7 +932,8 @@ TEST(CalDAV, AddEntry){
 	
 }
 
-TEST(CalDAV, GetEntryETag){
+TEST(CalDAV, GetEntryETag)
+{
 	
 	CalDAVConnectionData connNormal;
 	string currentUserPrincipal;
@@ -997,7 +1007,8 @@ TEST(CalDAV, GetEntryETag){
 	
 }
 
-TEST(CalDAV, EditEntry){
+TEST(CalDAV, EditEntry)
+{
 	
 	// Check that EntryCalendarHREFProcessing is not blank.	
 	
@@ -1099,7 +1110,8 @@ TEST(CalDAV, EditEntry){
 	
 }
 
-TEST(CalDAV, DeleteEntry){
+TEST(CalDAV, DeleteEntry)
+{
 
 	// Check that EntryCalendarHREFProcessing is not blank.	
 	
@@ -1165,7 +1177,8 @@ TEST(CalDAV, DeleteEntry){
 	
 }
 
-TEST(CalDAV, GetEntryList){
+TEST(CalDAV, GetEntryList)
+{
 	
 	// Check that EntryCalendarHREFProcessing is not blank.	
 	
@@ -1265,4 +1278,4 @@ TEST(CalDAV, GetEntryList){
 
 	EXPECT_EQ(entryList.href.size(), 0);
 
-}
\ No newline at end of file
+}