homebrew-core/Formula/stunnel.rb

105 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.57.tar.gz"
sha256 "af5ab973dde11807c38735b87bdd87563a47d2fa1c72a07929fcfce80a600fe1"
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
cellar :any
rebuild 1
sha256 "df0539084eff628b24a2d41e69356e919cb764516d7bf4602f037f75a2617bf8" => :big_sur
sha256 "878eba096ca3019a14b911d5c4e98850ebd8e5339e9d6921fc9c641c5251405e" => :catalina
sha256 "365dd14775cdcf6b7a4b9a92b9f2cfc9e2ab59534e250f30654e9d7a8c187015" => :mojave
sha256 "e9f7507a85fb3b2951f770fd9a784a48a90a02263733d870142e23bf2334f706" => :high_sierra
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