X-Git-Url: http://Server1/repobrowser/?a=blobdiff_plain;f=source%2Fcarddav2%2Fcarddav2.cpp;h=dd70bab9a6c030ebd5843fc61efef84eac3545dc;hb=f69e09d827e06435ea94bb73aa71ab5f9d5c035b;hp=d7c77075d3a60b1555a55ff0ee19c9d0aa6b8f50;hpb=74f3b0f9b31a7573c18a003bf008b0cc2819f424;p=xestiaab%2F.git diff --git a/source/carddav2/carddav2.cpp b/source/carddav2/carddav2.cpp index d7c7707..dd70bab 100644 --- a/source/carddav2/carddav2.cpp +++ b/source/carddav2/carddav2.cpp @@ -18,8 +18,6 @@ #include "carddav2.h" -#include - using namespace std; CardDAV2::CardDAV2(string ServerAddress, int ServerPort, string ServerUser, string ServerPass, bool ServerSSL){ @@ -169,13 +167,13 @@ SSLCertCollectionString CardDAV2::BuildSSLCollection(){ certptr.certdata = NULL; - curl_easy_getinfo(ConnectionSession, CURLINFO_CERTINFO, &certptr.certinfo); - + 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; @@ -233,7 +231,7 @@ COConnectResult CardDAV2::Connect(bool DoAuthentication){ COConnectResult ConnectResult = COCONNECT_UNITTESTFAIL; string ServerAddressURL = BuildURL("/principals/"); - + curl_easy_setopt(ConnectionSession, CURLOPT_URL, ServerAddressURL.c_str()); if (TestMode == true){ @@ -241,7 +239,7 @@ COConnectResult CardDAV2::Connect(bool DoAuthentication){ } else { SessionResult = curl_easy_perform(ConnectionSession); } - + switch(SessionResult){ case CURLE_OK: case CURLE_HTTP_RETURNED_ERROR: @@ -249,6 +247,7 @@ COConnectResult CardDAV2::Connect(bool DoAuthentication){ SSLVerified = COSSL_VERIFIED; ConnectResult = COCONNECT_OK; break; + case CURLE_SSL_INVALIDCERTSTATUS: case CURLE_SSL_CACERT: case CURLE_SSL_CONNECT_ERROR: SSLStatus = true; @@ -1270,8 +1269,6 @@ COContactList CardDAV2::GetContactList(std::string SyncToken){ std::string SyncData; - // TODO: Copy old code from CardDAV class as needed. - if (SyncToken.size() > 0){ SyncData = "\n" @@ -1414,7 +1411,7 @@ void CardDAV2::SetupDefaultParametersNonSSL(bool DoAuthentication){ PageHeaderObject.ServerUsingSSL = false; curl_easy_setopt(ConnectionSession, CURLOPT_URL, ServerAddress.c_str()); - curl_easy_setopt(ConnectionSession, CURLOPT_NOPROGRESS, 0L); + curl_easy_setopt(ConnectionSession, CURLOPT_NOPROGRESS, 1L); curl_easy_setopt(ConnectionSession, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST|CURLAUTH_BASIC); curl_easy_setopt(ConnectionSession, CURLOPT_TIMEOUT, 60); curl_easy_setopt(ConnectionSession, CURLOPT_FAILONERROR, true); @@ -1455,6 +1452,7 @@ void CardDAV2::SetupDefaultParametersSSL(bool DoAuthentication){ curl_easy_setopt(ConnectionSession, CURLOPT_URL, ServerAddressURL.c_str()); curl_easy_setopt(ConnectionSession, CURLOPT_NOPROGRESS, 1L); + curl_easy_setopt(ConnectionSession, CURLOPT_CERTINFO, 1L); curl_easy_setopt(ConnectionSession, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST|CURLAUTH_BASIC); curl_easy_setopt(ConnectionSession, CURLOPT_TIMEOUT, 60); curl_easy_setopt(ConnectionSession, CURLOPT_FAILONERROR, 0L); @@ -1463,9 +1461,6 @@ void CardDAV2::SetupDefaultParametersSSL(bool DoAuthentication){ curl_easy_setopt(ConnectionSession, CURLOPT_WRITEDATA, &PageDataObject); curl_easy_setopt(ConnectionSession, CURLOPT_WRITEHEADER, &PageHeaderObject); curl_easy_setopt(ConnectionSession, CURLOPT_ERRORBUFFER, SessionErrorBuffer); - curl_easy_setopt(ConnectionSession, CURLOPT_NOSIGNAL, 1L); - curl_easy_setopt(ConnectionSession, CURLOPT_CERTINFO, 1L); - curl_easy_setopt(ConnectionSession, CURLOPT_VERBOSE, 2L); curl_easy_setopt(ConnectionSession, CURLOPT_CUSTOMREQUEST, "GET"); curl_easy_setopt(ConnectionSession, CURLOPT_HTTPHEADER, nullptr); curl_easy_setopt(ConnectionSession, CURLOPT_POSTFIELDS, nullptr); @@ -1496,9 +1491,12 @@ void CardDAV2::SetupDefaultParametersSSL(bool DoAuthentication){ string CertificateFilename = GetAccountDir(ServerAccount, true); if (wxFile::Exists(CertificateFilename)){ - + curl_easy_setopt(ConnectionSession, CURLOPT_CAINFO, CertificateFilename.c_str()); + // Force CURLOPT_SSL_VERIFYSTATUS to 0. + curl_easy_setopt(ConnectionSession, CURLOPT_SSL_VERIFYSTATUS, 0L); + } } @@ -1511,10 +1509,10 @@ string CardDAV2::BuildURL(string URI){ string ServerAddressURL; - if (SSLStatus == true){ + if (ServerSSL == true){ ServerAddressURL = "https://" + ServerAddress + ":" + to_string(ServerPort) + URI; } else { - ServerAddressURL = "https://" + ServerAddress + ":" + to_string(ServerPort) + URI; + ServerAddressURL = "http://" + ServerAddress + ":" + to_string(ServerPort) + URI; } return ServerAddressURL;