Download latest OpenSSL, find version of newest installed iOS SDK, and build with OpenSSL-for-iPhone.
#!/bin/bash
function get_openssl_tar_gz {
export PERL_UNICODE=SAD
local url="http://www.openssl.org/source/"
# get [LATEST] openssl source archive
TAR_GZ=$(curl -sSL $url |\
xmllint --html --xmlout --encode utf-8 --dropdtd --nowarning - |\
xpath "string(//b[text()='[LATEST]']/../a[substring(@href, string-length(@href) - 5, 6) = 'tar.gz']/@href)" 2> /dev/null)
curl -sSL -O $url$TAR_GZ
}
function set_version {
VERSION=${TAR_GZ/.tar.gz}
VERSION=${VERSION#openssl-}
echo "VERSION=\"$VERSION\""
}
function get_build_libssl_sh {
curl -OsSL 'https://raw.githubusercontent.com/x2on/OpenSSL-for-iPhone/master/build-libssl.sh'
}
function edit_build_libssl_sh {
# substitute VERSION in build-libssl.sh
sed -i '' -e "1,\$s@^VERSION=.*@VERSION=${VERSION}@" build-libssl.sh
}
function cleanup {
rm -rf bin src *.tar.gz
}
get_openssl_tar_gz
set_version
get_build_libssl_sh
edit_build_libssl_sh
sh build-libssl.sh
cleanup
lipo -info lib/*.a
download:
fetch-and-build-libssl.sh