homebrew-core/Formula/stunnel.rb

103 lines
3.4 KiB
Ruby

class Stunnel < Formula
desc "SSL tunneling program"
homepage "https://www.stunnel.org/"
url "https://www.stunnel.org/downloads/stunnel-5.58.tar.gz"
sha256 "d4c14cc096577edca3f6a2a59c2f51869e35350b3988018ddf808c88e5973b79"
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_big_sur: "47e3d1a9585e643d19bf40bbb20ecc5f7d42519d5975bb599e00fc09ca5b31e0"
sha256 cellar: :any, big_sur: "d58e8c12d8876325031dba9bcd538a60180c43ac30cdc2d0710c0f4535ec1711"
sha256 cellar: :any, catalina: "d80657bc44794018b06497504b5e5231f202cffa9123a29d962fa98d408853d3"
sha256 cellar: :any, mojave: "d8054e955a2e33e8da6afb7ab9a770cf8745ff1741d408d718c27ab91598c588"
end
depends_on "openssl@1.1"
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@1.1"].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
args = %w[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/]
system "dd", "if=/dev/urandom", "of=stunnel.rnd", "bs=256", "count=1"
system "#{Formula["openssl@1.1"].opt_bin}/openssl", *args
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
plist_options manual: "stunnel"
def plist
<<~EOS
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>#{plist_name}</string>
<key>ProgramArguments</key>
<array>
<string>#{opt_bin}/stunnel</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
EOS
end
test do
(testpath/"tstunnel.conf").write <<~EOS
cert = #{etc}/stunnel/stunnel.pem
setuid = nobody
setgid = nobody
[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