Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Altered CardDAV object to accommodate for SSL support for OS X (and other OSes in...
[xestiaab/.git] / source / carddav / carddav.cpp
index fb07b50..b95dec1 100644 (file)
@@ -28,7 +28,7 @@
 #include "../vcard/vcard.h"\r
 #include "../common/dirs.h"\r
 \r
-size_t WritebackFunc(char *ptr, size_t size, size_t nmemb, wxString *stream){\r
+size_t CardDAV::WritebackFunc(char *ptr, size_t size, size_t nmemb, wxString *stream){\r
        \r
        // Writeback function for the CardDAV object.\r
        \r
@@ -37,6 +37,21 @@ size_t WritebackFunc(char *ptr, size_t size, size_t nmemb, wxString *stream){
        \r
        stream->Append(Data);\r
        \r
+       // Get the SSL engine pointer and trust if required on certain operating systems.\r
+       \r
+#if defined(__APPLE__)\r
+       \r
+       const struct curl_tlssessioninfo *TLSInfo;\r
+       CURLcode TLSCode;\r
+       CURL *Connection = GetConnectionObject();\r
+       TLSCode = curl_easy_getinfo(Connection, CURLINFO_TLS_SSL_PTR, &TLSInfo);\r
+       \r
+       if (TLSInfo->internals != nullptr && TLSCode == CURLE_OK){\r
+               SSLCopyPeerTrust((SSLContext*)TLSInfo->internals, &SecTrustObject);\r
+       }\r
+       \r
+#endif\r
+       \r
        return size * nmemb;\r
 \r
 }\r
@@ -92,6 +107,9 @@ int CardDAV::HTTPErrorCode;
 wxString CardDAV::ErrorMessage;\r
 SSLCertCollection CardDAV::VerifyCertCollection;\r
 bool CardDAV::AllowSelfSign;\r
+SSLContext *CardDAV::SSLContextPointer;\r
+SecTrustRef CardDAV::SecTrustObject;\r
+CURL *CardDAV::ConnectionObject;\r
 \r
 CardDAV::CardDAV(){\r
        \r
@@ -320,13 +338,13 @@ void CardDAV::SetupData(wxString Method, wxString FilenameLocation, wxString Upl
        // Check if ServerFilenameLocation has a / at \r
        // the start and if not then append it.\r
        \r
-       if (ServerFilenameLocation.Left(1) != wxT("/")){\r
+       /*if (ServerFilenameLocation.Left(1) != wxT("/")){\r
        \r
                // Not there so insert.\r
                \r
                ServerFilenameLocation = wxT("/") + ServerFilenameLocation;\r
        \r
-       }\r
+       }*/\r
 \r
 }\r
 \r
@@ -458,4 +476,20 @@ wxString CardDAV::GetErrorMessage(){
        \r
        return ErrorMessage;\r
 \r
+}\r
+\r
+CURL* CardDAV::GetConnectionObject(){\r
+       \r
+       // Get the CardDAV connection object.\r
+       \r
+       return ConnectionObject;\r
+       \r
+}\r
+\r
+void CardDAV::SetConnectionObject(CURL *ConnectionObjectIn){\r
+\r
+       // Set the connection object.\r
+       \r
+       ConnectionObject = ConnectionObjectIn;\r
+       \r
 }
\ No newline at end of file
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