2014-07-11 19:09:38 +00:00
|
|
|
class Libressl < Formula
|
2015-05-19 00:00:59 +00:00
|
|
|
desc "Version of the SSL/TLS protocol forked from OpenSSL"
|
2014-07-11 19:09:38 +00:00
|
|
|
homepage "http://www.libressl.org/"
|
2015-08-30 16:16:52 +00:00
|
|
|
url "http://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-2.2.3.tar.gz"
|
|
|
|
sha256 "a1ccc21adf91d60e99246031b99c930c9af5e1b1b5a61b1bec87beef6f16d882"
|
2014-07-11 19:09:38 +00:00
|
|
|
|
2014-07-14 00:48:07 +00:00
|
|
|
bottle do
|
2015-08-30 21:25:10 +00:00
|
|
|
sha256 "a4e4afd644d5a603e99ad091a87c10cf132b40b7e8bf3990971223e49a290591" => :yosemite
|
|
|
|
sha256 "fcebe2fdce64cbbd8d6b2e3fe0bd876b5591decfc87f614f754013ed170077a7" => :mavericks
|
|
|
|
sha256 "aa98a4c2a616a67e7352ee1dd9432d03703a2f26804fbba45e8d915d2fa05ed6" => :mountain_lion
|
2014-07-14 00:48:07 +00:00
|
|
|
end
|
|
|
|
|
2014-07-11 19:09:38 +00:00
|
|
|
head do
|
|
|
|
url "https://github.com/libressl-portable/portable.git"
|
2015-08-17 05:42:36 +00:00
|
|
|
|
2014-07-11 19:09:38 +00:00
|
|
|
depends_on "automake" => :build
|
|
|
|
depends_on "autoconf" => :build
|
|
|
|
depends_on "libtool" => :build
|
|
|
|
end
|
|
|
|
|
2014-12-07 01:06:21 +00:00
|
|
|
keg_only "LibreSSL is not linked to prevent conflict with the system OpenSSL."
|
2014-07-11 19:09:38 +00:00
|
|
|
|
|
|
|
def install
|
2014-12-07 01:06:21 +00:00
|
|
|
args = %W[
|
|
|
|
--disable-dependency-tracking
|
|
|
|
--disable-silent-rules
|
|
|
|
--prefix=#{prefix}
|
|
|
|
--with-openssldir=#{etc}/libressl
|
|
|
|
--sysconfdir=#{etc}/libressl
|
|
|
|
]
|
2014-07-11 19:09:38 +00:00
|
|
|
|
2015-08-17 05:42:36 +00:00
|
|
|
# https://github.com/libressl-portable/portable/issues/121
|
|
|
|
args << "--disable-asm" if MacOS.version <= :snow_leopard
|
|
|
|
|
2014-12-07 01:06:21 +00:00
|
|
|
system "./autogen.sh" if build.head?
|
|
|
|
system "./configure", *args
|
2014-07-11 19:09:38 +00:00
|
|
|
system "make"
|
|
|
|
system "make", "check"
|
|
|
|
system "make", "install"
|
|
|
|
end
|
|
|
|
|
2014-11-27 13:49:49 +00:00
|
|
|
def post_install
|
2014-12-07 01:06:21 +00:00
|
|
|
keychains = %w[
|
|
|
|
/Library/Keychains/System.keychain
|
|
|
|
/System/Library/Keychains/SystemRootCertificates.keychain
|
|
|
|
]
|
|
|
|
|
2015-07-01 22:23:36 +00:00
|
|
|
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("openssl x509 -inform pem -checkend 0 -noout", "w") do |openssl_io|
|
|
|
|
openssl_io.write(cert)
|
|
|
|
openssl_io.close_write
|
|
|
|
end
|
|
|
|
|
|
|
|
$?.success?
|
|
|
|
end
|
|
|
|
|
2015-08-08 17:47:05 +00:00
|
|
|
# LibreSSL install a default pem - We prefer to use OS X for consistency.
|
|
|
|
rm_f etc/"libressl/cert.pem"
|
2015-07-01 22:23:36 +00:00
|
|
|
(etc/"libressl/cert.pem").atomic_write(valid_certs.join("\n"))
|
2014-11-27 13:49:49 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def caveats; <<-EOS.undent
|
2014-12-07 01:06:21 +00:00
|
|
|
A CA file has been bootstrapped using certificates from the system
|
|
|
|
keychain. To add additional certificates, place .pem files in
|
2015-04-10 17:33:27 +00:00
|
|
|
#{etc}/libressl/certs
|
|
|
|
|
|
|
|
and run
|
|
|
|
#{opt_bin}/openssl certhash #{etc}/libressl/certs
|
2014-11-27 13:49:49 +00:00
|
|
|
EOS
|
|
|
|
end
|
|
|
|
|
2014-07-11 19:09:38 +00:00
|
|
|
test do
|
2015-08-08 17:47:05 +00:00
|
|
|
# Make sure the necessary .cnf file exists, otherwise LibreSSL gets moody.
|
|
|
|
assert (HOMEBREW_PREFIX/"etc/libressl/openssl.cnf").exist?,
|
|
|
|
"LibreSSL requires the .cnf file for some functionality"
|
|
|
|
|
|
|
|
# Check LibreSSL itself functions as expected.
|
2014-07-11 19:09:38 +00:00
|
|
|
(testpath/"testfile.txt").write("This is a test file")
|
2015-08-08 17:47:05 +00:00
|
|
|
expected_checksum = "e2d0fe1585a63ec6009c8016ff8dda8b17719a637405a4e23c0ff81339148249"
|
|
|
|
system "#{bin}/openssl", "dgst", "-sha256", "-out", "checksum.txt", "testfile.txt"
|
2014-07-11 19:09:38 +00:00
|
|
|
open("checksum.txt") do |f|
|
|
|
|
checksum = f.read(100).split("=").last.strip
|
|
|
|
assert_equal checksum, expected_checksum
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|