97 lines
3.1 KiB
Ruby
97 lines
3.1 KiB
Ruby
class Stunnel < Formula
|
|
desc "SSL tunneling program"
|
|
homepage "https://www.stunnel.org/"
|
|
url "https://www.stunnel.org/downloads/stunnel-5.55.tar.gz"
|
|
sha256 "90de69f41c58342549e74c82503555a6426961b29af3ed92f878192727074c62"
|
|
revision 1
|
|
|
|
bottle do
|
|
cellar :any
|
|
sha256 "1ec3c9e5c73a63ffb7db7a900ef209457f124d38fb260fd705661d0c7d6ce263" => :catalina
|
|
sha256 "fafa5e38414ab12177298f5b77a4371edfd8602409477b9b0007da2b1b1cf88e" => :mojave
|
|
sha256 "b47a1919e1b97f074635d8779304aed0e4a10357b5a4e8a2d012628f2072a613" => :high_sierra
|
|
sha256 "a5f0c738c84803bc42de720998b0328e50c294d4dd62d9880754c56c39d9a7eb" => :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
|