Bug 155125 - "Encrypt with GPG key" option missing when using System File Dialog on macOS
Summary: "Encrypt with GPG key" option missing when using System File Dialog on macOS
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
7.4.0.0 alpha0+
Hardware: All macOS (All)
: high normal
Assignee: Patrick Luby (volunteer)
URL:
Whiteboard: target:24.2.0 target:7.6.0.2
Keywords:
Depends on:
Blocks: macOS-UI-polish Digital-Signatures OpenPGP
  Show dependency treegraph
 
Reported: 2023-05-02 11:00 UTC by Andrew Watson
Modified: 2023-12-23 15:27 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Watson 2023-05-02 11:00:35 UTC
Description:
There is no "Encrypt with GPG key" check-box in "Save As ..." dialog box when UseSystemFileDialog is True (i.e. when using MacOS Save dialogue boxes).

Steps to Reproduce:
1. Select Preferences>LibreOffice>Advanced>Open Expert Configuration.
2. Search for "UseSystemFileDialog"
3. Ensure value is set to false (possibly by double-clicking to toggle the Boolean).
4. Click "OK" to close Expert Configuration window.
5. Click "OK" to close Preferences window.
6. Select File>New>Text Document
7. Enter any text.
8. Select "File>Save As ..."
9. Observe that LO "Save As" window has an "Encrypt with GPG key" option (lower left).
10. Click "Cancel".
11. Select Preferences>LibreOffice>Advanced>Open Expert Configuration.
12. Search for "UseSystemFileDialog".
13. Double click to change value to "true".
14. Click "OK" to close Expert Configuration window.
15. Click "OK" to close Preferences window.
16. Select "File>Save As ..."
17. Observe that Mac OS system "Save As" window does not have an "Encrypt with GPG key" option.

Actual Results:
Mac OS system "Save As ..." window does not have an "Encrypt with GPG key" option.

Expected Results:
Mac OS system "Save As ..." window should have an "Encrypt with GPG key" option.


Reproducible: Always


User Profile Reset: No

Additional Info:
Bug observed in both:

Version: 7.4.0.0.alpha0+ / LibreOffice Community
Build ID: beb6c62e990599d91ac5d9183164c94d269027d3
CPU threads: 4; OS: Mac OS X 10.14.6; UI render: Skia/Metal; VCL: osx
Locale: en-GB (en_GB.UTF-8); UI: en-US
Calc: threaded

-- AND --

Version: 7.4.6.2 / LibreOffice Community
Build ID: 5b1f5509c2decdade7fda905e3e1429a67acd63d
CPU threads: 4; OS: Mac OS X 10.14.6; UI render: default; VCL: osx
Locale: en-GB (en_GB.UTF-8); UI: en-GB
Calc: threaded

(See previous note of this bug in Comment 50 on Bug 115538, dated 2022-02-01 14:19:00 UTC).
Comment 1 Stéphane Guillou (stragu) 2023-05-05 13:28:47 UTC
Confirmed by Andrew in bug 115538 comment 61
Comment 2 Stéphane Guillou (stragu) 2023-07-12 15:53:55 UTC
(In reply to Stéphane Guillou (stragu) from comment #1)
> Confirmed by Andrew in bug 115538 comment 61

Just realised that comment was also by Andrew... But Steve just confirmed in the QA chat.
Comment 3 steve 2023-07-12 15:55:56 UTC
Another data point:

Version: 24.2.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: fcbae818b793a9ee97a1b5ddc53902be7a2376f5
CPU threads: 8; OS: Mac OS X 13.4.1; UI render: Skia/Raster; VCL: osx
Locale: en-US (en_DE.UTF-8); UI: en-US
Calc: threaded

Confirming as well. As per the documentation https://help.libreoffice.org/latest/en-US/text/shared/guide/openpgp.html using Save as is the only option to use OpenPGP in LibreOffice. This has not been functional on macOS for a while.

Was slightly surprised to see "Improve PGP/GPG encryption support" GSoC project, while the most basic functionality is not working and this bug here does not seem to be part of the GSoC effort around OpenPGP.
Comment 4 Alex Thurgood 2023-07-13 14:45:13 UTC
FWIW, I have two machines (MBPro & macmini, both Arm silicon, both running Ventura) where LO refuses to see any of the GPG keys that I have in my home folder, be it under .gnupg, the old .gnupg_pre2.1 folder, or any of these folders when unhidden.

GPGSuite 2023.2 has no problem finding and displaying those keys for me.

Finding the keys has to work reliably, above all else, otherwise, what's the point of having the functionality?
Comment 5 Stéphane Guillou (stragu) 2023-07-13 15:05:56 UTC
TokieSan, copying you in in case you are interested.
Comment 6 Patrick Luby (volunteer) 2023-07-13 17:30:48 UTC
(In reply to Alex Thurgood from comment #4)
> FWIW, I have two machines (MBPro & macmini, both Arm silicon, both running
> Ventura) where LO refuses to see any of the GPG keys that I have in my home
> folder, be it under .gnupg, the old .gnupg_pre2.1 folder, or any of these
> folders when unhidden.
> 
> GPGSuite 2023.2 has no problem finding and displaying those keys for me.
> 
> Finding the keys has to work reliably, above all else, otherwise, what's the
> point of having the functionality?

I don't know anything about what code searches for your GPG keys. That said, are you using the Mac App Store version of LibreOffice?

I ask because in Mac App Store applications, the "macOS sandbox" sets your home folder for each Mac App Store application to a hidden folder. For example, when running LibreOffice's Mac App Store version, your home folder is the following:

~/Library/Containers/org.libreoffice.script/Data/

If you are using the LibreOffice Mac App Store version, what happens if you copy all of ~/.gnupg to ~/Library/Containers/org.libreoffice.script/Data/ are restart LibreOffice?

Note: you have copy, not create a softlink or macOS alias as the "macOS sandbox" does not have access to read files in your real home folder without a bunch of steps.
Comment 7 Commit Notification 2023-07-13 20:36:05 UTC
Patrick Luby committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/3c7b230910c95838d644d1d3971f2a656b64f635

tdf#155125 add "Encrypt with GPG key" checkbox in macOS native save dialog

It will be available in 24.2.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 8 Patrick Luby (volunteer) 2023-07-13 20:43:48 UTC
So I think that I have fixed the missing checkbox in the native macOS save dialog. I still need to install gpg on my Mac but with my fix, I do see the "Select Certificate" dialog after I check the "Encrypt with GPG key" checkbox and press "Save" in the save dialog.

Can anyone test my patch? It should be included in the next nightly build.
Comment 9 Patrick Luby (volunteer) 2023-07-14 13:28:28 UTC
So I installed the 14 July 2023 nightly build and installed the gpgme package from MacPorts. The new "Encrypt with GPG key" checkbox is now in the save dialog so that is fixed.

@Alex Thurgood: I think I am seeing the same problem as you described in https://bugs.documentfoundation.org/show_bug.cgi?id=155125#c4 when I launch the nightly build from the Finder.

On my machine, MacPorts installed the gpg command in /opt/local/bin and /opt/local/bin is in my PATH environment variable in the Terminal. But launching from the Finder has a much more limited PATH by default. So, my guess is that some additional common paths need to be hardcoded in the LibreOffice code that searches for the gpg command.

I think I need to add at least the following paths for MacPorts and Homebrew:

/usr/local/bin
/opt/local/bin

@Alex Thurgood: since you are using GPGTools, can you run the "which gpg" command in a Terminal and post it?
Comment 10 steve 2023-07-14 23:35:21 UTC
As usual: thanks so much for diving in on this, Patrick.

Verifying that "Encrypt with GPG key" option is now showing in save dialog as expected.

However this is not functional yet.

When I tick the option and click save LibreOffice hangs, spinning beach ball shows and only way to proceed is to force quit LO, which brings up the following crash log (1 month): https://bin.disroot.org/?368f1c05aa746394#7hVy2wSzHNRkog1K4Q77Sdx1QLMkUSryZ8MbrAkatu6Q

Not sure if this is the same or related as the gpgme crash reported in https://bugs.documentfoundation.org/show_bug.cgi?id=152524.

With GPG Suite installed which gpg says: /usr/local/bin/gpg
Comment 11 steve 2023-07-14 23:43:23 UTC
Sorry, no editing function... forgot to mention some details:

Tested with Version: 24.2.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 73367f09716f5709264885486a2bb03626d39884
CPU threads: 8; OS: Mac OS X 13.4.1; UI render: Skia/Raster; VCL: osx
Locale: en-US (en_DE.UTF-8); UI: en-US
Calc: threaded

For me keys do show reliably in Settings > User data with GPG Suite installed. That has not always been the case with previous main builds.
Comment 12 Commit Notification 2023-07-15 00:26:16 UTC
Patrick Luby committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/693411e60c6bbd1c2ef25490cc3902f6b2461682

Related tdf#155125: add MacPorts to GPG's fallback search on macOS

It will be available in 24.2.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 13 Patrick Luby (volunteer) 2023-07-15 12:36:36 UTC
(In reply to Commit Notification from comment #12)
> Patrick Luby committed a patch related to this issue.
> It has been pushed to "master":
> 
> https://git.libreoffice.org/core/commit/
> 693411e60c6bbd1c2ef25490cc3902f6b2461682

The above change attempts to fix the problem that @Alex Thurgood and I have been seeing where LibreOffice cannot find the gpg command line executables (that the user has installed separately) when LibreOffice is launched from the Finder.

I found some code in the GPGME third-party code that LibreOffice uses and it has a hardcoded list of fallback paths to search for the gpg command line executables if none are found in the PATH environment variable. So I added /opt/local/bin onto the list:

/usr/local/bin:/usr/local/MacGPG2/bin:/opt/homebrew/bin:/opt/local/bin

I tested the above change in the 15 July 2023 nightly build and it works with both GPGTools and MacPorts gpgme package on my Mac Silicon:

Version: 24.2.0.0.alpha0+ (AARCH64) / LibreOffice Community
Build ID: 693411e60c6bbd1c2ef25490cc3902f6b2461682
CPU threads: 8; OS: Mac OS X 12.6.7; UI render: Skia/Raster; VCL: osx
Locale: en-US (en_US.UTF-8); UI: en-US
Calc: threaded
Comment 14 Patrick Luby (volunteer) 2023-07-15 13:17:14 UTC
(In reply to steve from comment #10)
> When I tick the option and click save LibreOffice hangs, spinning beach ball
> shows and only way to proceed is to force quit LO, which brings up the
> following crash log (1 month):
> https://bin.disroot.org/
> ?368f1c05aa746394#7hVy2wSzHNRkog1K4Q77Sdx1QLMkUSryZ8MbrAkatu6Q
> 
> Not sure if this is the same or related as the gpgme crash reported in
> https://bugs.documentfoundation.org/show_bug.cgi?id=152524.
> 

Thank you for the sample. It looks like LibreOffice was deep in the third-party GPGME code during the hang. Specifically, AFAICT, the GPGME code has launched one of the gpg command line tools (i.e. GPGTools in your case) and is waiting for the output of that gpg command.

It's not exactly the same as the crash https://bugs.documentfoundation.org/show_bug.cgi?id=152524 but in a similar area. I am not familiar with the GPGME code but it looks like there is some incompatibility or bug in the GPGME code that LibreOffice includes and GPGTools.

What do you and any other people using GPGTools see when you execute the following Terminal command?:

gpg --version

I have the gpg command from installing the MacPorts gpgme package and the output that I get is as follows:

gpg --version
gpg (GnuPG) 2.4.0
libgcrypt 1.10.2
Copyright (C) 2021 Free Software Foundation, Inc.
License GNU GPL-3.0-or-later <https://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Home: /Users/pluby/.gnupg
Supported algorithms:
Pubkey: RSA, ELG, DSA, ECDH, ECDSA, EDDSA
Cipher: IDEA, 3DES, CAST5, BLOWFISH, AES, AES192, AES256, TWOFISH,
        CAMELLIA128, CAMELLIA192, CAMELLIA256
Hash: SHA1, RIPEMD160, SHA256, SHA384, SHA512, SHA224
Compression: Uncompressed, ZIP, ZLIB, BZIP2
Comment 15 Andrew Watson 2023-07-15 14:38:51 UTC
(In reply to Patrick Luby from comment #14)
 
> What do you and any other people using GPGTools see when you execute the
> following Terminal command?:
> 
> gpg --version

I get:

--------

Discovery:Pre-meeting material ajw$ gpg --version
gpg (GnuPG/MacGPG2) 2.2.24
libgcrypt 1.8.7
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Home: /Users/ajw/.gnupg
Supported algorithms:
Pubkey: RSA, ELG, DSA, ECDH, ECDSA, EDDSA
Cipher: IDEA, 3DES, CAST5, BLOWFISH, AES, AES192, AES256, TWOFISH,
        CAMELLIA128, CAMELLIA192, CAMELLIA256
Hash: SHA1, RIPEMD160, SHA256, SHA384, SHA512, SHA224
Compression: Uncompressed, ZIP, ZLIB, BZIP2
Discovery:Pre-meeting material ajw$ 

--------

I haven't tested the new build(s) on my ancient MacOS 10.14 configuration yet - I hope to get time within a few days.

Many thanks to all who are working on this issue.

Andrew
Comment 16 Patrick Luby (volunteer) 2023-07-15 21:19:01 UTC
Just for completeness, I rebooted into Ventura, installed the 15 July 2023 nightly build, installed GPGTools, created a certificate with "gpg --full-generate-key", and I can encrypt and reopen a simple .odt file.

Here is what I get when I run "gpg --version" on Ventura:

gpg (GnuPG/MacGPG2) 2.2.41
libgcrypt 1.8.10
Copyright (C) 2022 g10 Code GmbH
License GNU GPL-3.0-or-later <https://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Home: /Users/pluby/.gnupg
Supported algorithms:
Pubkey: RSA, ELG, DSA, ECDH, ECDSA, EDDSA
Cipher: IDEA, 3DES, CAST5, BLOWFISH, AES, AES192, AES256, TWOFISH,
        CAMELLIA128, CAMELLIA192, CAMELLIA256
Hash: SHA1, RIPEMD160, SHA256, SHA384, SHA512, SHA224
Compression: Uncompressed, ZIP, ZLIB, BZIP2


Also, here is the LibreOffice About dialog info:

Version: 24.2.0.0.alpha0+ (AARCH64) / LibreOffice Community
Build ID: 693411e60c6bbd1c2ef25490cc3902f6b2461682
CPU threads: 8; OS: Mac OS X 13.4.1; UI render: Skia/Metal; VCL: osx
Locale: en-US (en_US.UTF-8); UI: en-US
Calc: threaded
Comment 17 steve 2023-07-17 12:15:24 UTC
Patrick, I retried with todays main build and ran into multiple issues.

After opening writer, typing test and saving, I tick the option to encrypt. As soon as I click ok, LibreOffice gets stuck, the soffice crash shows as macOS crash dialog and LibreOffice shows an error message:
Error saving the document Untitled 1:
General Error.
General input/output error.

Version: 24.2.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 07074836b0055a94c3ad9319e97e733b019c0519
CPU threads: 8; OS: Mac OS X 13.4.1; UI render: Skia/Raster; VCL: osx
Locale: en-US (en_DE.UTF-8); UI: en-US
Calc: threaded

Using multiple OpenPGP keys. In User Data LibreOffice shows the key entries I selected previously. I have the option to encrypt to self enabled.
Comment 18 Patrick Luby (volunteer) 2023-07-17 13:02:10 UTC
(In reply to steve from comment #17)
> Patrick, I retried with todays main build and ran into multiple issues.
> 

What is the Terminal output of "gpg --version"?

Your LibreOffice samples are both trying to execute one of the gpg* Terminal commands. Since those commands are installed separately by the user. LibreOffice does not bundle them because they have an incompatible open source license so I think the first thing to check is your gpg installation that you installed (via GPGTools or Homebrew?) is reasonably up-to-date and compatible with the gpgme code that LibreOffice uses to execute gpg* Terminal commands.

If your gpg installation is up-to-date, then the next step would be to reproduce the hang like in your latest sample and then, while LibreOffice is hung, try to get a sample of whatever gpg* command LibreOffice is waiting to finish. I think you could get this by launching the /Applications/Utilities/Activity Monitor application while LibreOffice is hanging, double-click on any applications that begin with "gpg" and press the "Sample" button in the dialog that appears.

Hope that helps.
Comment 19 Alex Thurgood 2023-07-17 19:57:36 UTC
(In reply to Patrick Luby from comment #9)
> 
> @Alex Thurgood: since you are using GPGTools, can you run the "which gpg"
> command in a Terminal and post it?

I'll check, off the top of my head, 

/opt/homebrew/something, 

but I'll also try with the latest master build after your fix and report back.
Comment 20 Alex Thurgood 2023-07-17 20:29:37 UTC
On my MBPro:

which gpg
/usr/local/bin/gpg

Testing with 

Version: 24.2.0.0.alpha0+ (AARCH64) / LibreOffice Community
Build ID: fcbae818b793a9ee97a1b5ddc53902be7a2376f5
CPU threads: 8; OS: Mac OS X 13.4; UI render: Skia/Metal; VCL: osx
Locale: fr-FR (fr_FR.UTF-8); UI: en-US
Calc: threaded

still does not find my keys.

$PATH (for the bits relating to possible gpg)
/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/MacGPG2/bin



gpg --version
gpg (GnuPG/MacGPG2) 2.2.41
libgcrypt 1.8.10
Copyright (C) 2022 g10 Code GmbH
License GNU GPL-3.0-or-later <https://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Home: /Users/alex/.gnupg
Algorithmes pris en charge :
Clef publique : RSA, ELG, DSA, ECDH, ECDSA, EDDSA
Chiffrement : IDEA, 3DES, CAST5, BLOWFISH, AES, AES192, AES256,
              TWOFISH, CAMELLIA128, CAMELLIA192, CAMELLIA256
Hachage : SHA1, RIPEMD160, SHA256, SHA384, SHA512, SHA224
Compression : Non compressé, ZIP, ZLIB, BZIP2
Comment 21 Alex Thurgood 2023-07-17 20:41:17 UTC
(In reply to Alex Thurgood from comment #20)

Paths to binary:

/usr/local/MacGPG2/bin/gpg
/usr/local/MacGPG2/bin/gpg2

/usr/local/bin/gpg
/usr/local/bin/gpg2

/usr/local/gnupg-2.1/bin/gpg
/usr/local/gnupg-2.1/bin/gpg2
Comment 22 Alex Thurgood 2023-07-17 21:00:41 UTC
I'm not seeing the option tickbox to encrypt in the Finder dialog, even after a restart in safe config mode.
Comment 23 Patrick Luby (volunteer) 2023-07-17 22:31:54 UTC
(In reply to Alex Thurgood from comment #22)
> I'm not seeing the option tickbox to encrypt in the Finder dialog, even
> after a restart in safe config mode.

Are you sure you have the latest nightly build?

I ask this because the save dialog checkbox doesn't require GPG to even be installed on your machine. The save dialog code just blindly adds the checkbox if you are doing a "save as". Where ever you see a "Save with password" checkbox, you should also see an "Encrypt with GPG key" checkbox.
Comment 24 Alex Thurgood 2023-07-18 07:05:40 UTC
(In reply to Patrick Luby from comment #23)

> 
> Are you sure you have the latest nightly build?
> 

This was the daily build from

/daily/master/MacOSX-aarch64@tb92-TDF/2023-07-17_05.19.53/
Comment 25 Alex Thurgood 2023-07-18 07:15:00 UTC
(In reply to Alex Thurgood from comment #24)
> (In reply to Patrick Luby from comment #23)
> 
> > 
> > Are you sure you have the latest nightly build?
> > 
> 
> This was the daily build from
> 
> /daily/master/MacOSX-aarch64@tb92-TDF/2023-07-17_05.19.53/

Well I downloaded the daily from

/daily/master/MacOSX-aarch64@tb92-TDF/2023-07-18_05.05.43/

and can now see the encrypt tick box in the Finder dialog, so at least that's that problem resolved !
Comment 26 Alex Thurgood 2023-07-18 07:19:01 UTC
(In reply to Alex Thurgood from comment #24)
> (In reply to Patrick Luby from comment #23)
> 
> > 
> > Are you sure you have the latest nightly build?
> > 
> 
> This was the daily build from
> 
> /daily/master/MacOSX-aarch64@tb92-TDF/2023-07-17_05.19.53/

Or so I thought, it turns out that it might have been from tb94 buildbot, which for some reason isn't "current", and so I might have actually downloaded a version from 11/07...it would be nice if the buildbots could be kept in synch :-)
Comment 27 steve 2023-07-18 12:28:08 UTC
Patrick, I filed https://bugs.documentfoundation.org/show_bug.cgi?id=156352 to avoid confusion with potentially dialog elements not showing on Apple Silicon and a follow up bug which is completely unrelated to the problem the bug here is about: https://bugs.documentfoundation.org/show_bug.cgi?id=156352

Alex: were you able to verify the fix on Apple Silicon with a recent main build?
Comment 28 Patrick Luby (volunteer) 2023-07-18 12:56:28 UTC
(In reply to steve from comment #27)
> Patrick, I filed https://bugs.documentfoundation.org/show_bug.cgi?id=156352
> to avoid confusion with potentially dialog elements not showing on Apple
> Silicon and a follow up bug which is completely unrelated to the problem the
> bug here is about: https://bugs.documentfoundation.org/show_bug.cgi?id=156352
> 
> Alex: were you able to verify the fix on Apple Silicon with a recent main
> build?

Whatever. But you still have not provided any of the data that I have asked for.

It is clear from your samples that LibreOffice's code is waiting for output from your user installed gpg commands. Posting that in a new bug just restates the obvious and, worse, effectively wipes out all of the debugging work that I've done so far.

Seriously, I have had no problem on either macOS Monterey or Ventura with a default installation of GPGTools. If you can't post the out put of "gpg --version" and a sample from Activity Monitor of whatever gpg command LibreOffice is waiting for, that's fine.

But from my perspective, this feature now works on every machine that I have access to with GPGTools so at the moment, all signs point to custom configuration in your user installed gpg commands.

It would be nice to know what those are (locked down permissions, password required to sent to commands via stdin, etc.) so we can put it in the LibreOffice help, but ultimately if GPGTools or Homebrew or whatever gpg commands your installed don't work like it does for the rest of us, there isn't much I can (or want to) do.

Of course, if you find a custom configuration that seems to trigger your particular problems, I am happy to try out the same configuration customizations.
Comment 29 Alex Thurgood 2023-07-18 13:10:49 UTC
(In reply to steve from comment #27)


> Alex: were you able to verify the fix on Apple Silicon with a recent main
> build?

Steve: yes, I can confirm that I can see the checkbox in today's (18/07/2023) daily build from buildbot tb92 (it doesn't do anything though), similar to Patrick's own experience mentioned in comment 8, before he installed gpg).

So, to summarize, I can see the tick box, but it does nothing, and the application doesn't cause crash when I click on it, the certificate dialog is displayed, albeit with no certificates i.e. reproduction of bug 115338).
Comment 30 Patrick Luby (volunteer) 2023-07-18 13:46:16 UTC
(In reply to Alex Thurgood from comment #29)
> So, to summarize, I can see the tick box, but it does nothing, and the
> application doesn't cause crash when I click on it, the certificate dialog
> is displayed, albeit with no certificates i.e. reproduction of bug 115338).

Do you see the same behavior when you run the nightly build from the Terminal?:

/Applications/LibreOfficeDev.app/Contents/MacOS/soffice

Running from the Terminal will use your Terminal's PATH environment variable to search for your user installed gpg commands so you can experiment with setting PATH to have your gpg commands' directory at the front of the list.

IIRC, your Terminal PATH is the following:

/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/MacGPG2/bin

In contrast, when you run LibreOffice from the Finder, the Finder sets its own PATH (it does not invoke any shell ".*rc" scripts) so the gpgme code will look through the following fallback directories and will take the first one that it finds:

/usr/local/bin:/usr/local/MacGPG2/bin:/opt/homebrew/bin:/opt/local/bin

So, I am curious if /opt/homebrew/bin works (i.e. running in the Terminal) but /usr/local/bin or /usr/local/MacGPG2/bin have gpg commands but they don't work (i.e. running from the Finder).
Comment 31 Alex Thurgood 2023-07-19 08:09:43 UTC
(In reply to Patrick Luby from comment #30)
> (In reply to Alex Thurgood from comment #29)
> > So, to summarize, I can see the tick box, but it does nothing, and the
> > application doesn't cause crash when I click on it, the certificate dialog
> > is displayed, albeit with no certificates i.e. reproduction of bug 115338).
> 
> Do you see the same behavior when you run the nightly build from the
> Terminal?:
> 
> /Applications/LibreOfficeDev.app/Contents/MacOS/soffice
> 

On my MBPro with the paths already provided, the problem remains the same, no GPG certificates are available in LO Preferences, and correspondingly none are displayed for encrypting or signing a test document.


For comparison, I started the same LODev version from the terminal on my macMini, where I also have GPG keys. When it came to encrypting a test file on save, LO did display the list of available GPG keys. However, when I try to encrypt with a given key, I get the following message:

"OpenPGP key not trusted, damaged, or encryption failure. Please try again."

The GPG key in question is valid (expiry 09/05/2025), and has ultimate trust.

The $PATH command returns a slightly different set of paths because I have used the macMini to try building LO from source in the past, but I see :

/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/local/MacGPG2/bin 

and 

which gpg 

 /opt/homebrew/bin/gpg
Comment 32 Alex Thurgood 2023-07-19 08:49:31 UTC
@Patrick - further investigation and some good news.

The root of my problems seems to lay in the previously old installation of gnupg-2.1 in /usr/local/bin which were i386 arch binaries (I passed them to the file command to check).

I removed the old i386 binaries and folder

I can now see the list of keys and encrypt a file, and re-open it with the appropriate password. 

Unfortunately, it seems that the keys that were previously made with the i386 binaries are now invalid, even if they are still valid in theory...which is a somewhat unfortunate consequence of the move to 64bit aarch/intel universal support, but not really anything to do with LibreOffice as far as I can tell.

I re-tested with a recently created key that I'd created with the universal arch version of GPGSuite, and that test succeeds both to encrypt the file on save, and re-open the file with the appropriate password.

I retested with LODev launched from Finder, and the test succeeded again.

For me at least, this issue is now resolved.
Comment 33 Patrick Luby (volunteer) 2023-07-19 12:13:27 UTC
Marking as verified. I'll see if isn't too late to get my fixes included in the LibreOffice 7.6 builds.
Comment 34 Commit Notification 2023-07-19 12:16:41 UTC
Patrick Luby committed a patch related to this issue.
It has been pushed to "libreoffice-7-6":

https://git.libreoffice.org/core/commit/28d736113317da3e6373f27d6ce5d75fd40d68e2

Related tdf#155125: add MacPorts to GPG's fallback search on macOS

It will be available in 7.6.0.2.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 35 Commit Notification 2023-07-19 12:16:43 UTC
Patrick Luby committed a patch related to this issue.
It has been pushed to "libreoffice-7-6":

https://git.libreoffice.org/core/commit/484fb0cf88cac6effe85f01f2803b00b0bf21151

tdf#155125 add "Encrypt with GPG key" checkbox in macOS native save dialog

It will be available in 7.6.0.2.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 36 Alex Thurgood 2023-07-19 20:26:10 UTC
(In reply to Patrick Luby from comment #33)
> Marking as verified. I'll see if isn't too late to get my fixes included in
> the LibreOffice 7.6 builds.

Thank you for fixing this and your patience with helping me sort out problems of my own making!