Page MenuHome GnuPG

gpg4win: Accept ".pub" suffix when importing certificates in Kleopatra
Open, Needs TriagePublic

Description

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


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

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.