libressl: postinstall code is mac-only (#72736)

master
Michka Popoff 2021-03-08 23:33:43 +01:00 committed by GitHub
parent 6018b79502
commit 06fbfba01d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 16 deletions

View File

@ -46,27 +46,29 @@ class Libressl < Formula
end end
def post_install def post_install
keychains = %w[ on_macos do
/System/Library/Keychains/SystemRootCertificates.keychain keychains = %w[
] /System/Library/Keychains/SystemRootCertificates.keychain
]
certs_list = `security find-certificate -a -p #{keychains.join(" ")}` certs_list = `security find-certificate -a -p #{keychains.join(" ")}`
certs = certs_list.scan( certs = certs_list.scan(
/-----BEGIN CERTIFICATE-----.*?-----END CERTIFICATE-----/m, /-----BEGIN CERTIFICATE-----.*?-----END CERTIFICATE-----/m,
) )
valid_certs = certs.select do |cert| valid_certs = certs.select do |cert|
IO.popen("#{bin}/openssl x509 -inform pem -checkend 0 -noout", "w") do |openssl_io| IO.popen("#{bin}/openssl x509 -inform pem -checkend 0 -noout", "w") do |openssl_io|
openssl_io.write(cert) openssl_io.write(cert)
openssl_io.close_write openssl_io.close_write
end
$CHILD_STATUS.success?
end end
$CHILD_STATUS.success? # LibreSSL install a default pem - We prefer to use macOS for consistency.
rm_f %W[#{etc}/libressl/cert.pem #{etc}/libressl/cert.pem.default]
(etc/"libressl/cert.pem").atomic_write(valid_certs.join("\n"))
end end
# LibreSSL install a default pem - We prefer to use macOS for consistency.
rm_f %W[#{etc}/libressl/cert.pem #{etc}/libressl/cert.pem.default]
(etc/"libressl/cert.pem").atomic_write(valid_certs.join("\n"))
end end
def caveats def caveats