From 2d6e38eea076601663313e044ce424a0ddc55d7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20A=CC=81lvaro?= Date: Thu, 27 Jul 2023 07:59:41 +0200 Subject: [PATCH] fix(autofirma): Find certificate before removing Find for 'AutoFirma ROOT' certificate before trying to remove it. --- Casks/a/autofirma.rb | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/Casks/a/autofirma.rb b/Casks/a/autofirma.rb index 735714892125..86ec14ca8987 100644 --- a/Casks/a/autofirma.rb +++ b/Casks/a/autofirma.rb @@ -10,7 +10,7 @@ verified: "estaticos.redsara.es/comunes/autofirma/" name "AutoFirma" desc "Digital signature editor and validator" - homepage "https://firmaelectronica.gob.es/Home/Descargas.htm" + homepage "https://firmaelectronica.gob.es/Home/Descargas.html" livecheck do url :url @@ -19,21 +19,17 @@ pkg "AutoFirma_#{version.dots_to_underscores}_#{pkg_arch}.pkg" - # remove 'Autofirma ROOT' and '127.0.0.1' certificates from keychain (these were installed by pkg) + # remove 'Autofirma ROOT' certificates from keychain uninstall_postflight do - system_command "/usr/bin/security", - args: [ - "delete-certificate", - "-c", "AutoFirma ROOT" - ], - sudo: true - - system_command "/usr/bin/security", - args: [ - "delete-certificate", - "-c", "127.0.0.1" - ], - sudo: true + stdout, * = system_command "/usr/bin/security", + args: ["find-certificate", "-a", "-c", "AutoFirma ROOT", "-Z"], + sudo: true + hashes = stdout.lines.grep(/^SHA-256 hash:/) { |l| l.split(":").second.strip } + hashes.each do |h| + system_command "/usr/bin/security", + args: ["delete-certificate", "-Z", h], + sudo: true + end end uninstall pkgutil: "es.gob.afirma",