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.62.tar.gz"
|
|
sha256 "9cf5bb949022aa66c736c1326554cca27d0641605a6370274edc4951eb5bd339"
|
|
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: "82c47650edac704ee6fbdaa75befa99e769ea0209a4303a50f5274c60986f0d3"
|
|
sha256 cellar: :any, arm64_big_sur: "d539d771869c2d92fd998a75f7f66c6c332954cff17bfbfc40850e098a58aa44"
|
|
sha256 cellar: :any, monterey: "89cbf82db1d97170eedd416807fcb7e20dd9a2e7d82db232b5eab5e4cebed34a"
|
|
sha256 cellar: :any, big_sur: "cbe3508823ebb850642a8d8290e71001ac34f3768ddae38dedfa431875147fed"
|
|
sha256 cellar: :any, catalina: "95442130a1f8b8a504326371587bb4ad9563db0418dfc5b4e410e1dceed578cb"
|
|
sha256 cellar: :any_skip_relocation, x86_64_linux: "d1cb3d49ca9477484993f8e9a78c3b3a3bd9504224fd0c5b6d3d35c2bbd36303"
|
|
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
|