139 lines
4.7 KiB
Ruby
139 lines
4.7 KiB
Ruby
class OpensslAT3 < Formula
|
|
desc "Cryptography and SSL/TLS Toolkit"
|
|
homepage "https://openssl.org/"
|
|
url "https://www.openssl.org/source/openssl-3.0.1.tar.gz"
|
|
mirror "https://www.mirrorservice.org/sites/ftp.openssl.org/source/openssl-3.0.1.tar.gz"
|
|
sha256 "c311ad853353bce796edad01a862c50a8a587f62e7e2100ef465ab53ec9b06d1"
|
|
license "Apache-2.0"
|
|
|
|
livecheck do
|
|
url "https://www.openssl.org/source/"
|
|
regex(/href=.*?openssl[._-]v?(\d+(?:\.\d+)+)\.t/i)
|
|
end
|
|
|
|
bottle do
|
|
sha256 arm64_monterey: "f3c6edd4c7917ee5b82dda776ad8d70569dc5baddfe0f773954e4bb73a6946db"
|
|
sha256 arm64_big_sur: "64ceea118bb6e2ea700168dda10109f8113ba3277fbe576aba97167c2a9feff0"
|
|
sha256 monterey: "331a18b7ac0b35d55adb422268c6b08190b378bdfec915a5f6d0b7375864fa4a"
|
|
sha256 big_sur: "48f4b3d0a036e4bf5c63732ce32e70e57a1ad1f9311f21776cef6431796e0cd1"
|
|
sha256 catalina: "3d687315c44656ae4dcf17d9f1f82f15e4b959816afb9cbef8073676b4aed480"
|
|
sha256 x86_64_linux: "51f292234a6a9933673d4afbf6ee98e676c1d523ec2316b49425c45d55e7471c"
|
|
end
|
|
|
|
keg_only :shadowed_by_macos, "macOS provides LibreSSL"
|
|
|
|
depends_on "ca-certificates"
|
|
|
|
on_linux do
|
|
keg_only "it conflicts with the `openssl@1.1` formula"
|
|
|
|
resource "Test::Harness" do
|
|
url "https://cpan.metacpan.org/authors/id/L/LE/LEONT/Test-Harness-3.42.tar.gz"
|
|
sha256 "0fd90d4efea82d6e262e6933759e85d27cbcfa4091b14bf4042ae20bab528e53"
|
|
end
|
|
|
|
resource "Test::More" do
|
|
url "https://cpan.metacpan.org/authors/id/E/EX/EXODIST/Test-Simple-1.302186.tar.gz"
|
|
sha256 "2895c8da7c3fe632e5714c7cc548705202cdbf3afcbc0e929bc5e6a5172265d4"
|
|
end
|
|
|
|
resource "ExtUtils::MakeMaker" do
|
|
url "https://cpan.metacpan.org/authors/id/B/BI/BINGOS/ExtUtils-MakeMaker-7.62.tar.gz"
|
|
sha256 "5022ad857fd76bd3f6b16af099fe2324639d9932e08f21e891fb313d9cae1705"
|
|
end
|
|
end
|
|
|
|
# SSLv2 died with 1.1.0, so no-ssl2 no longer required.
|
|
# SSLv3 & zlib are off by default with 1.1.0 but this may not
|
|
# be obvious to everyone, so explicitly state it for now to
|
|
# help debug inevitable breakage.
|
|
def configure_args
|
|
args = %W[
|
|
--prefix=#{prefix}
|
|
--openssldir=#{openssldir}
|
|
--libdir=#{lib}
|
|
no-ssl3
|
|
no-ssl3-method
|
|
no-zlib
|
|
]
|
|
on_linux do
|
|
args += (ENV.cflags || "").split
|
|
args += (ENV.cppflags || "").split
|
|
args += (ENV.ldflags || "").split
|
|
end
|
|
args
|
|
end
|
|
|
|
def install
|
|
if OS.linux?
|
|
ENV.prepend_create_path "PERL5LIB", libexec/"lib/perl5"
|
|
|
|
%w[ExtUtils::MakeMaker Test::Harness Test::More].each do |r|
|
|
resource(r).stage do
|
|
system "perl", "Makefile.PL", "INSTALL_BASE=#{libexec}"
|
|
system "make", "PERL5LIB=#{ENV["PERL5LIB"]}", "CC=#{ENV.cc}"
|
|
system "make", "install"
|
|
end
|
|
end
|
|
end
|
|
|
|
# This could interfere with how we expect OpenSSL to build.
|
|
ENV.delete("OPENSSL_LOCAL_CONFIG_DIR")
|
|
|
|
# This ensures where Homebrew's Perl is needed the Cellar path isn't
|
|
# hardcoded into OpenSSL's scripts, causing them to break every Perl update.
|
|
# Whilst our env points to opt_bin, by default OpenSSL resolves the symlink.
|
|
ENV["PERL"] = Formula["perl"].opt_bin/"perl" if which("perl") == Formula["perl"].opt_bin/"perl"
|
|
|
|
arch_args = []
|
|
if OS.mac?
|
|
arch_args += %W[darwin64-#{Hardware::CPU.arch}-cc enable-ec_nistp_64_gcc_128]
|
|
elsif Hardware::CPU.intel?
|
|
arch_args << (Hardware::CPU.is_64_bit? ? "linux-x86_64" : "linux-elf")
|
|
elsif Hardware::CPU.arm?
|
|
arch_args << (Hardware::CPU.is_64_bit? ? "linux-aarch64" : "linux-armv4")
|
|
end
|
|
|
|
openssldir.mkpath
|
|
system "perl", "./Configure", *(configure_args + arch_args)
|
|
system "make"
|
|
system "make", "install", "MANDIR=#{man}", "MANSUFFIX=ssl"
|
|
system "make", "test"
|
|
end
|
|
|
|
def openssldir
|
|
etc/"openssl@3"
|
|
end
|
|
|
|
def post_install
|
|
rm_f openssldir/"cert.pem"
|
|
openssldir.install_symlink Formula["ca-certificates"].pkgetc/"cert.pem"
|
|
end
|
|
|
|
def caveats
|
|
<<~EOS
|
|
A CA file has been bootstrapped using certificates from the system
|
|
keychain. To add additional certificates, place .pem files in
|
|
#{openssldir}/certs
|
|
|
|
and run
|
|
#{opt_bin}/c_rehash
|
|
EOS
|
|
end
|
|
|
|
test do
|
|
# Make sure the necessary .cnf file exists, otherwise OpenSSL gets moody.
|
|
assert_predicate pkgetc/"openssl.cnf", :exist?,
|
|
"OpenSSL requires the .cnf file for some functionality"
|
|
|
|
# Check OpenSSL 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
|