diff options
author | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2017-03-14 21:28:17 +0100 |
---|---|---|
committer | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2017-03-15 14:09:19 +0000 |
commit | fa05bf54c923d0a8fc648593a001358a100e6285 (patch) | |
tree | e8e1f67f0a98f7b85ccbb7d79c0b675764d8bf05 /xmlsecurity | |
parent | 2fa9b7d004af0ff180e0220f6d26cb98b033e863 (diff) |
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 <ci@libreoffice.org>
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Diffstat (limited to 'xmlsecurity')
-rw-r--r-- | xmlsecurity/source/gpg/SecurityEnvironment.cxx | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/xmlsecurity/source/gpg/SecurityEnvironment.cxx b/xmlsecurity/source/gpg/SecurityEnvironment.cxx index 64b4224f3efc..27d71e0d77ac 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; |