X-Git-Url: http://Server1/repobrowser/?a=blobdiff_plain;f=source%2Fcarddav%2Fcarddav.cpp;h=52ae03aa49eea14e7794553691f726e36290de01;hb=ff65774611d82f2bdbb6cb5c34829cc2e922cf68;hp=bc3a8f7310e9533f601f3a644c9f77217e8699f9;hpb=072c524faf30f84a30bf0fd40b2580d199967e74;p=xestiaab%2F.git diff --git a/source/carddav/carddav.cpp b/source/carddav/carddav.cpp index bc3a8f7..52ae03a 100644 --- a/source/carddav/carddav.cpp +++ b/source/carddav/carddav.cpp @@ -50,6 +50,26 @@ size_t CardDAV::WritebackFunc(char *ptr, size_t size, size_t nmemb, wxString *st 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){ + + // Free the previous certificate data. + + CertFreeCertificateContext(CertificateData); + + PCtxtHandle SSLHandle = (PCtxtHandle)TLSInfo->internals; + SECURITY_STATUS GetData = QueryContextAttributes(SSLHandle, SECPKG_ATTR_REMOTE_CERT_CONTEXT, &CertificateData); + + } + #endif return size * nmemb; @@ -110,6 +130,11 @@ 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 @@ -480,6 +505,8 @@ wxString CardDAV::GetErrorMessage(){ } +#if defined(__APPLE__) || defined(__WIN32__) + CURL* CardDAV::GetConnectionObject(){ // Get the CardDAV connection object. @@ -494,4 +521,43 @@ void CardDAV::SetConnectionObject(CURL *ConnectionObjectIn){ ConnectionObject = ConnectionObjectIn; -} \ No newline at end of file +} + +#endif + +#if defined(__WIN32__) + +PCCERT_CONTEXT CardDAV::GetCertificateContextPointer(){ + + // Check that the PCCERT_CONTEXT has an address + // other than NULL. Return nullptr if this is the + // case. + + if (CertificateData == NULL){ + return NULL; + } + + // Get the certificate data. + + return CertificateData; + +} + +CERT_CONTEXT CardDAV::GetCertificateContext(){ + + // Check that the PCCERT_CONTEXT has an address + // other than NULL. Return nullptr if this is the + // case. + + if (CertificateData == NULL){ + CERT_CONTEXT EmptyCertificateData = { 0 }; + return EmptyCertificateData; + } + + // Get the certificate data. + + return *CertificateData; + +} + +#endif \ No newline at end of file