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 );
wxStaticText* lblServerUsernamePassword;
wxStaticText* lblAbleToLoginResult;
wxStaticText* lblIsCalDAV;
- wxStaticText* lblCardDAVSupportResult;
+ wxStaticText* lblCalDAVSupportResult;
wxStaticLine* m_staticline3;
wxStaticText* lblConnectionResultText;
wxPanel* tabFinish;
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 \
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
form_actmgrobjs: $(FORM_ACTMGROBJS)
+form_invalidsslcertificateobjs: $(FORM_INVALIDSSLCERTOBJS)
+
widgetsobjs: $(WIDGETSOBJS)
commonobjs: $(COMMONOBJS)
--- /dev/null
+// 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
+++ /dev/null
-// 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
-}
--- /dev/null
+// 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
Subclass of frmInvalidSSLCertificateADT, which is generated by wxFormBuilder.
*/
-#include "../AppXestiaCalendar.h"
+#include "../../AppXestiaCalendar.h"
+
+#include "../../common/sslcertstructs.h"
//// end generated include
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
};
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);
// 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.
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();
usingSSLBypass = true;
testConnection.BypassSSLVerification(true);
- CalDAVServerResult testConnectionResult = testConnection.Connect(true);
+ CalDAVServerResult testConnectionResult = testConnection.Connect();
testConnection.BypassSSLVerification(false);
// 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);
}
- 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.
#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);
}
-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.
}
-string BuildServerAddress(CalDAVConnectionData *connData, string uriAddress){
+static string BuildServerAddress(CalDAVConnectionData *connData, string uriAddress){
string serverAddress;
return serverAddress;
-}
\ No newline at end of file
+}
#include "../../common/colour.h"
#include "../../common/text.h"
#include "../../common/uuid.h"
+#include "../../common/sslcertstructs.h"
using namespace std;
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:
string serverData = "";
string serverHeader = "";
+ COSSLVerified SSLVerified;
+ bool EnableSSLBypass = false;
+ bool SSLSelfSigned = false;
public:
CalDAV();
~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
string entryCalendarHREFProcessing = "";
string entryUUID = "";
-TEST(CalDAV, BasicTests){
+TEST(CalDAV, BasicTests)
+{
CalDAVConnectionData connPlain;
CalDAVConnectionData connNormal;
}
-TEST(CalDAV, BuildServerAddress){
+TEST(CalDAV, BuildServerAddress)
+{
CalDAVConnectionData connNormal;
ProcessConnectionDataFileResult dataFileResult;
}
-TEST(CalDAV, CalendarServerSupport){
+TEST(CalDAV, CalendarServerSupport)
+{
CalDAVConnectionData connNormal;
}
-TEST(CalDAV, GetCalendarHome){
+TEST(CalDAV, GetCalendarHome)
+{
CalDAVConnectionData connNormal;
}
-TEST(CalDAV, ListCalendars){
+TEST(CalDAV, ListCalendars)
+{
CalDAVConnectionData connNormal;
string currentUserPrincipal;
}
-TEST(CalDAV, AddCalendar){
+TEST(CalDAV, AddCalendar)
+{
CalDAVConnectionData connNormal;
string currentUserPrincipal;
}
-TEST(CalDAV, EditCalendar){
+TEST(CalDAV, EditCalendar)
+{
CalDAVConnectionData connNormal;
string currentUserPrincipal;
}
-TEST(CalDAV, DeleteCalendar){
+TEST(CalDAV, DeleteCalendar)
+{
CalDAVConnectionData connNormal;
string currentUserPrincipal;
}
-TEST(CalDAV, AddEntry){
+TEST(CalDAV, AddEntry)
+{
CalDAVConnectionData connNormal;
string currentUserPrincipal;
}
-TEST(CalDAV, GetEntryETag){
+TEST(CalDAV, GetEntryETag)
+{
CalDAVConnectionData connNormal;
string currentUserPrincipal;
}
-TEST(CalDAV, EditEntry){
+TEST(CalDAV, EditEntry)
+{
// Check that EntryCalendarHREFProcessing is not blank.
}
-TEST(CalDAV, DeleteEntry){
+TEST(CalDAV, DeleteEntry)
+{
// Check that EntryCalendarHREFProcessing is not blank.
}
-TEST(CalDAV, GetEntryList){
+TEST(CalDAV, GetEntryList)
+{
// Check that EntryCalendarHREFProcessing is not blank.
EXPECT_EQ(entryList.href.size(), 0);
-}
\ No newline at end of file
+}