summaryrefslogtreecommitdiff
path: root/xmlsecurity/source/gpg/SecurityEnvironment.cxx
diff options
context:
space:
mode:
authorSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2017-06-27 16:33:59 +0200
committerSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2017-06-28 09:39:29 +0200
commit0d7b437260ec991ee70769e7fb1002973e431f12 (patch)
treeaf4c1d3f2b831ee889782403b503a0d4b9553739 /xmlsecurity/source/gpg/SecurityEnvironment.cxx
parent7931ef2abbcef22de5cdddd26738e4dd8d1d8ca5 (diff)
tdf#108794 gpg4libre: Use key id to get the right key
Change-Id: I5950d192e19e652cbb7680db426bfbd28907a1cb Reviewed-on: https://gerrit.libreoffice.org/39308 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Diffstat (limited to 'xmlsecurity/source/gpg/SecurityEnvironment.cxx')
-rw-r--r--xmlsecurity/source/gpg/SecurityEnvironment.cxx14
1 files changed, 10 insertions, 4 deletions
diff --git a/xmlsecurity/source/gpg/SecurityEnvironment.cxx b/xmlsecurity/source/gpg/SecurityEnvironment.cxx
index 37abf31111a1..45c89f1545d0 100644
--- a/xmlsecurity/source/gpg/SecurityEnvironment.cxx
+++ b/xmlsecurity/source/gpg/SecurityEnvironment.cxx
@@ -16,6 +16,7 @@
#include <key.h>
#include <keylistresult.h>
+#include "xmlsec-wrapper.h"
using namespace css;
using namespace css::security;
@@ -97,18 +98,23 @@ Sequence< Reference < XCertificate > > SecurityEnvironmentGpg::getPersonalCertif
return xCertificateSequence;
}
-Reference< XCertificate > SecurityEnvironmentGpg::getCertificate( const OUString& issuerName, const Sequence< sal_Int8 >& /*serialNumber*/ )
+Reference< XCertificate > SecurityEnvironmentGpg::getCertificate( const OUString& keyId, const Sequence< sal_Int8 >& /*serialNumber*/ )
{
CertificateImpl* xCert=nullptr;
+ //xmlChar* pSignatureValue=xmlNodeGetContent(cur);
+ OString ostr = OUStringToOString( keyId , RTL_TEXTENCODING_UTF8 );
+ const xmlChar* strKeyId = reinterpret_cast<const xmlChar*>(ostr.getStr());
+ if(xmlSecBase64Decode(strKeyId, const_cast<xmlSecByte*>(strKeyId), xmlStrlen(strKeyId)) < 0)
+ throw RuntimeException("Base64 decode failed");
+
m_ctx->setKeyListMode(GPGME_KEYLIST_MODE_LOCAL);
- OString ostr = OUStringToOString( issuerName , RTL_TEXTENCODING_UTF8 );
- GpgME::Error err = m_ctx->startKeyListing(ostr.getStr(), true);
+ GpgME::Error err = m_ctx->startKeyListing("", true);
while (!err) {
GpgME::Key k = m_ctx->nextKey(err);
if (err)
break;
- if (!k.isInvalid()) {
+ if (!k.isInvalid() && strcmp(k.keyID(), reinterpret_cast<const char*>(strKeyId)) == 0) {
xCert = new CertificateImpl();
xCert->setCertificate(m_ctx.get(), k);
m_ctx->endKeyListing();