Bug 469705 - okular does not find any certificate for digital signing
Summary: okular does not find any certificate for digital signing
Status: REPORTED
Alias: None
Product: okular
Classification: Applications
Component: PDF backend (show other bugs)
Version: 23.04.0
Platform: openSUSE Linux
: NOR normal
Target Milestone: ---
Assignee: Okular developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-05-13 16:39 UTC by Philippe ROUBACH
Modified: 2023-10-16 10:49 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
backend settings (135.39 KB, image/png)
2023-10-02 15:18 UTC, Philippe ROUBACH
Details
no gpg certificate (2.27 MB, image/png)
2023-10-13 08:12 UTC, Philippe ROUBACH
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Philippe ROUBACH 2023-05-13 16:39:04 UTC
Here are all my certificates

~> find ~ -name "cert9.db"
~/.mozilla/firefox/sv1r6rd3.default-esr78/cert9.db
~/.mozilla/firefox/9y66b0sk.default-release/cert9.db
~/.pki/nssdb/cert9.db

Kleopatra finds my certificates.

I can digital sign my mails with kmail.


I tried all the paths

I  get a message saying there is no digital certificate.


SOFTWARE/OS VERSIONS
Operating System: openSUSE Tumbleweed 20230511
KDE Plasma Version: 5.27.5
KDE Frameworks Version: 5.105.0
Qt Version: 5.15.9
Comment 1 Philippe ROUBACH 2023-05-15 07:14:37 UTC
kleopatra, kmail, LibreOffice finds the same list of certificates, not okular !
Comment 2 Philippe ROUBACH 2023-05-15 07:15:39 UTC
launching okular in konsole then no error message about certificate db.

I made the following experiment with “~/pki/nssdb/“.

I uninstall okular then I install snap version of okular from “app.kde.store”.

Furthermore, I launch this snap version in konsole.

I get a message saying “bad database”

in ./pki/nssdb/ there are :

cert9.db
key4.db
pkcs11.txt

also I found that the certificates I can see in kleopatra, kmail, LibreOffice are in ~/gnupg/ and the format is not the same as in "nssdb" folders.
Comment 3 Philippe ROUBACH 2023-05-15 07:16:08 UTC
It's strange because in an issue in gitlab about poppler I read that the code for digital signing in poppler is a copy of the code in LibreOffice.

see https://gitlab.freedesktop.org/poppler/poppler/-/issues/465
Comment 4 Sune Vuorela 2023-05-15 10:25:31 UTC
(In reply to Philippe ROUBACH from comment #3)
> It's strange because in an issue in gitlab about poppler I read that the
> code for digital signing in poppler is a copy of the code in LibreOffice.
> 
> see https://gitlab.freedesktop.org/poppler/poppler/-/issues/465

The LibreOffice code can interact with both nss and the gpg keystore.

Poppler currently can only interact with the nss keystore (There are patches under review also letting poppler (and then also okular) interact with the gpg keystore)

KMail and Kleopatra only uses the gpg keystore.

You can ask poppler about it's available keys with the pdfsig utility, like

`pdfsig -nssdir ~/.pki/nssdb/ -list-nicks`

and see what's available
Comment 5 Philippe ROUBACH 2023-05-15 10:29:01 UTC
pdfsig -nssdir ~/.pki/nssdb/ -list-nicks
There are no certificates available.
Comment 6 Philippe ROUBACH 2023-05-15 10:32:23 UTC
It seems that kde policy is to use gpg store. Why not okular ?
Comment 7 Sune Vuorela 2023-05-15 10:33:21 UTC
(In reply to Philippe ROUBACH from comment #6)
> It seems that kde policy is to use gpg store. Why not okular ?

It's coming.
Comment 8 Ovidiu-Florin BOGDAN 2023-08-21 18:39:21 UTC
I had this issue as well. My solution for this was to go in the Okular PDF platforms settings and ensure that the Firefox profile that Okular looks in is the same one that Firefox is using.

In my case Okular was looking in a non-existing directory by default. As soon as I changed it to the proper path the certificate appeared and was usable.
Comment 9 Sune Vuorela 2023-10-02 12:38:16 UTC
(In reply to Philippe ROUBACH from comment #6)
> It seems that kde policy is to use gpg store. Why not okular ?

This was released as part of okular 23.08 (requires a similar new-ish poppler library, at least 23.07)
Comment 10 Philippe ROUBACH 2023-10-02 13:40:03 UTC
okular 23.08.1
poppler 23.09

Issue still there :
okular by default does not point to ~/.gnupg/ and when we customize the path to ~/.gnupg/ then okular does not find any key. Certainly because it knows only NSS format.
Comment 11 Sune Vuorela 2023-10-02 13:58:54 UTC
(In reply to Philippe ROUBACH from comment #10)
> okular 23.08.1
> poppler 23.09
> 
> Issue still there :
> okular by default does not point to ~/.gnupg/ and when we customize the path
> to ~/.gnupg/ then okular does not find any key. Certainly because it knows
> only NSS format.

Did you select gnupg in the backend dropdown ?

/Sune
Comment 12 Philippe ROUBACH 2023-10-02 15:18:09 UTC
Created attachment 162025 [details]
backend settings

See the settings
Comment 13 Albert Astals Cid 2023-10-02 20:39:48 UTC
> It seems that kde policy is to use gpg store

There is no such policy.
Comment 14 Sune Vuorela 2023-10-03 06:40:09 UTC
(In reply to Philippe ROUBACH from comment #12)
> Created attachment 162025 [details]
> backend settings
> 
> See the settings

Please file a bug report to whomever provides your poppler binaries.
Comment 15 Philippe ROUBACH 2023-10-03 06:45:21 UTC
(In reply to Sune Vuorela from comment #14)
> (In reply to Philippe ROUBACH from comment #12)
> > Created attachment 162025 [details]
> > backend settings
> > 
> > See the settings
> 
> Please file a bug report to whomever provides your poppler binaries.

Do you say the issue is solved or what ?
Comment 16 Sune Vuorela 2023-10-03 07:45:01 UTC
(In reply to Philippe ROUBACH from comment #15)
> (In reply to Sune Vuorela from comment #14)
> > (In reply to Philippe ROUBACH from comment #12)
> > > Created attachment 162025 [details]
> > > backend settings
> > > 
> > > See the settings
> > 
> > Please file a bug report to whomever provides your poppler binaries.
> 
> Do you say the issue is solved or what ?

There is unfortunately 2-3 issues in this bug-thread.

But one of them is that your certificates seen with kleopatra cannot be used with okular.

If your recent poppler is built with gpgme support (and gnupg2.4.1 or later is available), okular can use the same certificate store as kleopatra.

You have the new okular that has the dropdown where it should be possible to select gpg, but the underlying poppler is not built with gpg support, so it isn't there. 

That you need to take up with whomever delivers your binaries.
Comment 17 Philippe ROUBACH 2023-10-03 08:17:03 UTC
Thanks

If I understand well, we need:
- okular default certificate folder is ~.gnupg
- gpg 2.4.1 or later
- we need poppler built with gpgme support.

right ?
Comment 18 Philippe ROUBACH 2023-10-03 08:28:59 UTC
I sent a report to openSUSE

https://bugzilla.opensuse.org/show_bug.cgi?id=1215890
Comment 19 Sune Vuorela 2023-10-03 08:30:01 UTC
(In reply to Philippe ROUBACH from comment #17)
> Thanks
> 
> If I understand well, we need:
> - okular default certificate folder is ~.gnupg
> - gpg 2.4.1 or later
> - we need poppler built with gpgme support.
> 
> right ?

point 1 is slighly wrong.
Okular still uses NSS by default with whatever certificate paths. 

You now have a configuration option in the dialog to select gnupg or nss, if poppler supports it, in the dialog you showed earlier.
Comment 20 Philippe ROUBACH 2023-10-03 12:42:56 UTC
see the answer from openSUSE

https://bugzilla.suse.com/show_bug.cgi?id=1215890#c1
Comment 21 Philippe ROUBACH 2023-10-03 12:43:59 UTC
Why Okular does not use the same technology as kleopatra, kmail or LibreOffcie ?
Comment 22 Sune Vuorela 2023-10-03 12:50:31 UTC
(In reply to Philippe ROUBACH from comment #21)
> Why Okular does not use the same technology as kleopatra, kmail or
> LibreOffcie ?

The work I did in poppler uses the exact same technology as kleopatra and kmail. Unfortunately there was a few bugs in the way. They were fixed in gnupg2.4.1.

Why opensuse has buggy QA scripts; that's a good question. But I have submitted a patch for that to them.
Comment 23 Philippe ROUBACH 2023-10-03 14:07:23 UTC
(In reply to Sune Vuorela from comment #22)
> (In reply to Philippe ROUBACH from comment #21)
> > Why Okular does not use the same technology as kleopatra, kmail or
> > LibreOffcie ?
> 
> The work I did in poppler uses the exact same technology as kleopatra and
> kmail. Unfortunately there was a few bugs in the way. They were fixed in
> gnupg2.4.1.
> 
> Why opensuse has buggy QA scripts; that's a good question. But I have
> submitted a patch for that to them.

Thanks
Comment 24 Philippe ROUBACH 2023-10-13 08:12:32 UTC
Created attachment 162271 [details]
no gpg certificate

Hello

OpenSUSE tumbleweed supplies :
- gpg2 2.4.3
- poppler built with gpgme support.

Okular still does not find any gpg certificate.

See the capture.
Comment 25 Sune Vuorela 2023-10-16 07:43:23 UTC
(In reply to Philippe ROUBACH from comment #24)
> Created attachment 162271 [details]
> no gpg certificate
> 
> Hello
> 
> OpenSUSE tumbleweed supplies :
> - gpg2 2.4.3
> - poppler built with gpgme support.
> 
> Okular still does not find any gpg certificate.
> 
> See the capture.

And you have your x509 certificates in your gpg store ?

What does `gpgsm --list-secret-keys` output ?
Comment 26 Philippe ROUBACH 2023-10-16 08:33:42 UTC
:~> gpgsm --list-secret-keys
/home/roubach/.gnupg/pubring.kbx
--------------------------------
Comment 27 Philippe ROUBACH 2023-10-16 08:36:31 UTC
>> And you have your x509 certificates in your gpg store ?

why you speak about x509 certificate ?

I speak about gpg certificates. Those found and used by kmail, LibreOffice, kleopatra for digital signing.
Comment 28 Sune Vuorela 2023-10-16 10:13:53 UTC
(In reply to Philippe ROUBACH from comment #27)
> >> And you have your x509 certificates in your gpg store ?
> 
> why you speak about x509 certificate ?
> 
> I speak about gpg certificates. Those found and used by kmail, LibreOffice,
> kleopatra for digital signing.

openpgp certificates are not specified to be used for pdf files.

For that we need CMS - https://en.wikipedia.org/wiki/Cryptographic_Message_Syntax - and CAdES -  https://en.wikipedia.org/wiki/CAdES_(computing) - according to the pdf specification section 12.8. 

I have not seen anyone specifying CMS with openpgp keys, only with x509 certificates.
Comment 29 Sune Vuorela 2023-10-16 10:16:02 UTC
(In reply to Philippe ROUBACH from comment #26)
> :~> gpgsm --list-secret-keys
> /home/roubach/.gnupg/pubring.kbx
> --------------------------------

So okular's dialog matches what you have in the keyring. That's expected.
Comment 30 Philippe ROUBACH 2023-10-16 10:29:22 UTC
>> openpgp certificates are not specified to be used for pdf files.

>> For that we need CMS - https://en.wikipedia.org/wiki/Cryptographic_Message_Syntax - and CAdES -  https://en.wikipedia.org 
>> /wiki/CAdES_(computing) - according to the pdf specification section 12.8. 

>> I have not seen anyone specifying CMS with openpgp keys, only with x509 certificates.

It is too techie for me. What I understand is :
- the pdf standard for digital signing is only using a x509 certificate.
- in the standard, there is no way for digital signing with an OpenPGP certificate.

Right ?
Comment 31 Sune Vuorela 2023-10-16 10:49:16 UTC
> It is too techie for me. What I understand is :
> - the pdf standard for digital signing is only using a x509 certificate.
> - in the standard, there is no way for digital signing with an OpenPGP
> certificate.
> 
> Right ?

Correct. 

And for added knowledge:
 - LibreOffice can do some operations using OpenPGP. And other operations using x509
 - Kleopatra works with both OpenPGP keys and x509 certificates for different and similar things
 - KMail cans sign and verify both with OpenPGP and with x509 (S/Mime)
 - GnuPG has tools to work with OpenPGP keys (gpg) and with x509 certificates (gpgsm)