Kaydet (Commit) 6d8598ac authored tarafından Ashod Nakashian's avatar Ashod Nakashian Kaydeden (comit) Ashod Nakashian

svl: populate subject and date-time when verifying signature

Change-Id: I50eeabf3e18176cac383f48797daa771ee9dc7e4
Reviewed-on: https://gerrit.libreoffice.org/41591Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarAshod Nakashian <ashnakash@gmail.com>
üst 9600f517
......@@ -114,6 +114,9 @@ struct SignatureInformation
/// For PDF: the byte range doesn't cover the whole document.
bool bPartialDocumentSignature;
/// The certificate owner (aka subject).
OUString ouSubject;
SignatureInformation( sal_Int32 nId )
{
nSecurityId = nId;
......
......@@ -2031,10 +2031,12 @@ bool Signing::Verify(const std::vector<unsigned char>& aData,
OUStringBuffer aBuffer;
comphelper::Base64::encode(aBuffer, aDerCert);
rInformation.ouX509Certificate = aBuffer.makeStringAndClear();
rInformation.ouSubject = OUString(pCertificate->subjectName, PL_strlen(pCertificate->subjectName), RTL_TEXTENCODING_UTF8);
}
PRTime nSigningTime;
// This may fail, in which case the date should be taken from the dictionary's "M" key.
// This may fail, in which case the date should be taken from the PDF's dictionary's "M" key,
// so not critical for PDF at least.
if (NSS_CMSSignerInfo_GetSigningTime(pCMSSignerInfo, &nSigningTime) == SECSuccess)
{
// First convert the UTC UNIX timestamp to a tools::DateTime.
......@@ -2044,6 +2046,20 @@ bool Signing::Verify(const std::vector<unsigned char>& aData,
// Then convert to a local UNO DateTime.
aDateTime.ConvertToLocalTime();
rInformation.stDateTime = aDateTime.GetUNODateTime();
if (rInformation.ouDateTime.isEmpty())
{
OUStringBuffer rBuffer;
rBuffer.append((sal_Int32) aDateTime.GetYear());
rBuffer.append('-');
if (aDateTime.GetMonth() < 10)
rBuffer.append('0');
rBuffer.append((sal_Int32) aDateTime.GetMonth());
rBuffer.append('-');
if (aDateTime.GetDay() < 10)
rBuffer.append('0');
rBuffer.append((sal_Int32) aDateTime.GetDay());
rInformation.ouDateTime = rBuffer.makeStringAndClear();
}
}
// Check if we have a signing certificate attribute.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment