summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2021-11-24 10:27:01 +0100
committerTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2021-11-24 10:35:57 +0100
commit72accbcbd352f54f9828bd03ef445a6f667b32ec (patch)
tree39263bbeac6b95d63ddc2bbca3d12f2a05712203
parent1c1b495515eb786b91d87f3c42035b376c5147fe (diff)
Add missing GetSubjectName for Windows buildmimo-5.4.7.2.M9
Change-Id: Ibffc5edd3c0937994c405f82ba8656c24c154342
-rw-r--r--xmlsecurity/source/pdfio/pdfdocument.cxx46
1 files changed, 46 insertions, 0 deletions
diff --git a/xmlsecurity/source/pdfio/pdfdocument.cxx b/xmlsecurity/source/pdfio/pdfdocument.cxx
index effc754f8ec7..2afba0e4cbc1 100644
--- a/xmlsecurity/source/pdfio/pdfdocument.cxx
+++ b/xmlsecurity/source/pdfio/pdfdocument.cxx
@@ -209,6 +209,52 @@ bad_data:
return rv;
}
#elif defined XMLSEC_CRYPTO_MSCRYPTO
+
+OUString GetSubjectName(PCCERT_CONTEXT pCertContext)
+{
+ OUString subjectName;
+
+ // Get Subject name size.
+ DWORD dwData = CertGetNameStringW(pCertContext,
+ CERT_NAME_SIMPLE_DISPLAY_TYPE,
+ 0,
+ nullptr,
+ nullptr,
+ 0);
+ if (!dwData)
+ {
+ SAL_WARN("xmlsecurity.pdfio", "ValidateSignature: CertGetNameString failed");
+ return subjectName;
+ }
+
+ // Allocate memory for subject name.
+ LPWSTR szName = static_cast<LPWSTR>(
+ LocalAlloc(LPTR, dwData * sizeof(WCHAR)));
+ if (!szName)
+ {
+ SAL_WARN("xmlsecurity.pdfio", "ValidateSignature: Unable to allocate memory for subject name");
+ return subjectName;
+ }
+
+ // Get subject name.
+ if (!CertGetNameStringW(pCertContext,
+ CERT_NAME_SIMPLE_DISPLAY_TYPE,
+ 0,
+ nullptr,
+ szName,
+ dwData))
+ {
+ LocalFree(szName);
+ SAL_WARN("xmlsecurity.pdfio", "ValidateSignature: CertGetNameString failed");
+ return subjectName;
+ }
+
+ subjectName = SAL_U(szName);
+ LocalFree(szName);
+
+ return subjectName;
+}
+
/// Verifies a non-detached signature using CryptoAPI.
bool VerifyNonDetachedSignature(SvStream& rStream, std::vector<std::pair<size_t, size_t>>& rByteRanges, std::vector<BYTE>& rExpectedHash)
{