Page MenuHome GnuPG

Kleopatra: Add ".pub" suffix to the file selector filter when importing certificates in Kleopatra
Open, NormalPublic

Description

When Importing certificates, Kleopatra does not accept ".pub" as valid suffix in Windows:


Traditionally public keys were stored in ".pub" files, however.

For clarification:

This is not about importing from the File Explorer but directly in Kleopatra.
The task is to add ".pub" to the filter used for the file selection there.

Details

Version
4.4.0

Event Timeline

uwi created this object in space S1 Public.

Really. I do this for PGP files but I have not seen that elsewhere.

I wasnt aware of this either, but it would be good since we currently don't have a file extension listed explicitly for pgp keys, even though we register one and have the strings already to handle downloading keys where the server transfers application/pgp-keys as information. While https://support.microsoft.com/en-us/windows/common-file-name-extensions-in-windows-da4a4430-8e76-89c5-59f7-1cdbbc75cb01 recognizes it as Microsoft Publisher file wikipedia says PGP Public key but without a citation. If AllowSilentDefaultTakeover is not set, the following code will not automatically change .pub to kleopatra. Instead in microsoft publisher is installed, it will ask you for the first time when a .pub file is opened after installing Kleopatra if you want to keep opening the files with Microsoft Publisher or if they should be opened from now on with IKleopatra,.

diff --git a/src/nsis/inst-kleopatra.nsi b/src/nsis/inst-kleopatra.nsi
index 45460c84..47e35f68 100644
--- a/src/nsis/inst-kleopatra.nsi
+++ b/src/nsis/inst-kleopatra.nsi
@@ -253,6 +253,8 @@ ${MementoSection} "Kleopatra" SEC_kleopatra
   WriteRegStr SHCTX "Software\Classes\gpg4win.AssocFile.Kleopatra.PGPKEY\CurVer" "" "${VERSION}"
   WriteRegStr SHCTX "Software\Classes\gpg4win.AssocFile.Kleopatra.PGPKEY\DefaultIcon" "" "$INSTDIR\share\gpg4win\file-ext.ico"
 
+  WriteRegBin SHCTX "Software\Classes\.pub\OpenWithProgIDs" "gpg4win.AssocFile.Kleopatra.PGPKEY" 0
+
   # CMS
   WriteRegExpandStr SHCTX "Software\Classes\gpg4win.AssocFile.Kleopatra.CMS\shell\open\command" "" "$\"$INSTDIR\bin\Kleopatra.exe$\" -- $\"%1$\""
   WriteRegStr SHCTX "Software\Classes\gpg4win.AssocFile.Kleopatra.CMS" "" "$(T_File_Type_pem_Name)"
@@ -335,6 +337,7 @@ ${MementoSection} "Kleopatra" SEC_kleopatra
   WriteRegStr SHCTX "Software\Gpg4win\Kleopatra\Capabilities\FileAssociations" ".mime" "gpg4win.AssocFile.Kleopatra.MIME"
   WriteRegStr SHCTX "Software\Gpg4win\Kleopatra\Capabilities\FileAssociations" ".mbox" "gpg4win.AssocFile.Kleopatra.MIME"
   WriteRegStr SHCTX "Software\Gpg4win\Kleopatra\Capabilities\FileAssociations" ".eml"  "gpg4win.AssocFile.Kleopatra.MIME"
+  WriteRegStr SHCTX "Software\Gpg4win\Kleopatra\Capabilities\FileAssociations" ".pub" "gpg4win.AssocFile.Kleopatra.PGPKEY"
 
   WriteRegExpandStr SHCTX "Software\Gpg4win\Kleopatra\Capabilities\shell\open\command" "" "$\"$INSTDIR\bin\Kleopatra.exe$\" -- $\"%1$\""
 
diff --git a/src/nsis/uninst-kleopatra.nsi b/src/nsis/uninst-kleopatra.nsi
index 6e49660a..1f10b066 100644
--- a/src/nsis/uninst-kleopatra.nsi
+++ b/src/nsis/uninst-kleopatra.nsi
@@ -226,6 +226,7 @@ Section "-un.kleopatra"
   DeleteRegValue SHCTX "Software\Classes\.mime\OpenWithProgids" "gpg4win.AssocFile.kleopatra.MIME"
   DeleteRegValue SHCTX "Software\Classes\.eml\OpenWithProgids"  "gpg4win.AssocFile.kleopatra.MIME"
   DeleteRegValue SHCTX "Software\Classes\.mbox\OpenWithProgids" "gpg4win.AssocFile.kleopatra.MIME"
+  DeleteRegValue SHCTX "Software\Classes\.pub\OpenWithProgids" "gpg4win.AssocFile.kleopatra.PGPKEY"
 
   DeleteRegValue SHCTX "Software\Classes\.kgrp\OpenWithProgids" "gpg4win.AssocFile.Kleopatra.KGRP"

Note that uninstall only deletes one value as the second value is deleted by deleting the whole key.

Just a note (in case it was not clear enough): I was *not* talking about registering "*.pub" for Kleopatra (currently it launches Microsoft Publisher), but I was talking about the file selector's default input pattern (I had to switch to "all files" to be able to see the file I wanted to import):


Thanks for the clarification, it seems that was necessary.

I'll change the task description accordingly.
I'm wondering if we should add ".sec" to the file selector filter, too, as I believe that has been popular in the past for secret keys.

ebo renamed this task from gpg4win: Accept ".pub" suffix when importing certificates in Kleopatra to Kleopatra: Add ".pub" suffix to the file selector filter when importing certificates in Kleopatra.Thu, Dec 12, 10:59 AM
ebo triaged this task as Normal priority.
ebo updated the task description. (Show Details)
ebo edited projects, added gpd5x; removed gpg4win.