diff options
Diffstat (limited to 'xmlsecurity/source/gpg/SecurityEnvironment.cxx')
-rw-r--r-- | xmlsecurity/source/gpg/SecurityEnvironment.cxx | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/xmlsecurity/source/gpg/SecurityEnvironment.cxx b/xmlsecurity/source/gpg/SecurityEnvironment.cxx index 83e6170a98c1..d120b2a985fa 100644 --- a/xmlsecurity/source/gpg/SecurityEnvironment.cxx +++ b/xmlsecurity/source/gpg/SecurityEnvironment.cxx @@ -59,11 +59,13 @@ OUString SecurityEnvironmentGpg::getSecurityEnvironmentInformation() Sequence< Reference < XCertificate > > SecurityEnvironmentGpg::getPersonalCertificates() { + // TODO: move to central init GpgME::initializeLibrary(); GpgME::Error err = GpgME::checkEngine(GpgME::OpenPGP); if (err) throw RuntimeException("The GpgME library failed to initialize for the OpenPGP protocol."); + // TODO: keep that around for SecurityEnvironmentGpg lifetime GpgME::Context* ctx = GpgME::Context::createForProtocol(GpgME::OpenPGP); if (ctx == nullptr) throw RuntimeException("The GpgME library failed to initialize for the OpenPGP protocol."); @@ -79,7 +81,7 @@ Sequence< Reference < XCertificate > > SecurityEnvironmentGpg::getPersonalCertif break; if (!k.isInvalid()) { xCert = new CertificateImpl(); - xCert->setCertificate(k); + xCert->setCertificate(ctx,k); certsList.push_back(xCert); } } @@ -96,11 +98,13 @@ Sequence< Reference < XCertificate > > SecurityEnvironmentGpg::getPersonalCertif Reference< XCertificate > SecurityEnvironmentGpg::getCertificate( const OUString& issuerName, const Sequence< sal_Int8 >& /*serialNumber*/ ) { + // TODO: move to central init GpgME::initializeLibrary(); GpgME::Error err = GpgME::checkEngine(GpgME::OpenPGP); if (err) throw RuntimeException("The GpgME library failed to initialize for the OpenPGP protocol."); + // TODO: keep that around for SecurityEnvironmentGpg lifetime GpgME::Context* ctx = GpgME::Context::createForProtocol(GpgME::OpenPGP); if (ctx == nullptr) throw RuntimeException("The GpgME library failed to initialize for the OpenPGP protocol."); @@ -117,13 +121,14 @@ Reference< XCertificate > SecurityEnvironmentGpg::getCertificate( const OUString break; if (!k.isInvalid()) { xCert = new CertificateImpl(); - xCert->setCertificate(k); + xCert->setCertificate(ctx, k); ctx->endKeyListing(); return xCert; } } ctx->endKeyListing(); + // TODO: cleanup ctx return nullptr; } |