apotocki/openssl
OpenSSL (libssl, libcrypto), built from source.
- Library
- openssl
- Newest
- 4.1.0 (r1, android)
- Targets
- android, apple, linux, windows
- License
- Apache-2.0
- Homepage
- https://www.openssl.org
- Keywords
- tls, crypto
Use it
In otok.toml:
[deps.openssl]
recipe = "apotocki/openssl"
version = "~> 4.1.0"
Versions
| Version | Target | Channel | Published | Status |
|---|---|---|---|---|
| 4.1.0 (r1, android) | android | stable | 2026-11-14 | |
| 4.1.0 (r1, apple) | apple | stable | 2026-11-07 | |
| 4.1.0 (r1, linux) | linux | stable | 2026-11-14 | |
| 4.1.0 (r1, windows) | windows | stable | 2026-11-07 | |
| 4.0.3 (r1, apple) | apple | stable | 2026-11-07 | |
| 3.6.5 (r1, apple) | apple | stable | 2026-11-07 | |
| 3.5.9 (r1, apple) | apple | stable | 2026-11-07 |
4.1.0 (r1, android)
Platforms
android
Options
| Option | Type | Default | Description |
|---|---|---|---|
no-deprecated |
bool | false |
Configure with no-deprecated: removes the deprecated APIs. |
Toolchains
make { default-recipe = "apotocki/make", version = ">= 3.81" }perl { default-recipe = "apotocki/perl", version = ">= 5.30", when = { environment = ["linux/ndk", "macos/ndk"] } }
Recipe files
Configurations/60-otok.conf
## SPDX-License-Identifier: Apache-2.0
## An extension of OpenSSL's Configurations, after the settings of the android targets in 15-android.conf
## (Copyright The OpenSSL Project Authors), under OpenSSL's license, the Apache License 2.0.
## Configure targets of the otok recipe: one per ABI of the Android target. otok's toolchain brings the compiler and its
## flags (CC with --target and --sysroot, CFLAGS with the API level), so these targets carry no NDK probing, unlike the
## android targets of 15-android.conf, which look for the NDK in ANDROID_NDK_ROOT.
my %targets = (
"otok-android" => {
inherit_from => [ "linux-generic32" ],
template => 1,
bin_cflags => "-fPIE",
bin_lflags => "-pie",
enable => [ ],
shared_extension => ".so",
},
# as android-arm, without RC4_CHAR (a speed choice that changes RC4_KEY: the Android target keeps one include/ for its ABIs)
"otok-android-armeabi-v7a" => {
inherit_from => [ "otok-android" ],
bn_ops => "BN_LLONG",
asm_arch => 'armv4',
perlasm_scheme => "void",
},
# as android-arm64, with the pages of 16 KiB Android 15 devices may have
"otok-android-arm64-v8a" => {
inherit_from => [ "otok-android" ],
bn_ops => "SIXTY_FOUR_BIT_LONG",
asm_arch => 'aarch64',
perlasm_scheme => "linux64",
shared_ldflag => add("-Wl,-z,max-page-size=16384"),
},
# as android-x86
"otok-android-x86" => {
inherit_from => [ "otok-android" ],
CFLAGS => add(picker(release => "-fomit-frame-pointer")),
bn_ops => "BN_LLONG",
asm_arch => 'x86',
perlasm_scheme => "android",
ex_libs => add(threads("-latomic")),
},
# as android-x86_64
"otok-android-x86_64" => {
inherit_from => [ "otok-android" ],
bn_ops => "SIXTY_FOUR_BIT_LONG",
asm_arch => 'x86_64',
perlasm_scheme => "elf",
shared_ldflag => add("-Wl,-z,max-page-size=16384"),
},
);
build.lua
-- Configure with a target of Configurations/60-otok.conf and the slice's compiler and flags (the NDK's clang for the ABI and
-- the API level), then the libraries and the development files only. The directory OpenSSL looks for certificates in is
-- /system/etc/ssl.
--
-- On Windows, Configure refuses the native perl for the Unix makefile of the android targets: it runs with the perl of
-- MSYS2 beside make, which takes the source and the prefix as MSYS2 names them (/c/…; a path with a drive is not an
-- absolute one to its File::Spec) and hands them to the NDK's programs as C:/… again. The makefile's rules run in sh,
-- which would drop the backslashes of the -ffile-prefix-map the toolchain writes with Windows' separators.
local function msys_path(path)
return (path:gsub("^(%a):/", function(drive) return "/" .. drive:lower() .. "/" end))
end
function build(slice, options, deps)
local t = slice.toolchain
local shared = slice.linkage == "dynamic"
otok.copy(slice.recipe .. "/Configurations/60-otok.conf", slice.source .. "/Configurations/60-otok.conf")
local perl, source, prefix, cflags = slice.toolchains.perl, slice.source, slice.prefix, {}
for i, flag in ipairs(t.cflags) do cflags[i] = flag end
if slice.host:find("^windows") then
perl = slice.toolchains.make:gsub("[^/]*$", "") .. "perl.exe" -- apotocki/make 4.4.1-r4 or later
source, prefix = msys_path(source), msys_path(prefix)
for i, flag in ipairs(cflags) do
if flag:find("^%-ffile%-prefix%-map=") then cflags[i] = flag:gsub("\\", "/") end
end
end
local configure = { perl, source .. "/Configure", "otok-android-" .. slice.arch,
shared and "shared" or "no-shared", "no-tests", "--prefix=" .. prefix, "--openssldir=/system/etc/ssl", "--libdir=lib",
"CC=" .. t.cc, "CFLAGS=" .. table.concat(cflags, " "), "AR=" .. t.ar, "RANLIB=" .. t.ranlib }
if options["no-deprecated"] then table.insert(configure, "no-deprecated") end
otok.run(configure, { cwd = slice.build })
otok.make{ "build_libs", cwd = slice.build }
local install = { "install_dev", cwd = slice.build }
if shared then table.insert(install, 2, "install_runtime_libs") end
otok.make(install)
-- The Android target keeps one include/ for its ABIs, and configuration.h tells the size of BN_ULONG, which only the
-- word size of the ABI changes: 64-bit ABIs have SIXTY_FOUR_BIT_LONG, 32-bit ones BN_LLONG with THIRTY_TWO_BIT
local configuration = slice.prefix .. "/include/openssl/configuration.h"
local text, count = otok.read(configuration):gsub("#if !defined%(OPENSSL_SYS_UEFI%)\r?\n.-\r?\n#endif\r?\n", function()
return table.concat({
"#if !defined(OPENSSL_SYS_UEFI)",
"# ifdef __LP64__",
"# undef BN_LLONG",
"# define SIXTY_FOUR_BIT_LONG",
"# undef SIXTY_FOUR_BIT",
"# undef THIRTY_TWO_BIT",
"# else",
"# define BN_LLONG",
"# undef SIXTY_FOUR_BIT_LONG",
"# undef SIXTY_FOUR_BIT",
"# define THIRTY_TWO_BIT",
"# endif",
"#endif",
"",
}, "\n")
end, 1)
if count ~= 1 then error("configuration.h has no word size block of the expected form") end
otok.write(configuration, text)
local p = slice.prefix
local ext = shared and ".so" or ".a"
return {
libraries = { ssl = otok.glob("lib/libssl" .. ext, p)[1], crypto = otok.glob("lib/libcrypto" .. ext, p)[1] },
headers = p .. "/include",
}
end
recipe.toml
# The otok recipe of OpenSSL (https://github.com/apotocki/otok): libssl and libcrypto for Android, from the release
# tag, with the Configure targets of Configurations/60-otok.conf and the slice's compiler; static or dynamic.
[recipe]
api = 1
library = "openssl"
name = "openssl"
version = "4.1.0"
revision = 1
license = "Apache-2.0"
license-files = ["LICENSE.txt"]
homepage = "https://www.openssl.org"
description = "OpenSSL (libssl, libcrypto), built from source."
keywords = ["tls", "crypto"]
linkage = ["static", "dynamic"]
[source]
git = "https://github.com/openssl/openssl"
commit = "2f4e3a5fec05394068cfa7379890ab552483a8a6"
tag = "openssl-4.1.0"
[platforms]
supported = ["android"]
build-on = ["*/ndk"]
[options.no-deprecated]
type = "bool"
default = false
doc = "Configure with no-deprecated: removes the deprecated APIs."
[[product]]
name = "OpenSSL"
libraries = ["ssl", "crypto"]
headers = "crypto"
defines = [{ define = "OPENSSL_NO_DEPRECATED", when = { option = "no-deprecated" } }]
[toolchains]
make = { version = ">= 3.81", default-recipe = "apotocki/make" }
# OpenSSL's Configure writes the Unix makefile of the android targets only with a perl of Unix paths: on Windows, the
# perl of MSYS2 beside make (apotocki/make 4.4.1-r4 or later), not the native one of apotocki/perl (build.lua)
perl = { version = ">= 5.30", default-recipe = "apotocki/perl", when = { environment = ["linux/ndk", "macos/ndk"] } }