xmlsecurity/source/gpg/SecurityEnvironment.cxx | 27 ++++++++++++------------- 1 file changed, 13 insertions(+), 14 deletions(-)
New commits: commit fa05bf54c923d0a8fc648593a001358a100e6285 Author: Samuel Mehrbrodt <samuel.mehrbr...@cib.de> Date: Tue Mar 14 21:28:17 2017 +0100 gpg4libre: Don't mark all keys as private Only those that can sign (have a private key) Change-Id: I1c8b553a788a14c236022c819cbc346fc4735daf Reviewed-on: https://gerrit.libreoffice.org/35202 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Samuel Mehrbrodt <samuel.mehrbr...@cib.de> diff --git a/xmlsecurity/source/gpg/SecurityEnvironment.cxx b/xmlsecurity/source/gpg/SecurityEnvironment.cxx index 64b4224..27d71e0 100644 --- a/xmlsecurity/source/gpg/SecurityEnvironment.cxx +++ b/xmlsecurity/source/gpg/SecurityEnvironment.cxx @@ -160,22 +160,21 @@ sal_Int32 SecurityEnvironmentGpg::verifyCertificate( const Reference< XCertifica } sal_Int32 SecurityEnvironmentGpg::getCertificateCharacters( - const Reference< XCertificate >& /*aCert*/) -{ -// const CertificateImpl* xCert; -// const GpgME::Key* key; -// -// Reference< XUnoTunnel > xCertTunnel(aCert, UNO_QUERY_THROW) ; -// xCert = reinterpret_cast<CertificateImpl*>(sal::static_int_cast<sal_uIntPtr>(xCertTunnel->getSomething(CertificateImpl::getUnoTunnelId()))) ; -// if (xCert == nullptr) -// throw RuntimeException(); -// -// key = xCert->getCertificate(); -// + const Reference< XCertificate >& aCert) +{ + const CertificateImpl* xCert; + const GpgME::Key* key; + + Reference< XUnoTunnel > xCertTunnel(aCert, UNO_QUERY_THROW) ; + xCert = reinterpret_cast<CertificateImpl*>(sal::static_int_cast<sal_uIntPtr>(xCertTunnel->getSomething(CertificateImpl::getUnoTunnelId()))) ; + if (xCert == nullptr) + throw RuntimeException(); + + key = xCert->getCertificate(); sal_Int32 characters = 0x0; - // TODO There is a bug in gpgme, hasSecret() always returns false. Need to find a workaround. - //if (key->hasSecret()) + // We need to use canSign() instead of hasSecret() because of a bug in the latter. + if (key->canSign()) characters |= CertificateCharacters::HAS_PRIVATE_KEY; return characters; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits