98 lines
3.3 KiB
Ruby
98 lines
3.3 KiB
Ruby
class Stunnel < Formula
|
|
desc "SSL tunneling program"
|
|
homepage "https://www.stunnel.org/"
|
|
url "https://www.stunnel.org/downloads/stunnel-5.64.tar.gz"
|
|
sha256 "eebe53ed116ba43b2e786762b0c2b91511e7b74857ad4765824e7199e6faf883"
|
|
license "GPL-2.0-or-later"
|
|
|
|
livecheck do
|
|
url "https://www.stunnel.org/downloads.html"
|
|
regex(/href=.*?stunnel[._-]v?(\d+(?:\.\d+)+)\.t/i)
|
|
end
|
|
|
|
bottle do
|
|
sha256 cellar: :any, arm64_monterey: "661fb14a483558d6572ed459c085fb3456d60dc58dcced2caf2bf082ba074ba9"
|
|
sha256 cellar: :any, arm64_big_sur: "324a76ed9a0567ccb8b5553be53d8273e24767a5258a5769b4d4ba59bc19a9ca"
|
|
sha256 cellar: :any, monterey: "30b9d6e8dafd81b4cb5da4978f9abfb309f682884596a85e84c75ce1f248649a"
|
|
sha256 cellar: :any, big_sur: "ea4d844c27669ad32c6166dc1b7f073be0e67aa9dbb832bacbc6a29a48ffec17"
|
|
sha256 cellar: :any, catalina: "2d287f3838ee54b9296feb29aa4d79f5091bad04ebc079e1af5bb0ef94226783"
|
|
sha256 cellar: :any_skip_relocation, x86_64_linux: "4189f6dfab60662d3a9747cc1323f34242fcff1f938f0c7ca50fb2eaf3597f0b"
|
|
end
|
|
|
|
depends_on "openssl@3"
|
|
|
|
def install
|
|
system "./configure", "--disable-dependency-tracking",
|
|
"--disable-silent-rules",
|
|
"--prefix=#{prefix}",
|
|
"--sysconfdir=#{etc}",
|
|
"--localstatedir=#{var}",
|
|
"--mandir=#{man}",
|
|
"--disable-libwrap",
|
|
"--disable-systemd",
|
|
"--with-ssl=#{Formula["openssl@3"].opt_prefix}"
|
|
system "make", "install"
|
|
|
|
# This programmatically recreates pem creation used in the tools Makefile
|
|
# which would usually require interactivity to resolve.
|
|
cd "tools" do
|
|
system "dd", "if=/dev/urandom", "of=stunnel.rnd", "bs=256", "count=1"
|
|
system "#{Formula["openssl@3"].opt_bin}/openssl", "req",
|
|
"-new", "-x509",
|
|
"-days", "365",
|
|
"-rand", "stunnel.rnd",
|
|
"-config", "openssl.cnf",
|
|
"-out", "stunnel.pem",
|
|
"-keyout", "stunnel.pem",
|
|
"-sha256",
|
|
"-subj", "/C=PL/ST=Mazovia Province/L=Warsaw/O=Stunnel Developers/OU=Provisional CA/CN=localhost/"
|
|
chmod 0600, "stunnel.pem"
|
|
(etc/"stunnel").install "stunnel.pem"
|
|
end
|
|
end
|
|
|
|
def caveats
|
|
<<~EOS
|
|
A bogus SSL server certificate has been installed to:
|
|
#{etc}/stunnel/stunnel.pem
|
|
|
|
This certificate will be used by default unless a config file says otherwise!
|
|
Stunnel will refuse to load the sample configuration file if left unedited.
|
|
|
|
In your stunnel configuration, specify a SSL certificate with
|
|
the "cert =" option for each service.
|
|
|
|
To use Stunnel with Homebrew services, make sure to set "foreground = yes" in
|
|
your Stunnel configuration.
|
|
EOS
|
|
end
|
|
|
|
service do
|
|
run [opt_bin/"stunnel"]
|
|
end
|
|
|
|
test do
|
|
user = if OS.mac?
|
|
"nobody"
|
|
else
|
|
ENV["USER"]
|
|
end
|
|
(testpath/"tstunnel.conf").write <<~EOS
|
|
cert = #{etc}/stunnel/stunnel.pem
|
|
|
|
setuid = #{user}
|
|
setgid = #{user}
|
|
|
|
[pop3s]
|
|
accept = 995
|
|
connect = 110
|
|
|
|
[imaps]
|
|
accept = 993
|
|
connect = 143
|
|
EOS
|
|
|
|
assert_match "successful", pipe_output("#{bin}/stunnel #{testpath}/tstunnel.conf 2>&1")
|
|
end
|
|
end
|