eap::get_cert_title() moved from TLS_UI to TLS
This commit is contained in:
parent
0ee9bade32
commit
faea2f3771
@ -20,12 +20,22 @@
|
|||||||
|
|
||||||
#include <sal.h>
|
#include <sal.h>
|
||||||
|
|
||||||
|
#include <WinStd/Common.h>
|
||||||
|
|
||||||
|
#include <Windows.h>
|
||||||
|
#include <WinCrypt.h> // Must include after <Windows.h>
|
||||||
|
|
||||||
namespace eap
|
namespace eap
|
||||||
{
|
{
|
||||||
///
|
///
|
||||||
/// TLS configuration
|
/// TLS configuration
|
||||||
///
|
///
|
||||||
class config_tls;
|
class config_tls;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Helper function to compile human-readable certificate name for UI display
|
||||||
|
///
|
||||||
|
winstd::tstring get_cert_title(PCCERT_CONTEXT cert);
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace eapserial
|
namespace eapserial
|
||||||
|
@ -20,10 +20,48 @@
|
|||||||
|
|
||||||
#include "StdAfx.h"
|
#include "StdAfx.h"
|
||||||
|
|
||||||
|
#pragma comment(lib, "Cryptui.lib")
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace winstd;
|
using namespace winstd;
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// eap::get_cert_title
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
tstring eap::get_cert_title(PCCERT_CONTEXT cert)
|
||||||
|
{
|
||||||
|
tstring name, str, issuer, title;
|
||||||
|
FILETIME ft;
|
||||||
|
SYSTEMTIME st;
|
||||||
|
|
||||||
|
// Prepare certificate information
|
||||||
|
CertGetNameString(cert, CERT_NAME_SIMPLE_DISPLAY_TYPE, 0, NULL, name);
|
||||||
|
title += name;
|
||||||
|
|
||||||
|
FileTimeToLocalFileTime(&(cert->pCertInfo->NotBefore), &ft);
|
||||||
|
FileTimeToSystemTime(&ft, &st);
|
||||||
|
GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &st, NULL, str);
|
||||||
|
title += _T(", ");
|
||||||
|
title += str;
|
||||||
|
|
||||||
|
FileTimeToLocalFileTime(&(cert->pCertInfo->NotAfter ), &ft);
|
||||||
|
FileTimeToSystemTime(&ft, &st);
|
||||||
|
GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &st, NULL, str);
|
||||||
|
title += _T('-');
|
||||||
|
title += str;
|
||||||
|
|
||||||
|
CertGetNameString(cert, CERT_NAME_SIMPLE_DISPLAY_TYPE, CERT_NAME_ISSUER_FLAG, NULL, issuer);
|
||||||
|
if (name != issuer) {
|
||||||
|
title += _T(", ");
|
||||||
|
title += issuer;
|
||||||
|
}
|
||||||
|
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
// eap::config_tls
|
// eap::config_tls
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
@ -191,7 +229,7 @@ bool eap::config_tls::load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEa
|
|||||||
string str;
|
string str;
|
||||||
WideCharToMultiByte(CP_UTF8, 0, bstrServerID, bstrServerID.length(), str, NULL, NULL);
|
WideCharToMultiByte(CP_UTF8, 0, bstrServerID, bstrServerID.length(), str, NULL, NULL);
|
||||||
|
|
||||||
m_server_names.push_back(str);
|
m_server_names.push_back(str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,8 +27,8 @@
|
|||||||
#include <wx/filedlg.h>
|
#include <wx/filedlg.h>
|
||||||
#include <wx/msgdlg.h>
|
#include <wx/msgdlg.h>
|
||||||
|
|
||||||
#include <cryptuiapi.h>
|
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
|
#include <cryptuiapi.h>
|
||||||
#include <WinCrypt.h> // Must include after <Windows.h>
|
#include <WinCrypt.h> // Must include after <Windows.h>
|
||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
@ -75,14 +75,6 @@ template <class _Tprov> class wxEAPTLSCredentialsConfigPanel;
|
|||||||
///
|
///
|
||||||
template <class _Tprov> class wxEAPTLSConfigPanel;
|
template <class _Tprov> class wxEAPTLSConfigPanel;
|
||||||
|
|
||||||
namespace eap
|
|
||||||
{
|
|
||||||
///
|
|
||||||
/// Helper function to compile human-readable certificate name for UI display
|
|
||||||
///
|
|
||||||
void get_cert_title(PCCERT_CONTEXT cert, winstd::tstring &title);
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../res/wxTLS_UI.h"
|
#include "../res/wxTLS_UI.h"
|
||||||
@ -297,8 +289,7 @@ protected:
|
|||||||
m_cred.m_cert &&
|
m_cred.m_cert &&
|
||||||
m_cred.m_cert->cbCertEncoded == data->m_cert->cbCertEncoded &&
|
m_cred.m_cert->cbCertEncoded == data->m_cert->cbCertEncoded &&
|
||||||
memcmp(m_cred.m_cert->pbCertEncoded, data->m_cert->pbCertEncoded, m_cred.m_cert->cbCertEncoded) == 0;
|
memcmp(m_cred.m_cert->pbCertEncoded, data->m_cert->pbCertEncoded, m_cred.m_cert->cbCertEncoded) == 0;
|
||||||
winstd::tstring name;
|
winstd::tstring name(std::move(eap::get_cert_title(cert)));
|
||||||
eap::get_cert_title(cert, name);
|
|
||||||
int i = m_cert_select_val->Append(name, data.release());
|
int i = m_cert_select_val->Append(name, data.release());
|
||||||
if (is_selected) {
|
if (is_selected) {
|
||||||
m_cert_select_val->SetSelection(i);
|
m_cert_select_val->SetSelection(i);
|
||||||
|
@ -20,46 +20,9 @@
|
|||||||
|
|
||||||
#include "StdAfx.h"
|
#include "StdAfx.h"
|
||||||
|
|
||||||
#pragma comment(lib, "Cryptui.lib")
|
|
||||||
#pragma comment(lib, "Crypt32.lib")
|
#pragma comment(lib, "Crypt32.lib")
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
|
||||||
// eap::get_cert_title
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
void eap::get_cert_title(PCCERT_CONTEXT cert, winstd::tstring &title)
|
|
||||||
{
|
|
||||||
winstd::tstring name, str, issuer;
|
|
||||||
FILETIME ft;
|
|
||||||
SYSTEMTIME st;
|
|
||||||
|
|
||||||
title.clear();
|
|
||||||
|
|
||||||
// Prepare certificate information
|
|
||||||
CertGetNameString(cert, CERT_NAME_SIMPLE_DISPLAY_TYPE, 0, NULL, name);
|
|
||||||
title += name;
|
|
||||||
|
|
||||||
FileTimeToLocalFileTime(&(cert->pCertInfo->NotBefore), &ft);
|
|
||||||
FileTimeToSystemTime(&ft, &st);
|
|
||||||
GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &st, NULL, str);
|
|
||||||
title += _T(", ");
|
|
||||||
title += str;
|
|
||||||
|
|
||||||
FileTimeToLocalFileTime(&(cert->pCertInfo->NotAfter ), &ft);
|
|
||||||
FileTimeToSystemTime(&ft, &st);
|
|
||||||
GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &st, NULL, str);
|
|
||||||
title += _T('-');
|
|
||||||
title += str;
|
|
||||||
|
|
||||||
CertGetNameString(cert, CERT_NAME_SIMPLE_DISPLAY_TYPE, CERT_NAME_ISSUER_FLAG, NULL, issuer);
|
|
||||||
if (name != issuer) {
|
|
||||||
title += _T(", ");
|
|
||||||
title += issuer;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
// wxCertificateClientData
|
// wxCertificateClientData
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
Loading…
x
Reference in New Issue
Block a user