homebrew-core/Formula/libressl.rb
2016-06-16 16:54:30 +01:00

88 lines
2.9 KiB
Ruby

class Libressl < Formula
desc "Version of the SSL/TLS protocol forked from OpenSSL"
homepage "http://www.libressl.org/"
# Please ensure when updating version the release is from stable branch.
url "http://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-2.3.6.tar.gz"
sha256 "358a4779e6813bd06f07db0cf0f0fe531401ed0c6ed958973d404416c3d537fa"
bottle do
sha256 "e20fddd926faeb3d6d0d45bd74f803208fc5e39d31a1f7032d8bbd2fe0a173fb" => :el_capitan
sha256 "e420e8207283bc89f0775ac64dd091c21b83a3f3bda2083bf8f887fbc0a70c94" => :yosemite
sha256 "107d7cd49afec0f536dee079327946dfb42a23bda4f590efff00bef39313d47d" => :mavericks
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
$?.success?
end
# LibreSSL install a default pem - We prefer to use OS X 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.undent
A CA file has been bootstrapped using certificates from the system
keychain. To add additional certificates, 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 (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