From 1232fa8930e8867be42f81d81c2493df2d09a7d3 Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Sun, 10 Dec 2017 00:33:40 +0000 Subject: [PATCH] Win32 SSPI: Implemented Win32 SSPI support using code from Xestia Address Book --- source/common/win32ssl.cpp | 55 ++++++++++++++++++++++++++++++++++++++ source/common/win32ssl.h | 35 ++++++++++++++++++++++++ source/main.cpp | 4 +++ 3 files changed, 94 insertions(+) create mode 100644 source/common/win32ssl.cpp create mode 100644 source/common/win32ssl.h diff --git a/source/common/win32ssl.cpp b/source/common/win32ssl.cpp new file mode 100644 index 0000000..266e319 --- /dev/null +++ b/source/common/win32ssl.cpp @@ -0,0 +1,55 @@ +// win32ssl.cpp - Win32 SSPI (SSL) support. +// +// (c) 2016-2017 Xestia Software Development. +// +// This file is part of Xestia Calendar (originally from Xestia Address Book). +// +// Xestia Address Book is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by the +// Free Software Foundation, version 3 of the license. +// +// Xestia Address Book is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with Xestia Address Book. If not, see + +#include "win32ssl.h" +#include "../objects/CalDAV/CalDAV.h" + +CRYPTUI_VIEWCERTIFICATE_STRUCTW BuildCertificateData(void *CalDAVObjectData, HWND WindowHandle){ + + PCCERT_CONTEXT CertificateContext = static_cast(CalDAVObjectData)->BuildSSLCollection(); + HCERTSTORE CertificateStore = CertificateContext->hCertStore; + CRYPTUI_VIEWCERTIFICATE_STRUCTW CertificateData = { 0 }; + CertificateData.hwndParent = WindowHandle; + CertificateData.dwFlags = CRYPTUI_ENABLE_ADDTOSTORE | CRYPTUI_DISABLE_HTMLLINK; + CertificateData.pCertContext = CertificateContext; + CertificateData.cStores = 1; + CertificateData.rghStores = &CertificateStore; + CertificateData.szTitle = _("Certificate Information"); + CertificateData.nStartPage = 0; + CertificateData.dwSize = sizeof(CertificateData); + + return CertificateData; + +} + +CRYPTUI_VIEWCERTIFICATE_STRUCTW BuildCertificateData(PCCERT_CONTEXT CertificateContext, HWND WindowHandle){ + + HCERTSTORE CertificateStore = CertificateContext->hCertStore; + CRYPTUI_VIEWCERTIFICATE_STRUCTW CertificateData = { 0 }; + CertificateData.hwndParent = WindowHandle; + CertificateData.dwFlags = CRYPTUI_DISABLE_HTMLLINK; + CertificateData.pCertContext = CertificateContext; + CertificateData.cStores = 1; + CertificateData.rghStores = &CertificateStore; + CertificateData.szTitle = _("Certificate Information"); + CertificateData.nStartPage = 0; + CertificateData.dwSize = sizeof(CertificateData); + + return CertificateData; + +} \ No newline at end of file diff --git a/source/common/win32ssl.h b/source/common/win32ssl.h new file mode 100644 index 0000000..3c757e3 --- /dev/null +++ b/source/common/win32ssl.h @@ -0,0 +1,35 @@ +// win32ssl.h - Win32 SSPI (SSL) support. +// +// (c) 2016-2017 Xestia Software Development. +// +// This file is part of Xestia Calendar (originally from Xestia Address Book). +// +// Xestia Address Book is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by the +// Free Software Foundation, version 3 of the license. +// +// Xestia Address Book is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with Xestia Address Book. If not, see + +#ifndef __COMMON_WIN32SSL_H__ +#define __COMMON_WIN32SSL_H__ + +#pragma once + +#include +#include +#include +#include +#include +#include +#include + +CRYPTUI_VIEWCERTIFICATE_STRUCTW BuildCertificateData(void *CalDAVObjectData, HWND WindowHandle); +CRYPTUI_VIEWCERTIFICATE_STRUCTW BuildCertificateData(PCCERT_CONTEXT CertificateContext, HWND WindowHandle); + +#endif \ No newline at end of file diff --git a/source/main.cpp b/source/main.cpp index ee0cd0b..ad99745 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -32,6 +32,10 @@ #include "forms/actmgr/frmActivityMgr.h" #include "defaults.h" +#ifdef __WIN32__ +#include "common/win32ssl.h" +#endif + class XestiaCALApp: public wxApp { virtual bool OnInit(); -- 2.39.5