From ab4e6d85bcea35c5a8971e9415bfcfed71395d06 Mon Sep 17 00:00:00 2001 From: SET Date: Tue, 24 Nov 2020 19:07:54 +0100 Subject: [PATCH] Log subject common name also. May help understanding problems. --- GpgMELogger.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/GpgMELogger.h b/GpgMELogger.h index f0777dd..f915a3e 100644 --- a/GpgMELogger.h +++ b/GpgMELogger.h @@ -13,6 +13,8 @@ #include #include #include +#include +#include #include #include @@ -26,10 +28,26 @@ static void LogGpgMEError(const GpgME::Error& e) if (e.code() == 0) return; std::unique_lock lock(gs_logGpgMEError); + + const vector * dnAttr + = &(WApplication::instance()->environment().sslInfo() + ->clientCertificate().subjectDn()); + WString subjectCommonName = WString::Empty; + for (uint i = 0; i < dnAttr->size(); i++) + { + if (dnAttr->at(i).name() == WSslCertificate::DnAttributeName::CommonName) + { + subjectCommonName = dnAttr->at(i).value(); + break; + } + } + + const string logfile = WApplication::appRoot() + string("gpgme.log"); WLogger logger; logger.setFile(logfile); logger.entry("") << WLogger::timestamp + << WLogger::sep << subjectCommonName << WLogger::sep << WApplication::instance()->environment().userAgent() << WLogger::sep << std::to_string(e.code()) << WLogger::sep << e.asString();