Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Initial work started on using ConnectionObject on Win32 systems
authorSteve Brokenshire <sbrokenshire@xestia.co.uk>
Sun, 11 Sep 2016 08:36:11 +0000 (09:36 +0100)
committerSteve Brokenshire <sbrokenshire@xestia.co.uk>
Sun, 11 Sep 2016 08:36:11 +0000 (09:36 +0100)
projects/msw/xestiaab.vcxproj
projects/msw/xestiaab.vcxproj.filters
source/actmgr/frmActivityMgr-tasks.cpp
source/actmgr/frmActivityMgr.cpp
source/carddav2/carddav2.cpp
source/carddav2/carddav2.h
source/common/dirs.cpp
source/common/win32ssl.cpp
source/common/win32ssl.h
source/connobject/ConnectionObject.h
source/frmNewAccount-CardDAV2.cpp

index cfd8129..d655b5c 100644 (file)
     <ClCompile Include="..\..\source\actmgr\frmActivityMgr-tasks.cpp" />
     <ClCompile Include="..\..\source\actmgr\frmActivityMgr.cpp" />
     <ClCompile Include="..\..\source\AppXestiaAddrBk.cpp" />
-    <ClCompile Include="..\..\source\carddav\carddav-connect.cpp" />
-    <ClCompile Include="..\..\source\carddav\carddav-contactlist.cpp" />
-    <ClCompile Include="..\..\source\carddav\carddav-defaultadrurl.cpp" />
-    <ClCompile Include="..\..\source\carddav\carddav-processdata.cpp" />
-    <ClCompile Include="..\..\source\carddav\carddav-servercontact.cpp" />
-    <ClCompile Include="..\..\source\carddav\carddav-serveretag.cpp" />
-    <ClCompile Include="..\..\source\carddav\carddav-sslverify.cpp" />
-    <ClCompile Include="..\..\source\carddav\carddav.cpp" />
+    <ClCompile Include="..\..\source\carddav2\carddav2.cpp" />
     <ClCompile Include="..\..\source\common\base64.cpp" />
     <ClCompile Include="..\..\source\common\defaults.cpp" />
     <ClCompile Include="..\..\source\common\dirs.cpp" />
@@ -44,6 +37,7 @@
     <ClCompile Include="..\..\source\common\timers.cpp" />
     <ClCompile Include="..\..\source\common\uuid.cpp" />
     <ClCompile Include="..\..\source\common\win32ssl.cpp" />
+    <ClCompile Include="..\..\source\connobject\ConnectionObject.cpp" />
     <ClCompile Include="..\..\source\contacteditor\cdo\ContactDataObject.cpp" />
     <ClCompile Include="..\..\source\contacteditor\frmContactEditor-Business.cpp" />
     <ClCompile Include="..\..\source\contacteditor\frmContactEditor-Calendar.cpp" />
@@ -94,6 +88,7 @@
     <ClCompile Include="..\..\source\frmEditAccount.cpp" />
     <ClCompile Include="..\..\source\frmInvalidSSLCertificate.cpp" />
     <ClCompile Include="..\..\source\frmMain.cpp" />
+    <ClCompile Include="..\..\source\frmNewAccount-CardDAV2.cpp" />
     <ClCompile Include="..\..\source\frmNewAccount.cpp" />
     <ClCompile Include="..\..\source\frmPreferences.cpp" />
     <ClCompile Include="..\..\source\frmSSLCertificate.cpp" />
index d196cc4..dee14e4 100644 (file)
     <ClCompile Include="..\..\source\common\base64.cpp">
       <Filter>Resource Files\Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="..\..\source\carddav\carddav.cpp">
-      <Filter>Resource Files\Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\source\carddav\carddav-connect.cpp">
-      <Filter>Resource Files\Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\source\carddav\carddav-contactlist.cpp">
-      <Filter>Resource Files\Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\source\carddav\carddav-defaultadrurl.cpp">
-      <Filter>Resource Files\Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\source\carddav\carddav-processdata.cpp">
-      <Filter>Resource Files\Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\source\carddav\carddav-servercontact.cpp">
-      <Filter>Resource Files\Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\source\carddav\carddav-serveretag.cpp">
-      <Filter>Resource Files\Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\source\carddav\carddav-sslverify.cpp">
-      <Filter>Resource Files\Source Files</Filter>
-    </ClCompile>
     <ClCompile Include="..\..\source\contacteditor\cdo\ContactDataObject.cpp">
       <Filter>Resource Files\Source Files</Filter>
     </ClCompile>
     <ClCompile Include="..\..\source\search\XABSearchPanel.cpp">
       <Filter>Resource Files\Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\source\connobject\ConnectionObject.cpp">
+      <Filter>Resource Files\Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\source\carddav2\carddav2.cpp">
+      <Filter>Resource Files\Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\source\frmNewAccount-CardDAV2.cpp">
+      <Filter>Resource Files\Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ResourceCompile Include="xestiaab.rc">
index 842598d..11d1b37 100644 (file)
@@ -108,7 +108,7 @@ int frmActivityMgr::AddTask(int TaskType, wxString TaskDetail, wxString TaskAcco
                // Setup all of the task details.
 
                ETagDB *ETagDBPtr = ETagTmrPtr->GetPointer(AccountDir);
-               
+
                CardDAV2 *ConnObject = new CardDAV2(AccountAddress.ToStdString(), AccountPort, AccountUsername.ToStdString(), AccountPassword.ToStdString(), AccountSSL, AccountPrefix.ToStdString(), AccountDir.ToStdString());
                ConnObject->SetupConnectionObject();
                
index ec4700c..a066d8f 100644 (file)
@@ -440,7 +440,7 @@ void frmActivityMgr::ProcessTasksThread()
 
 #elif defined(__WIN32__)
 
-                                       frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnHandle.GetCertificateContextPointer());
+                                       frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnObjectIter->second->BuildSSLCollection());
 
 #else
                                        
@@ -905,7 +905,7 @@ void frmActivityMgr::ProcessTasksThread()
 
 #elif defined(__WIN32__)
 
-                                       frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnHandle.GetCertificateContextPointer());
+                                       frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnObjectIter->second->BuildSSLCollection());
 
 #else
                                
@@ -1130,7 +1130,7 @@ void frmActivityMgr::ProcessTasksThread()
 
 #elif defined(__WIN32__)
 
-                                       frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnHandle.GetCertificateContextPointer());
+                                       frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnObjectIter->second->BuildSSLCollection());
 
 #else
                                         
index 536afac..2159b98 100644 (file)
@@ -54,8 +54,7 @@ size_t CardDAV2::WritebackFuncImplementation(char *ptr, size_t size, size_t nmem
 
                const struct curl_tlssessioninfo *TLSInfo;
                CURLcode TLSCode;
-               CURL *Connection = GetConnectionObject();
-               TLSCode = curl_easy_getinfo(Connection, CURLINFO_TLS_SSL_PTR, &TLSInfo);
+               TLSCode = curl_easy_getinfo(ConnectionSession, CURLINFO_TLS_SSL_PTR, &TLSInfo);
 
                if (TLSInfo->internals != nullptr && TLSCode == CURLE_OK){
 
@@ -85,6 +84,12 @@ CardDAV2::~CardDAV2(){
                curl_slist_free_all(HeaderList);
                HeaderList = nullptr;
        }
+
+#if defined(__WIN32__)
+
+       CertFreeCertificateContext(CertificateData);
+
+#endif
        
 }
 
@@ -92,6 +97,12 @@ CardDAV2::~CardDAV2(){
 
 #elif defined(__WIN32__)
 
+PCCERT_CONTEXT CardDAV2::BuildSSLCollection(){
+
+       return CertificateData;
+
+}
+
 #else
 
 SSLCertCollectionString CardDAV2::BuildSSLCollection(){
@@ -1379,6 +1390,8 @@ void CardDAV2::SetupDefaultParametersSSL(bool DoAuthentication){
                curl_easy_setopt(ConnectionSession, CURLOPT_USERPWD, ":");              
        }
        
+#if !defined(__WIN32__)
+
        if (EnableSSLBypass == true){
                curl_easy_setopt(ConnectionSession, CURLOPT_SSL_VERIFYHOST, 0);
                curl_easy_setopt(ConnectionSession, CURLOPT_SSL_VERIFYPEER, 0);
@@ -1386,6 +1399,8 @@ void CardDAV2::SetupDefaultParametersSSL(bool DoAuthentication){
                curl_easy_setopt(ConnectionSession, CURLOPT_SSL_VERIFYHOST, 2);
                curl_easy_setopt(ConnectionSession, CURLOPT_SSL_VERIFYPEER, 1);         
        }
+
+#endif
        
        if (TestMode == false && ServerAccount.size() > 0){
                
index 2698d5a..fd1212c 100644 (file)
@@ -38,7 +38,7 @@ class CardDAV2 : public ConnectionObject {
        public:
        
                using ConnectionObject::ConnectionObject;
-       
+
                // Destructor.
        
                ~CardDAV2();
@@ -71,6 +71,9 @@ class CardDAV2 : public ConnectionObject {
 
 #if defined(__APPLE__)
 #elif defined(__WIN32__)
+
+               PCCERT_CONTEXT BuildSSLCollection();
+
 #else
                SSLCertCollectionString BuildSSLCollection();
 
@@ -108,6 +111,9 @@ class CardDAV2 : public ConnectionObject {
        
 #if defined(__APPLE__)
 #elif defined(__WIN32__)
+
+               PCCERT_CONTEXT CertificateData;
+
 #else
                bool EnableSSLBypass = false;
 #endif
index 3baf541..63232c0 100644 (file)
@@ -186,7 +186,7 @@ std::string GetAccountDir(std::string AccName, bool ServerCert)
        AccountDir.append("\\");
     
        if (ServerCert == true){
-               AccountDir.append(wxT("server.crt"));
+               AccountDir.append("server.crt");
        }
     
 #elif defined(__APPLE__)
index 26c7754..2c28621 100644 (file)
@@ -18,9 +18,9 @@
 
 #include "win32ssl.h"
 
-CRYPTUI_VIEWCERTIFICATE_STRUCTW BuildCertificateData(CardDAV *CardDAVConnection, HWND WindowHandle){
+CRYPTUI_VIEWCERTIFICATE_STRUCTW BuildCertificateData(ConnectionObject *ConnectionObjectData, HWND WindowHandle){
 
-       PCCERT_CONTEXT CertificateContext = CardDAVConnection->GetCertificateContextPointer();
+       PCCERT_CONTEXT CertificateContext = ConnectionObjectData->BuildSSLCollection();
        HCERTSTORE CertificateStore = CertificateContext->hCertStore;
        CRYPTUI_VIEWCERTIFICATE_STRUCTW CertificateData = { 0 };
        CertificateData.hwndParent = WindowHandle;
index 4035dc3..11a483d 100644 (file)
@@ -29,9 +29,9 @@
 #include <cryptuiapi.h>
 #include <sspi.h>
 
-#include "../carddav/carddav.h"
+#include "../connobject/ConnectionObject.h"
 
-CRYPTUI_VIEWCERTIFICATE_STRUCTW BuildCertificateData(CardDAV *CardDAVConnection, HWND WindowHandle);
+CRYPTUI_VIEWCERTIFICATE_STRUCTW BuildCertificateData(ConnectionObject *ConnectionObjectData, HWND WindowHandle);
 CRYPTUI_VIEWCERTIFICATE_STRUCTW BuildCertificateData(PCCERT_CONTEXT CertificateContext, HWND WindowHandle);
 
 #endif
\ No newline at end of file
index 24f357f..8e5221f 100644 (file)
 #include <iostream>
 #include "../common/sslcertstructs.h"
 
+#if defined (__WIN32__)
+#include <Windows.h>
+#include <basetsd.h>
+#include <winapifamily.h>
+#include <security.h>
+#include <schannel.h>
+#include <cryptuiapi.h>
+#include <sspi.h>
+#endif
+
 enum COConnectResult {
        COCONNECT_UNITTESTFAIL = -1,
        COCONNECT_OK,
@@ -80,39 +90,42 @@ class ConnectionObject{
        public:
                ConnectionObject(std::string ServerAddress, int ServerPort, std::string ServerUser, std::string ServerPass, bool ServerSSL);
                ConnectionObject(std::string ServerAddress, int ServerPort, std::string ServerUser, std::string ServerPass, bool ServerSSL, std::string ServerPrefix, std::string ServerAccount);
-       
+
                // Virtual functions to be setup by the inheriting classes.
        
-               virtual void SetupConnectionObject() { };
+               virtual void SetupConnectionObject() = 0;
                //virtual ~ConnectionObject() {};
                
-               virtual bool IsTaskCompleted() {};
+               virtual bool IsTaskCompleted() = 0;
                
-               virtual COConnectResult Connect(bool DoAuthentication) {};
-               virtual void BypassSSLVerification(bool EnableBypass) {};
+               virtual COConnectResult Connect(bool DoAuthentication) = 0;
+               virtual void BypassSSLVerification(bool EnableBypass) = 0;
                
-               virtual COServerResponse GetDefaultPrefix(std::string *ServerPrefix) {};
-               virtual COServerResponse AddContact(std::string Location, std::string Data) {};
-               virtual COServerResponse EditContact(std::string Location, std::string Data) {};
-               virtual COServerResponse DeleteContact(std::string Location) {};
-               virtual COServerResponse GetServerEntityTagValue(std::string Location) {};
-               virtual COServerResponse GetContact(std::string Location, std::string *PageData) {};
-               virtual COContactList GetContactList(std::string SyncToken) {};
+               virtual COServerResponse GetDefaultPrefix(std::string *ServerPrefix) = 0;
+               virtual COServerResponse AddContact(std::string Location, std::string Data) = 0;
+               virtual COServerResponse EditContact(std::string Location, std::string Data) = 0;
+               virtual COServerResponse DeleteContact(std::string Location) = 0;
+               virtual COServerResponse GetServerEntityTagValue(std::string Location) = 0;
+               virtual COServerResponse GetContact(std::string Location, std::string *PageData) = 0;
+               virtual COContactList GetContactList(std::string SyncToken) = 0;
                
-               virtual bool CanDoProcessing() {};
-               virtual bool CanDoSSL() {};
-               virtual COSSLVerified SSLVerify() {};
-               virtual bool AbleToLogin() {};
-               virtual bool HasValidResponse() {};
-               virtual bool IsSelfSigned() {};
-               virtual std::string GetErrorMessage() {};
+               virtual bool CanDoProcessing() = 0;
+               virtual bool CanDoSSL() = 0;
+               virtual COSSLVerified SSLVerify() = 0;
+               virtual bool AbleToLogin() = 0;
+               virtual bool HasValidResponse() = 0;
+               virtual bool IsSelfSigned() = 0;
+               virtual std::string GetErrorMessage() = 0;
        
                // OS specific functions.
                
 #if defined(__APPLE__)
 #elif defined(__WIN32__)
+
+               virtual PCCERT_CONTEXT BuildSSLCollection() = 0;
+
 #else
-               virtual SSLCertCollectionString BuildSSLCollection() {};
+               virtual SSLCertCollectionString BuildSSLCollection() = 0;
 
 #endif
                
index d8bd4fb..07f2239 100644 (file)
@@ -49,6 +49,26 @@ void frmNewAccount::RunCardDAV2Test( wxCommandEvent& event ){
        if (TestConnection.SSLVerify() == COSSL_UNABLETOVERIFY){
 #if defined(__APPLE__)
 #elif defined(__WIN32__)
+
+               BOOL ModifiedCertificateData = false;
+
+               CRYPTUI_VIEWCERTIFICATE_STRUCTW CertificateDialogData = BuildCertificateData(&TestConnection, (HWND)this->GetHandle());
+
+               if (!CryptUIDlgViewCertificate(&CertificateDialogData, &ModifiedCertificateData)){
+                       wxMessageBox(_("An error occured while trying to open the certificate dialog."), _("Error opening Certificate Information dialog"));
+               }
+
+               if (ModifiedCertificateData = false){
+
+                       lblServerConnResult->SetLabel(_("Failed"));
+                       lblServerResponse->SetLabel(_("Not applicable"));
+                       lblServerSSLResult->SetLabel(_("Used"));
+                       lblServerSSLValid->SetLabel(_("No"));
+                       lblConnectionResultText->SetLabel(_("An error occured whilst connnecting: ") + TestConnection.GetErrorMessage());
+                       return;
+
+               }
+
 #else
        
                // Connect again and fetch SSL certificate information.
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