91 lines
3.1 KiB
Ruby
91 lines
3.1 KiB
Ruby
class Libressl < Formula
|
|
desc "Version of the SSL/TLS protocol forked from OpenSSL"
|
|
homepage "https://www.libressl.org/"
|
|
# Please ensure when updating version the release is from stable branch.
|
|
url "https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-2.7.4.tar.gz"
|
|
mirror "https://mirrorservice.org/pub/OpenBSD/LibreSSL/libressl-2.7.4.tar.gz"
|
|
sha256 "1e3a9fada06c1c060011470ad0ff960de28f9a0515277d7336f7e09362517da6"
|
|
|
|
bottle do
|
|
sha256 "b13f008fb2415cf9c026b886fd359304c2534270d18b318b11f8356fe926e6ff" => :mojave
|
|
sha256 "2abf2817dc620567a9b2fb276559956db8876f373ed99cea07e801e5602199da" => :high_sierra
|
|
sha256 "a38f908150d5c5db02c78321936d72898b84f502d04067de5e2a77a8225720f4" => :sierra
|
|
sha256 "914ced83b7b05447f6a1fa844f6c8042c06b7694abb50966c0afa9e9d9d6ab31" => :el_capitan
|
|
end
|
|
|
|
head do
|
|
url "https://github.com/libressl-portable/portable.git"
|
|
|
|
depends_on "automake" => :build
|
|
depends_on "autoconf" => :build
|
|
depends_on "libtool" => :build
|
|
end
|
|
|
|
keg_only "LibreSSL is not linked to prevent conflict with the system OpenSSL"
|
|
|
|
def install
|
|
args = %W[
|
|
--disable-dependency-tracking
|
|
--disable-silent-rules
|
|
--prefix=#{prefix}
|
|
--with-openssldir=#{etc}/libressl
|
|
--sysconfdir=#{etc}/libressl
|
|
]
|
|
|
|
system "./autogen.sh" if build.head?
|
|
system "./configure", *args
|
|
system "make"
|
|
system "make", "check"
|
|
system "make", "install"
|
|
end
|
|
|
|
def post_install
|
|
keychains = %w[
|
|
/System/Library/Keychains/SystemRootCertificates.keychain
|
|
]
|
|
|
|
certs_list = `security find-certificate -a -p #{keychains.join(" ")}`
|
|
certs = certs_list.scan(
|
|
/-----BEGIN CERTIFICATE-----.*?-----END CERTIFICATE-----/m,
|
|
)
|
|
|
|
valid_certs = certs.select do |cert|
|
|
IO.popen("#{bin}/openssl x509 -inform pem -checkend 0 -noout", "w") do |openssl_io|
|
|
openssl_io.write(cert)
|
|
openssl_io.close_write
|
|
end
|
|
|
|
$CHILD_STATUS.success?
|
|
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
|
|
|
|
def caveats; <<~EOS
|
|
A CA file has been bootstrapped using certificates from the SystemRoots
|
|
keychain. To add additional certificates (e.g. the certificates added in
|
|
the System keychain), place .pem files in
|
|
#{etc}/libressl/certs
|
|
|
|
and run
|
|
#{opt_bin}/openssl certhash #{etc}/libressl/certs
|
|
EOS
|
|
end
|
|
|
|
test do
|
|
# Make sure the necessary .cnf file exists, otherwise LibreSSL gets moody.
|
|
assert_predicate HOMEBREW_PREFIX/"etc/libressl/openssl.cnf", :exist?,
|
|
"LibreSSL requires the .cnf file for some functionality"
|
|
|
|
# Check LibreSSL itself functions as expected.
|
|
(testpath/"testfile.txt").write("This is a test file")
|
|
expected_checksum = "e2d0fe1585a63ec6009c8016ff8dda8b17719a637405a4e23c0ff81339148249"
|
|
system "#{bin}/openssl", "dgst", "-sha256", "-out", "checksum.txt", "testfile.txt"
|
|
open("checksum.txt") do |f|
|
|
checksum = f.read(100).split("=").last.strip
|
|
assert_equal checksum, expected_checksum
|
|
end
|
|
end
|
|
end
|