141 lines
4.9 KiB
Ruby
141 lines
4.9 KiB
Ruby
class OpensslAT3 < Formula
|
|
desc "Cryptography and SSL/TLS Toolkit"
|
|
homepage "https://openssl.org/"
|
|
url "https://www.openssl.org/source/openssl-3.0.7.tar.gz"
|
|
mirror "https://www.mirrorservice.org/sites/ftp.openssl.org/source/openssl-3.0.7.tar.gz"
|
|
sha256 "83049d042a260e696f62406ac5c08bf706fd84383f945cf21bd61e9ed95c396e"
|
|
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_ventura: "5b3d605f5c1fcadfea094c5670091e4bec2b2de7c121874be166bc737ef64ccf"
|
|
sha256 arm64_monterey: "aaa47bcc0e7727e655af43748c77f580b1379403010177aab47978b737180295"
|
|
sha256 arm64_big_sur: "c84729c8726b7934f0a63d75fd2dce795c948f9b7ec29f9681f667de90b73f16"
|
|
sha256 ventura: "3fe02c4f33f395b1ff0af0e05fdac80ab09fc13e85236f33a2aecb105a83d996"
|
|
sha256 monterey: "8501aeeab59c63a75dd14c1b836269a6effb08058ec7afb35313f954b40d78c3"
|
|
sha256 big_sur: "a8231d898ef9e61de88fc916ed316e58862ef04f1f17563b2f6247fcc894247f"
|
|
sha256 catalina: "11f2d168758de4ac078c5799f2ce0fcc93e4f0c3d8b59e6f53eea700dfa02e83"
|
|
sha256 x86_64_linux: "1c2ee30c067e2a81dfa1d4f539c91fa278816a45c5d59ff798ec437a5de82f9c"
|
|
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
|