<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.kde.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugs.kde.org/"
          
          maintainer="sysadmin@kde.org"
>

    <bug>
          <bug_id>498558</bug_id>
          
          <creation_ts>2025-01-12 14:21:53 +0000</creation_ts>
          <short_desc>Can&apos;t import certificates to digitally sign in Okular, it gives &quot;NSS_Init failed: security library: bad database&quot;</short_desc>
          <delta_ts>2025-01-24 14:32:44 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>2</classification_id>
          <classification>Applications</classification>
          <product>okular</product>
          <component>PDF backend</component>
          <version>24.12.0</version>
          <rep_platform>Ubuntu</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>NOR</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Allexus J">a.geno</reporter>
          <assigned_to name="Scarlett Moore">sgmoore</assigned_to>
          <cc>aacid</cc>
    
    <cc>kde</cc>
    
    <cc>sgmoore</cc>
          
          <cf_commitlink></cf_commitlink>
          <cf_versionfixedin></cf_versionfixedin>
          <cf_sentryurl></cf_sentryurl>
          <votes>0</votes>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2388829</commentid>
    <comment_count>0</comment_count>
    <who name="Allexus J">a.geno</who>
    <bug_when>2025-01-12 14:21:53 +0000</bug_when>
    <thetext>I&apos;m struggling to import self signed certificates into Okular to digitally sign a pdf, I cannot succeed.

I tried two ways:

1)

    $ rm -rf ~/.pki/nssdb/ &amp;&amp; mkdir -p ~/.pki/nssdb
    $ certutil -N -d ~/.pki/nssdb
    $ certutil -S -d ~/.pki/nssdb -s &quot;CN=Example Signing Certificate;OU=Example Certificate Authority;O=Example Organization;L=City;ST=State;C=US&quot; -t &quot;,,C,C&quot; -n &quot;Example Signing Certificate&quot; -x

Then I started Okular via terminal, I made sure backend pdf setting was set on database certificate path /home/allexj/.pki/nssdb, and it gives me 

    NSS_Init failed: security library: bad database.


2)
I also tried creating certificate in a different way, but the result is the same (same error as before):

    $ openssl req -x509 -newkey rsa:4096 -sha256 -days 3650 -nodes \
    -keyout signing.key -out signing.crt -subj &quot;/CN=John T Doe/emailAddress=you@somesite.com&quot; \
    -addext &quot;subjectAltName=email:you@somesite.com&quot;
    $ openssl pkcs12 -export -in signing.crt -inkey signing.key -out signing-certificate.p12 -name &quot;John T Doe&quot;
    $ rm .rf ~/.pki/nssdb &amp;&amp; mkdir -p ~/.pki/nssdb &amp;&amp; certutil -d ~/.pki/nssdb -N
    $ pk12util -d ~/.pki/nssdb -i signing-certificate.p12


What am I doing wrong? Is this a bug?



SOFTWARE/OS VERSIONS
OS: Ubuntu 24.04.1, Gnome
$ kf5-config --version
Qt: 5.15.13
KDE Frameworks: 5.115.0</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2388998</commentid>
    <comment_count>1</comment_count>
    <who name="Allexus J">a.geno</who>
    <bug_when>2025-01-13 11:08:52 +0000</bug_when>
    <thetext>Update: I was finally able to digitally sign my PDF by using Master PDF Editor 5. But I want to know why Okular has this bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2389031</commentid>
    <comment_count>2</comment_count>
    <who name="Sune Vuorela">kde</who>
    <bug_when>2025-01-13 12:21:05 +0000</bug_when>
    <thetext>(In reply to Allexus J from comment #1)
&gt; Update: I was finally able to digitally sign my PDF by using Master PDF
&gt; Editor 5. But I want to know why Okular has this bug.

Is your package installed as a distribution package or as a snap package ?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2389142</commentid>
    <comment_count>3</comment_count>
    <who name="Allexus J">a.geno</who>
    <bug_when>2025-01-13 17:38:22 +0000</bug_when>
    <thetext>(In reply to Sune Vuorela from comment #2)
&gt; (In reply to Allexus J from comment #1)
&gt; &gt; Update: I was finally able to digitally sign my PDF by using Master PDF
&gt; &gt; Editor 5. But I want to know why Okular has this bug.
&gt; 
&gt; Is your package installed as a distribution package or as a snap package ?

snap</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2389391</commentid>
    <comment_count>4</comment_count>
    <who name="Sune Vuorela">kde</who>
    <bug_when>2025-01-14 08:36:45 +0000</bug_when>
    <thetext>(In reply to Allexus J from comment #3)
&gt; (In reply to Sune Vuorela from comment #2)
&gt; &gt; (In reply to Allexus J from comment #1)
&gt; &gt; &gt; Update: I was finally able to digitally sign my PDF by using Master PDF
&gt; &gt; &gt; Editor 5. But I want to know why Okular has this bug.
&gt; &gt; 
&gt; &gt; Is your package installed as a distribution package or as a snap package ?
&gt; 
&gt; snap

I know nothing of snaps, but I would expect it needing to configured a &apos;hole&apos; in the sandboxing to access ~/.pki/nssdb for that. I don&apos;t know if that has been set up or not.

Scarlett?

/Sune</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2389456</commentid>
    <comment_count>5</comment_count>
    <who name="Scarlett Moore">sgmoore</who>
    <bug_when>2025-01-14 14:36:11 +0000</bug_when>
    <thetext>Yep, I will have to give the snap access to that file. Will fix asap.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2389826</commentid>
    <comment_count>6</comment_count>
    <who name="Scarlett Moore">sgmoore</who>
    <bug_when>2025-01-15 16:55:15 +0000</bug_when>
    <thetext>I have uploaded fix to stable, unfortunately it has to be approved. https://forum.snapcraft.io/t/kde-okular-snap-personal-files/44643</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2392292</commentid>
    <comment_count>7</comment_count>
    <who name="Scarlett Moore">sgmoore</who>
    <bug_when>2025-01-24 14:32:44 +0000</bug_when>
    <thetext>You must sudo snap connect okular:dot-pki-nssdb :personal-files and it will work.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>