X-Git-Url: http://Server1/repobrowser/?a=blobdiff_plain;f=source%2Fcarddav%2Fcarddav.cpp;h=5276cb760fbccf835f12c50506fd237f512137fe;hb=71fe3c25d1299666d5752df3e3263b03fa85594e;hp=a7cc43df0bf229b22a983235bf57716869c9652f;hpb=a10f6a5be860215492885ab324760b603a5d22fa;p=xestiaab%2F.git diff --git a/source/carddav/carddav.cpp b/source/carddav/carddav.cpp index a7cc43d..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(){ @@ -239,23 +279,6 @@ bool CardDAV::IsSelfSigned(){ } -/* - -size_t CardDAV::WritebackFunc(char *ptr, size_t size, size_t nmemb, FILE *stream){ - - wxString Data; - Data = wxString::FromUTF8((char *)ptr); - if ((bool)stream == TRUE){ - PageHeader.Append(Data); - } else { - PageData.Append(Data); - } - return size * nmemb; - -} - -*/ - int CardDAV::ProgressFuncProc(void *clientdata, double TTUp, double NUp, double TTDown, double NDown){ // Progress function processing. @@ -337,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; - } + }*/ } @@ -475,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