[Libreoffice-commits] core.git: xmlsecurity/source

Samuel Mehrbrodt Samuel.Mehrbrodt at cib.de
Wed Mar 15 14:09:58 UTC 2017


 xmlsecurity/source/gpg/SecurityEnvironment.cxx |   27 ++++++++++++-------------
 1 file changed, 13 insertions(+), 14 deletions(-)

New commits:
commit fa05bf54c923d0a8fc648593a001358a100e6285
Author: Samuel Mehrbrodt <Samuel.Mehrbrodt at 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 <ci at libreoffice.org>
    Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt at 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;


More information about the Libreoffice-commits mailing list