X-Git-Url: http://Server1/repobrowser/?a=blobdiff_plain;ds=sidebyside;f=source%2Fcarddav%2Fcarddav.cpp;h=5276cb760fbccf835f12c50506fd237f512137fe;hb=66e841c8847db860ad378b330ae5344554f53d35;hp=fb07b50f0d403947da7025ba5523ffefcdf98865;hpb=f7c42f023c68ec189d29e7ca8f3c75d3847f65e2;p=xestiaab%2F.git diff --git a/source/carddav/carddav.cpp b/source/carddav/carddav.cpp index fb07b50..5276cb7 100644 --- a/source/carddav/carddav.cpp +++ b/source/carddav/carddav.cpp @@ -28,7 +28,7 @@ #include "../vcard/vcard.h" #include "../common/dirs.h" -size_t WritebackFunc(char *ptr, size_t size, size_t nmemb, wxString *stream){ +size_t CardDAV::WritebackFunc(char *ptr, size_t size, size_t nmemb, wxString *stream){ // Writeback function for the CardDAV object. @@ -37,6 +37,36 @@ size_t WritebackFunc(char *ptr, size_t size, size_t nmemb, wxString *stream){ stream->Append(Data); + // Get the SSL engine pointer and trust if required on certain operating systems. + +#if defined(__APPLE__) + + const struct curl_tlssessioninfo *TLSInfo; + CURLcode TLSCode; + CURL *Connection = GetConnectionObject(); + TLSCode = curl_easy_getinfo(Connection, CURLINFO_TLS_SSL_PTR, &TLSInfo); + + if (TLSInfo->internals != nullptr && TLSCode == CURLE_OK){ + SSLCopyPeerTrust((SSLContext*)TLSInfo->internals, &SecTrustObject); + } + +#elif defined(__WIN32__) + + const struct curl_tlssessioninfo *TLSInfo; + CURLcode TLSCode; + CURL *Connection = GetConnectionObject(); + TLSCode = curl_easy_getinfo(Connection, CURLINFO_TLS_SSL_PTR, &TLSInfo); + + std::string CertName; + + if (TLSInfo->internals != nullptr && TLSCode == CURLE_OK){ + PCtxtHandle SSLHandle = (PCtxtHandle)TLSInfo->internals; + SECURITY_STATUS GetData = QueryContextAttributes(SSLHandle, SECPKG_ATTR_REMOTE_CERT_CONTEXT, &CertificateData); + //QueryContextAttributesA(TLSInfo->internals, SECPKG_); + } + +#endif + return size * nmemb; } @@ -92,6 +122,16 @@ int CardDAV::HTTPErrorCode; wxString CardDAV::ErrorMessage; SSLCertCollection CardDAV::VerifyCertCollection; bool CardDAV::AllowSelfSign; +#if defined(__APPLE__) +SSLContext *CardDAV::SSLContextPointer; +SecTrustRef CardDAV::SecTrustObject; +#endif +#if defined(__WIN32__) +PCCERT_CONTEXT CardDAV::CertificateData; +#endif +#if defined(__APPLE__) || defined(__WIN32__) +CURL *CardDAV::ConnectionObject; +#endif CardDAV::CardDAV(){ @@ -320,13 +360,13 @@ void CardDAV::SetupData(wxString Method, wxString FilenameLocation, wxString Upl // Check if ServerFilenameLocation has a / at // the start and if not then append it. - if (ServerFilenameLocation.Left(1) != wxT("/")){ + /*if (ServerFilenameLocation.Left(1) != wxT("/")){ // Not there so insert. ServerFilenameLocation = wxT("/") + ServerFilenameLocation; - } + }*/ } @@ -458,4 +498,44 @@ wxString CardDAV::GetErrorMessage(){ return ErrorMessage; -} \ No newline at end of file +} + +#if defined(__APPLE__) || defined(__WIN32__) + +CURL* CardDAV::GetConnectionObject(){ + + // Get the CardDAV connection object. + + return ConnectionObject; + +} + +void CardDAV::SetConnectionObject(CURL *ConnectionObjectIn){ + + // Set the connection object. + + ConnectionObject = ConnectionObjectIn; + +} + +#endif + +#if defined(__WIN32__) + +PCCERT_CONTEXT CardDAV::GetCertificateContextPointer(){ + + // Get the certificate data. + + return CertificateData; + +} + +CERT_CONTEXT CardDAV::GetCertificateContext(){ + + // Get the certificate data. + + return *CertificateData; + +} + +#endif \ No newline at end of file