+ // Writeback function for the CardDAV object.
+
+ CalDAVPassObject *data = static_cast<CalDAVPassObject*>(stream);
+ data->DataSetting->append(receivedBuffer);
+
+ // Get the SSL engine pointer and trust if required on certain operating systems.
+
+ if (data->ServerUsingSSL == true) {
+
+#if defined(__APPLE__)
+
+ const struct curl_tlssessioninfo *TLSInfo;
+ CURLcode TLSCode;
+ TLSCode = curl_easy_getinfo(data->ConnectionSessionObject, CURLINFO_TLS_SSL_PTR, &TLSInfo);
+
+ SecTrustRef CertificateData;
+
+ if (TLSInfo->internals != nullptr && TLSCode == CURLE_OK) {
+ SSLCopyPeerTrust((SSLContext*)TLSInfo->internals, &CertificateData);
+ data->SSLContext = CertificateData;
+ }
+
+#elif defined(__WIN32__)
+
+ const struct curl_tlssessioninfo *TLSInfo;
+ CURLcode TLSCode;
+ TLSCode = curl_easy_getinfo(data->ConnectionSessionObject, CURLINFO_TLS_SSL_PTR, &TLSInfo);
+
+ if (TLSInfo->internals != nullptr && TLSCode == CURLE_OK) {
+
+ // Free the previous certificate data.
+
+ //CertFreeCertificateContext(CertificateData);
+
+ PCCERT_CONTEXT CertificateData;
+
+ PCtxtHandle SSLHandle = (PCtxtHandle)TLSInfo->internals;
+ SECURITY_STATUS GetData = QueryContextAttributes(SSLHandle, SECPKG_ATTR_REMOTE_CERT_CONTEXT, &CertificateData);
+
+ data->SSLContext = CertificateData;
+
+ }
+
+#endif
+
+ }
+