2011-03-10 05:11:03 +00:00
|
|
|
class Openssl < Formula
|
2014-10-15 02:06:49 +00:00
|
|
|
homepage "https://openssl.org"
|
|
|
|
url "https://www.openssl.org/source/openssl-1.0.1j.tar.gz"
|
2014-10-15 22:42:46 +00:00
|
|
|
mirror "https://raw.githubusercontent.com/DomT4/LibreMirror/master/OpenSSL/openssl-1.0.1j.tar.gz"
|
2014-10-15 02:06:49 +00:00
|
|
|
sha256 "1b60ca8789ba6f03e8ef20da2293b8dc131c39d83814e775069f02d26354edf3"
|
2014-12-07 02:06:12 +00:00
|
|
|
revision 1
|
2010-02-16 07:19:53 +00:00
|
|
|
|
2014-01-21 03:32:52 +00:00
|
|
|
bottle do
|
2014-12-07 02:20:58 +00:00
|
|
|
sha1 "ffc47898c5c5599745b644c1889e473418a18d5a" => :yosemite
|
|
|
|
sha1 "65e125a4777eb6dfb63f01a18f724246123dd79e" => :mavericks
|
|
|
|
sha1 "511057d68144943d149cea76718db55656c73dff" => :mountain_lion
|
2014-01-21 03:32:52 +00:00
|
|
|
end
|
|
|
|
|
2014-05-16 04:45:42 +00:00
|
|
|
option :universal
|
2014-06-04 12:41:37 +00:00
|
|
|
option "without-check", "Skip build-time tests (not recommended)"
|
2014-05-16 04:45:42 +00:00
|
|
|
|
|
|
|
depends_on "makedepend" => :build
|
2014-03-12 16:43:37 +00:00
|
|
|
|
2011-03-16 05:01:31 +00:00
|
|
|
keg_only :provided_by_osx,
|
2014-10-16 05:15:08 +00:00
|
|
|
"Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries"
|
2010-10-17 15:52:14 +00:00
|
|
|
|
2014-05-16 04:45:42 +00:00
|
|
|
def arch_args
|
|
|
|
{
|
2014-07-28 19:31:03 +00:00
|
|
|
:x86_64 => %w[darwin64-x86_64-cc enable-ec_nistp_64_gcc_128],
|
2014-05-16 04:45:42 +00:00
|
|
|
:i386 => %w[darwin-i386-cc],
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
def configure_args; %W[
|
|
|
|
--prefix=#{prefix}
|
|
|
|
--openssldir=#{openssldir}
|
2014-08-24 16:45:37 +00:00
|
|
|
no-ssl2
|
2014-05-16 04:45:42 +00:00
|
|
|
zlib-dynamic
|
|
|
|
shared
|
|
|
|
enable-cms
|
|
|
|
]
|
|
|
|
end
|
|
|
|
|
2010-02-16 07:19:53 +00:00
|
|
|
def install
|
2014-05-16 04:45:42 +00:00
|
|
|
if build.universal?
|
|
|
|
ENV.permit_arch_flags
|
|
|
|
archs = Hardware::CPU.universal_archs
|
|
|
|
elsif MacOS.prefer_64_bit?
|
|
|
|
archs = [Hardware::CPU.arch_64_bit]
|
2013-04-08 22:04:11 +00:00
|
|
|
else
|
2014-05-16 04:45:42 +00:00
|
|
|
archs = [Hardware::CPU.arch_32_bit]
|
2013-04-08 22:04:11 +00:00
|
|
|
end
|
2012-04-17 08:34:14 +00:00
|
|
|
|
2014-05-16 04:45:42 +00:00
|
|
|
dirs = []
|
|
|
|
|
|
|
|
archs.each do |arch|
|
|
|
|
if build.universal?
|
|
|
|
dir = "build-#{arch}"
|
|
|
|
dirs << dir
|
|
|
|
mkdir dir
|
|
|
|
mkdir "#{dir}/engines"
|
|
|
|
system "make", "clean"
|
|
|
|
end
|
|
|
|
|
|
|
|
ENV.deparallelize
|
|
|
|
system "perl", "./Configure", *(configure_args + arch_args[arch])
|
|
|
|
system "make", "depend"
|
|
|
|
system "make"
|
2014-12-20 17:25:18 +00:00
|
|
|
|
|
|
|
if (MacOS.prefer_64_bit? || arch == MacOS.preferred_arch) && build.with?("check")
|
|
|
|
system "make", "test"
|
|
|
|
end
|
2014-05-16 04:45:42 +00:00
|
|
|
|
|
|
|
if build.universal?
|
|
|
|
cp Dir["*.?.?.?.dylib", "*.a", "apps/openssl"], dir
|
|
|
|
cp Dir["engines/**/*.dylib"], "#{dir}/engines"
|
|
|
|
end
|
|
|
|
end
|
2011-07-22 00:09:26 +00:00
|
|
|
|
2012-04-17 09:08:58 +00:00
|
|
|
system "make", "install", "MANDIR=#{man}", "MANSUFFIX=ssl"
|
2014-05-16 04:45:42 +00:00
|
|
|
|
|
|
|
if build.universal?
|
|
|
|
%w[libcrypto libssl].each do |libname|
|
|
|
|
system "lipo", "-create", "#{dirs.first}/#{libname}.1.0.0.dylib",
|
|
|
|
"#{dirs.last}/#{libname}.1.0.0.dylib",
|
|
|
|
"-output", "#{lib}/#{libname}.1.0.0.dylib"
|
|
|
|
system "lipo", "-create", "#{dirs.first}/#{libname}.a",
|
|
|
|
"#{dirs.last}/#{libname}.a",
|
|
|
|
"-output", "#{lib}/#{libname}.a"
|
|
|
|
end
|
|
|
|
|
|
|
|
Dir.glob("#{dirs.first}/engines/*.dylib") do |engine|
|
|
|
|
libname = File.basename(engine)
|
|
|
|
system "lipo", "-create", "#{dirs.first}/engines/#{libname}",
|
|
|
|
"#{dirs.last}/engines/#{libname}",
|
|
|
|
"-output", "#{lib}/engines/#{libname}"
|
|
|
|
end
|
|
|
|
|
|
|
|
system "lipo", "-create", "#{dirs.first}/openssl",
|
|
|
|
"#{dirs.last}/openssl",
|
|
|
|
"-output", "#{bin}/openssl"
|
|
|
|
end
|
2010-02-16 07:19:53 +00:00
|
|
|
end
|
2013-02-17 18:29:09 +00:00
|
|
|
|
2013-07-14 00:16:31 +00:00
|
|
|
def openssldir
|
|
|
|
etc/"openssl"
|
|
|
|
end
|
|
|
|
|
2014-04-24 18:25:54 +00:00
|
|
|
def post_install
|
2014-03-26 21:24:20 +00:00
|
|
|
keychains = %w[
|
|
|
|
/Library/Keychains/System.keychain
|
|
|
|
/System/Library/Keychains/SystemRootCertificates.keychain
|
|
|
|
]
|
|
|
|
|
2013-07-14 00:16:31 +00:00
|
|
|
openssldir.mkpath
|
2014-04-24 18:25:54 +00:00
|
|
|
(openssldir/"cert.pem").atomic_write `security find-certificate -a -p #{keychains.join(" ")}`
|
2013-02-17 18:29:09 +00:00
|
|
|
end
|
2014-01-15 04:05:39 +00:00
|
|
|
|
2014-04-24 18:25:54 +00:00
|
|
|
def caveats; <<-EOS.undent
|
|
|
|
A CA file has been bootstrapped using certificates from the system
|
|
|
|
keychain. To add additional certificates, place .pem files in
|
|
|
|
#{openssldir}/certs
|
|
|
|
|
|
|
|
and run
|
|
|
|
#{opt_bin}/c_rehash
|
|
|
|
EOS
|
|
|
|
end
|
|
|
|
|
2014-01-15 04:05:39 +00:00
|
|
|
test do
|
2014-12-06 17:53:36 +00:00
|
|
|
# Make sure the necessary .cnf file exists, otherwise OpenSSL gets moody.
|
|
|
|
assert (HOMEBREW_PREFIX/"etc/openssl/openssl.cnf").exist?,
|
|
|
|
"OpenSSL requires the .cnf file for some functionality"
|
|
|
|
|
|
|
|
# Check OpenSSL itself functions as expected.
|
2014-10-15 02:06:49 +00:00
|
|
|
(testpath/"testfile.txt").write("This is a test file")
|
2014-01-15 04:05:39 +00:00
|
|
|
expected_checksum = "91b7b0b1e27bfbf7bc646946f35fa972c47c2d32"
|
2014-10-15 02:06:49 +00:00
|
|
|
system "#{bin}/openssl", "dgst", "-sha1", "-out", "checksum.txt", "testfile.txt"
|
2014-01-15 04:05:39 +00:00
|
|
|
open("checksum.txt") do |f|
|
|
|
|
checksum = f.read(100).split("=").last.strip
|
|
|
|
assert_equal checksum, expected_checksum
|
|
|
|
end
|
|
|
|
end
|
2010-02-16 07:19:53 +00:00
|
|
|
end
|