diff options
author | Ashod Nakashian <ashod.nakashian@collabora.co.uk> | 2017-08-25 13:45:32 -0400 |
---|---|---|
committer | Ashod Nakashian <ashnakash@gmail.com> | 2017-08-28 03:49:01 +0200 |
commit | 6d8598acb23bbecb55ac235c15b9e01885588ad7 (patch) | |
tree | 2d458f17d29a7072219c042c93100180ea6bc619 /svl | |
parent | 9600f5179795380749aa5a7c9fa0bf5387d2b95f (diff) |
svl: populate subject and date-time when verifying signature
Change-Id: I50eeabf3e18176cac383f48797daa771ee9dc7e4
Reviewed-on: https://gerrit.libreoffice.org/41591
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Diffstat (limited to 'svl')
-rw-r--r-- | svl/source/crypto/cryptosign.cxx | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/svl/source/crypto/cryptosign.cxx b/svl/source/crypto/cryptosign.cxx index dab47be4e5cc..44175c53961c 100644 --- a/svl/source/crypto/cryptosign.cxx +++ b/svl/source/crypto/cryptosign.cxx @@ -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. |