curl_easy_setopt(conn, CURLOPT_SSL_VERIFYHOST, 0L);
}
+ SetConnectionObject(conn);
+
conncode = (curl_easy_perform(conn));
ptr.certdata = NULL;
wxString ServerAddressNormal;
conn = curl_easy_init();
+
+#if defined(__APPLE__)
+ SetConnectionObject(conn);
+#endif
struct CardDAVCURLPasser {
wxString Data1;
wxString Data2;
- ServerAddressURL = ServerAddress + wxT(":") + wxString::Format(wxT("%i"), ServerPort) + wxT("/") + ServerPrefix + wxT("/");
+ ServerAddressURL = ServerAddress + wxT(":") + wxString::Format(wxT("%i"), ServerPort) + ServerPrefix;
ServerAddressSSL = wxT("https://") + ServerAddressURL;
ServerAddressNormal = wxT("http://") + ServerAddressURL;
curl_easy_setopt(conn, CURLOPT_HTTPHEADER, slist);
curl_easy_setopt(conn, CURLOPT_CERTINFO, 1);
+#if defined(__APPLE__)
+
+#else
+
ServerCertFilename = GetAccountDir(ServerAccount, TRUE);
if (wxFile::Exists(ServerCertFilename) == TRUE){
}
+#endif
+
curl_easy_setopt(conn, CURLOPT_POSTFIELDS, query);
curl_easy_setopt(conn, CURLOPT_POSTFIELDSIZE, strlen(query));
// Check if it fails with a CURLE_SSL_CACERT then compare
// the certificates as PEM files.
+#if defined(__APPLE__)
+
+#else
+
if (claconncode == CURLE_SSL_CACERT && wxFile::Exists(ServerCertFilename) == TRUE){
CURL *sslerrconn;
curl_easy_cleanup(sslerrconn);
}
+
+#endif
// Sort out SSL error.
curl_easy_setopt(sslerrconn, CURLOPT_SSL_VERIFYPEER, 0);
curl_easy_setopt(sslerrconn, CURLOPT_CERTINFO, 1);
+#if defined(__APPLE__)
+ SetConnectionObject(sslerrconn);
+#endif
+
sslerrconncode = (curl_easy_perform(sslerrconn));
SSLCertCol = BuildSSLCollection(sslerrconn);
// First: Get the principal UID address.
conn = curl_easy_init();
+
+ SetConnectionObject(conn);
struct curl_slist *connhd = NULL;
struct curl_slist *connhd2 = NULL;
curl_easy_setopt(conn, CURLOPT_SSL_VERIFYHOST, 0L);
}
+ SetConnectionObject(conn);
+
conncode = (curl_easy_perform(conn));
if (conncode == CURLE_OK){
curl_easy_setopt(conn, CURLOPT_SSL_VERIFYHOST, 0L);
}
+ SetConnectionObject(conn);
+
conncode = (curl_easy_perform(conn));
if (conncode == CURLE_OK){
curl_easy_setopt(conn, CURLOPT_SSL_VERIFYHOST, 0L);
}
+ SetConnectionObject(conn);
+
conncode = (curl_easy_perform(conn));
if (conncode == CURLE_OK){
wxString ServerAddressURL;
wxString ServerAuth;
wxString ServerAddressSSL;
- wxString ServerAddressNormal;
-
+ wxString ServerAddressNormal;
+
conn = curl_easy_init();
+ SetConnectionObject(conn);
+
struct CardDAVCURLPasser {
CardDAV *Data;
wxString ETagOriginal;
wxString ETagServer;
- ServerAddressURL = ServerAddress + wxT(":") + wxString::Format(wxT("%i"), ServerPort) + wxT("/") + ServerPrefix + ServerFilenameLocation;
+ ServerAddressURL = ServerAddress + wxT(":") + wxString::Format(wxT("%i"), ServerPort) + ServerPrefix + ServerFilenameLocation;
ServerAddressSSL = wxT("https://") + ServerAddressURL;
ServerAddressNormal = wxT("http://") + ServerAddressURL;
}
+#if defined(__APPLE__)
+
+#else
+
ServerCertFilename = GetAccountDir(ServerAccount, TRUE);
if (wxFile::Exists(ServerCertFilename) == TRUE){
curl_easy_setopt(conn, CURLOPT_CAINFO, (const char*)ServerCertFilename.mb_str(wxConvUTF8));
}
+
+#endif
claconncode = (curl_easy_perform(conn));
// Check if it fails with a CURLE_SSL_CACERT then compare
// the certificates as PEM files.
+#if defined(__APPLE__)
+
+#else
+
if (claconncode == CURLE_SSL_CACERT && wxFile::Exists(ServerCertFilename) == TRUE){
CURL *sslerrconn;
wxString SSLLocalData;
wxString SSLServerData;
-
- sslerrconncode = (curl_easy_perform(sslerrconn));
-
+
+ sslerrconncode = (curl_easy_perform(sslerrconn));
+
SSLCertCol = BuildSSLCollection(sslerrconn);
std::map<int, SSLCertData>::iterator SSLCDIter = SSLCertCol.SSLCollection.find(0);
std::multimap<wxString,wxString>::iterator SSLDataIter = SSLCDIter->second.CertData.find(wxT("Cert"));
curl_easy_cleanup(sslerrconn);
}
+
+#endif
// Sort out SSL error.
curl_easy_setopt(sslerrconn, CURLOPT_NOSIGNAL, 1);
curl_easy_setopt(sslerrconn, CURLOPT_SSL_VERIFYPEER, 0);
curl_easy_setopt(sslerrconn, CURLOPT_CERTINFO, 1);
-
+
+ SetConnectionObject(sslerrconn);
+
sslerrconncode = (curl_easy_perform(sslerrconn));
+#if defined(__APPLE__)
+
+#else
+
SSLCertCol = BuildSSLCollection(sslerrconn);
SSLCertCol.SuccessCode = 1;
+#endif
+
return;
} else if (claconncode == CURLE_HTTP_RETURNED_ERROR){
- fprintf(stderr, "curl_easy_perform() failed: %s\n",
+ fprintf(stderr, "ProcessDataThrad(): curl_easy_perform() failed: %s\n",
curl_easy_strerror(claconncode));
int http_code = 0;
curl_easy_getinfo(conn, CURLINFO_RESPONSE_CODE, &http_code);
wxString ServerAddressURL;
wxString ServerAuth;
wxString ServerAddressSSL;
- wxString ServerAddressNormal;
-
+ wxString ServerAddressNormal;
+
conn = curl_easy_init();
+ SetConnectionObject(conn);
+
struct CardDAVCURLPasser {
CardDAV *Data;
curl_easy_setopt(conn, CURLOPT_WRITEHEADER, &PageHeader);
curl_easy_setopt(conn, CURLOPT_NOSIGNAL, 1);
+#if defined(__APPLE__)
+
+#else
+
ServerCertFilename = GetAccountDir(ServerAccount, TRUE);
if (wxFile::Exists(ServerCertFilename) == TRUE){
}
+#endif
+
claconncode = (curl_easy_perform(conn));
// If CURLE_PEER_FAILED_VERIFICATION is returned, retry without
// Check if it fails with a CURLE_SSL_CACERT then compare
// the certificates as PEM files.
+#if defined(__APPLE__)
+
+#else
+
if (claconncode == CURLE_SSL_CACERT && wxFile::Exists(ServerCertFilename) == TRUE){
CURL *sslerrconn;
}
+#endif
+
// Sort out SSL error.
// When SSL cert error occurs, connect again and fetch certificates.
curl_easy_setopt(sslerrconn, CURLOPT_NOSIGNAL, 1);
curl_easy_setopt(sslerrconn, CURLOPT_SSL_VERIFYPEER, 0);
curl_easy_setopt(sslerrconn, CURLOPT_CERTINFO, 1);
-
+
+ SetConnectionObject(sslerrconn);
+
sslerrconncode = (curl_easy_perform(sslerrconn));
SSLCertCol = BuildSSLCollection(sslerrconn);
AbortConnection = FALSE;
bool FilenameIsDirectory = FALSE;
- CURL *conn;
- CURLcode conncode;
+ CURL *conn;
+ CURLcode conncode;
wxString ServerAddressURL;
wxString ServerAuth;
wxString ServerAddressSSL;
conn = curl_easy_init();
+ SetConnectionObject(conn);
+
struct CardDAVCURLPasser {
CardDAV *Data;
wxString Data1;
wxString Data2;
- ServerAddressURL = ServerAddress + wxT(":") + wxString::Format(wxT("%i"), ServerPort) + wxT("/") + ServerPrefix + ServerFilenameLocation;
+ ServerAddressURL = ServerAddress + wxT(":") + wxString::Format(wxT("%i"), ServerPort) + ServerPrefix + ServerFilenameLocation;
ServerAddressSSL = wxT("https://") + ServerAddressURL;
ServerAddressNormal = wxT("http://") + ServerAddressURL;
curl_easy_setopt(conn, CURLOPT_POSTFIELDS, query);
curl_easy_setopt(conn, CURLOPT_POSTFIELDSIZE, strlen(query));
+#if defined(__APPLE__)
+
+#else
+
ServerCertFilename = GetAccountDir(ServerAccount, TRUE);
if (wxFile::Exists(ServerCertFilename) == TRUE){
}
+#endif
+
claconncode = (curl_easy_perform(conn));
// If CURLE_PEER_FAILED_VERIFICATION is returned, retry without
// Check if it fails with a CURLE_SSL_CACERT then compare
// the certificates as PEM files.
+#if defined(__APPLE__)
+
+#else
+
if (claconncode == CURLE_SSL_CACERT && wxFile::Exists(ServerCertFilename) == TRUE){
CURL *sslerrconn;
curl_easy_cleanup(sslerrconn);
}
+
+#endif
// Sort out SSL error.
sslerrconncode = (curl_easy_perform(sslerrconn));
+ SetConnectionObject(sslerrconn);
+
SSLCertCol = BuildSSLCollection(sslerrconn);
SSLCertCol.SuccessCode = 1;
} else if (claconncode == CURLE_HTTP_RETURNED_ERROR){
- fprintf(stderr, "curl_easy_perform() failed: %s\n",
+ fprintf(stderr, "GetServerETagValueThread(): curl_easy_perform() failed: %s\n",
curl_easy_strerror(claconncode));
int http_code = 0;
curl_easy_getinfo(conn, CURLINFO_RESPONSE_CODE, &http_code);
} else {
- fprintf(stderr, "curl_easy_perform() failed: %s\n",
+ fprintf(stderr, "GetServerETagValueThread(): curl_easy_perform() failed: %s\n",
curl_easy_strerror(claconncode));
int http_code = 0;
curl_easy_getinfo(conn, CURLINFO_RESPONSE_CODE, &http_code);
curl_easy_setopt(conn, CURLOPT_WRITEDATA, &PageData);
curl_easy_setopt(conn, CURLOPT_WRITEHEADER, &PageHeader);
+ SetConnectionObject(conn);
+
conncode = (curl_easy_perform(conn));
// Check if the SSL certificate is valid or self-signed or some other
curl_easy_setopt(connssldata, CURLOPT_SSL_VERIFYPEER, 0L);
curl_easy_setopt(connssldata, CURLOPT_SSL_VERIFYHOST, 0L);
+ SetConnectionObject(connssldata);
+
CURLcode certfetchcode;
certfetchcode = (curl_easy_perform(connssldata));
#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
\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
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
// 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
\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
wxString GetDefaultAddressBookURL();
void GetSSLResults();
SSLCertCollection GetCertificateData();
- static SSLCertCollection BuildSSLCollection(CURL *conn);
+ static SSLCertCollection BuildSSLCollection(CURL *conn);
wxString ETagValueResult();
wxString GetErrorMessage();
-
+ static size_t WritebackFunc(char *ptr, size_t size, size_t nmemb, wxString *stream);
+ static CURL* GetConnectionObject();
+ static void SetConnectionObject(CURL *ConnectionObject);
+#if defined(__APPLE__)
+ SecTrustRef GetTrustObject();
+#endif
+
// SSL Verification tests when connecting.
static CURLcode SSLVerifyTest();
//size_t WritebackFunc(char *ptr, size_t size, size_t nmemb, FILE *userdata);
private:
+#if defined(__APPLE__)
+ static SSLContext *SSLContextPointer;
+ static SecTrustRef SecTrustObject;
+#endif
+ static CURL* ConnectionObject;
static wxString ServerAddress;
static int ServerPort;
static wxString ServerUser;