Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Win32 Support: Add basic SSL verification.
authorSteve Brokenshire <sbrokenshire@xestia.co.uk>
Thu, 12 May 2016 20:47:41 +0000 (21:47 +0100)
committerSteve Brokenshire <sbrokenshire@xestia.co.uk>
Thu, 12 May 2016 20:47:41 +0000 (21:47 +0100)
source/carddav/carddav-sslverify.cpp
source/carddav/carddav.cpp
source/carddav/carddav.h

index 9418e5a..57b11c0 100644 (file)
@@ -74,10 +74,10 @@ CURLcode CardDAV::SSLVerifyTest(){
                curl_easy_setopt(conn, CURLOPT_WRITEDATA, &PageData);
                curl_easy_setopt(conn, CURLOPT_WRITEHEADER, &PageHeader);
 
-#if defined(__APPLE__)
+#if defined(__APPLE__) || defined(__WIN32__)
                
                SetConnectionObject(conn);
-               
+
 #endif
                 
                conncode = (curl_easy_perform(conn));
@@ -107,16 +107,18 @@ CURLcode CardDAV::SSLVerifyTest(){
                        curl_easy_setopt(connssldata, CURLOPT_SSL_VERIFYPEER, 0L);
                        curl_easy_setopt(connssldata, CURLOPT_SSL_VERIFYHOST, 0L);
 
-#if defined(__APPLE__)
+#if defined(__APPLE__) || defined(__WIN32__)
                        
                         SetConnectionObject(connssldata);
-                       
+
 #endif
                        
                        CURLcode certfetchcode;
 
                        certfetchcode = (curl_easy_perform(connssldata));
 
+#if !defined(__APPLE__) && !defined(__WIN32__) 
+
                        VerifyCertCollection = BuildSSLCollection(connssldata);
 
                        if (certfetchcode == CURLE_OK){
@@ -131,6 +133,8 @@ CURLcode CardDAV::SSLVerifyTest(){
 
                        }
 
+#endif
+
                        *ServerResult = FALSE;
 
                } else {
index 8cbc71e..5276cb7 100644 (file)
@@ -50,6 +50,21 @@ size_t CardDAV::WritebackFunc(char *ptr, size_t size, size_t nmemb, wxString *st
                SSLCopyPeerTrust((SSLContext*)TLSInfo->internals, &SecTrustObject);\r
        }\r
        \r
+#elif defined(__WIN32__)\r
+\r
+       const struct curl_tlssessioninfo *TLSInfo;\r
+       CURLcode TLSCode;\r
+       CURL *Connection = GetConnectionObject();\r
+       TLSCode = curl_easy_getinfo(Connection, CURLINFO_TLS_SSL_PTR, &TLSInfo);\r
+\r
+       std::string CertName;\r
+\r
+       if (TLSInfo->internals != nullptr && TLSCode == CURLE_OK){\r
+               PCtxtHandle SSLHandle = (PCtxtHandle)TLSInfo->internals;\r
+               SECURITY_STATUS GetData = QueryContextAttributes(SSLHandle, SECPKG_ATTR_REMOTE_CERT_CONTEXT, &CertificateData);\r
+               //QueryContextAttributesA(TLSInfo->internals, SECPKG_);\r
+       }\r
+\r
 #endif\r
        \r
        return size * nmemb;\r
@@ -110,6 +125,11 @@ bool CardDAV::AllowSelfSign;
 #if defined(__APPLE__)\r
 SSLContext *CardDAV::SSLContextPointer;\r
 SecTrustRef CardDAV::SecTrustObject;\r
+#endif\r
+#if defined(__WIN32__)\r
+PCCERT_CONTEXT CardDAV::CertificateData;\r
+#endif\r
+#if defined(__APPLE__) || defined(__WIN32__)\r
 CURL *CardDAV::ConnectionObject;\r
 #endif\r
 \r
@@ -480,7 +500,7 @@ wxString CardDAV::GetErrorMessage(){
 \r
 }\r
 \r
-#if defined(__APPLE__)\r
+#if defined(__APPLE__) || defined(__WIN32__)\r
 \r
 CURL* CardDAV::GetConnectionObject(){\r
        \r
@@ -498,4 +518,24 @@ void CardDAV::SetConnectionObject(CURL *ConnectionObjectIn){
        \r
 }\r
 \r
+#endif\r
+\r
+#if defined(__WIN32__)\r
+\r
+PCCERT_CONTEXT CardDAV::GetCertificateContextPointer(){\r
+\r
+       // Get the certificate data.\r
+\r
+       return CertificateData;\r
+\r
+}\r
+\r
+CERT_CONTEXT CardDAV::GetCertificateContext(){\r
+\r
+       // Get the certificate data.\r
+\r
+       return *CertificateData;\r
+\r
+}\r
+\r
 #endif
\ No newline at end of file
index 6afc3f8..9bdd973 100644 (file)
 #include <libxml/parser.h>
 #include <libxml/tree.h>
 #include <curl/curl.h>
+#if defined(__WIN32__)
+#include <security.h>
+#include <schannel.h>
+#endif
 #include "../vcard/vcard.h"
 #include "../actmgr/frmActivityMgr.h"
 #include "../common/sslcertstructs.h"
@@ -107,10 +111,16 @@ class CardDAV
                wxString ETagValueResult();
                wxString GetErrorMessage();
                static size_t WritebackFunc(char *ptr, size_t size, size_t nmemb, wxString *stream);
-#if defined(__APPLE__)
+#if defined(__APPLE__) || defined(__WIN32__)
                static CURL* GetConnectionObject();
                static void SetConnectionObject(CURL *ConnectionObject);
+#endif
+
+#if defined(__APPLE__)
                SecTrustRef GetTrustObject();
+#elif defined(__WIN32__)
+               PCCERT_CONTEXT GetCertificateContextPointer();
+               CERT_CONTEXT GetCertificateContext();
 #endif
     
                // SSL Verification tests when connecting.
@@ -120,10 +130,14 @@ class CardDAV
 
                //size_t WritebackFunc(char *ptr, size_t size, size_t nmemb, FILE *userdata);
        private:
+#if defined(__APPLE__) || defined(__WIN32__)
+               static CURL* ConnectionObject;
+#endif
 #if defined(__APPLE__)
                static SSLContext *SSLContextPointer;
                static SecTrustRef SecTrustObject;
-               static CURL* ConnectionObject;
+#elif defined(__WIN32__)
+               static PCCERT_CONTEXT CertificateData;
 #endif
                static wxString ServerAddress;
                static int ServerPort;
Xestia Software Development
Yn Maystri
© 2006 - 2019 Xestia Software Development
Software

Xestia Address Book
Xestia Calendar
Development

Xestia Gelforn
Everything else

About
News
Privacy Policy