Skip to content

Commit

Permalink
fix(autofirma): Find certificate before removing
Browse files Browse the repository at this point in the history
Find for 'AutoFirma ROOT' certificate before trying to remove it.
  • Loading branch information
cdalvaro committed Aug 9, 2023
1 parent 5f483d2 commit 2d6e38e
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions Casks/a/autofirma.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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",
Expand Down

0 comments on commit 2d6e38e

Please sign in to comment.