class Gnutls < Formula desc "GNU Transport Layer Security (TLS) Library" homepage "https://gnutls.org/" url "https://www.gnupg.org/ftp/gcrypt/gnutls/v3.6/gnutls-3.6.11.1.tar.xz" mirror "https://www.mirrorservice.org/sites/ftp.gnupg.org/gcrypt/gnutls/v3.6/gnutls-3.6.11.1.tar.xz" sha256 "fbba12f3db9a55dbf027e14111755817ec44b57eabec3e8089aac8ac6f533cf8" bottle do sha256 "00b17bc3c4c3a74318a582cc45068042b8bd74ea96fac02116e71772a2355dc1" => :catalina sha256 "ee8df35a8efcb0595f454d980da7d46da5420d32b99c76f29d70c3f43bfb3c2d" => :mojave sha256 "bff8a1931f8a8fc192a3f2e2b37c6fb2dd45657769cb3ee373520ddd9bf3c515" => :high_sierra end depends_on "autoconf" => :build depends_on "automake" => :build depends_on "pkg-config" => :build depends_on "gmp" depends_on "libidn2" depends_on "libtasn1" depends_on "libunistring" depends_on "nettle" depends_on "p11-kit" depends_on "unbound" def install args = %W[ --disable-dependency-tracking --disable-silent-rules --disable-static --prefix=#{prefix} --sysconfdir=#{etc} --with-default-trust-store-file=#{etc}/openssl/cert.pem --disable-guile --disable-heartbeat-support --with-p11-kit ] # Work around a gnulib issue with macOS Catalina args << "gl_cv_func_ftello_works=yes" system "./configure", *args system "make", "install" # certtool shadows the macOS certtool utility mv bin/"certtool", bin/"gnutls-certtool" mv man1/"certtool.1", man1/"gnutls-certtool.1" end def post_install keychains = %w[ /System/Library/Keychains/SystemRootCertificates.keychain ] certs_list = `security find-certificate -a -p #{keychains.join(" ")}` certs = certs_list.scan(/-----BEGIN CERTIFICATE-----.*?-----END CERTIFICATE-----/m) valid_certs = certs.select do |cert| IO.popen("openssl x509 -inform pem -checkend 0 -noout", "w") do |openssl_io| openssl_io.write(cert) openssl_io.close_write end $CHILD_STATUS.success? end openssldir = etc/"openssl" openssldir.mkpath (openssldir/"cert.pem").atomic_write(valid_certs.join("\n")) end test do system bin/"gnutls-cli", "--version" end end