blob: 7727ec43e87d97d2f1bef8dfcf6e60bb6ff7f18b [file] [log] [blame]
Andrew Geissler595f6302022-01-24 19:11:47 +00001SUMMARY = "Secure Socket Layer"
2DESCRIPTION = "Secure Socket Layer (SSL) binary and related cryptographic tools."
3HOMEPAGE = "http://www.openssl.org/"
4BUGTRACKER = "http://www.openssl.org/news/vulnerabilities.html"
5SECTION = "libs/network"
6
7LICENSE = "Apache-2.0"
8LIC_FILES_CHKSUM = "file://LICENSE.txt;md5=c75985e733726beaba57bc5253e96d04"
9
10SRC_URI = "http://www.openssl.org/source/openssl-${PV}.tar.gz \
11 file://run-ptest \
12 file://0001-buildinfo-strip-sysroot-and-debug-prefix-map-from-co.patch \
13 file://afalg.patch \
14 file://0001-Configure-do-not-tweak-mips-cflags.patch \
15 file://reproducibility.patch \
16 "
17
18SRC_URI:append:class-nativesdk = " \
19 file://environment.d-openssl.sh \
20 "
21
22SRC_URI[sha256sum] = "c311ad853353bce796edad01a862c50a8a587f62e7e2100ef465ab53ec9b06d1"
23
24inherit lib_package multilib_header multilib_script ptest perlnative
25MULTILIB_SCRIPTS = "${PN}-bin:${bindir}/c_rehash"
26
27PACKAGECONFIG ?= ""
28PACKAGECONFIG:class-native = ""
29PACKAGECONFIG:class-nativesdk = ""
30
31PACKAGECONFIG[cryptodev-linux] = "enable-devcryptoeng,disable-devcryptoeng,cryptodev-linux,,cryptodev-module"
32PACKAGECONFIG[no-tls1] = "no-tls1"
33PACKAGECONFIG[no-tls1_1] = "no-tls1_1"
34
35B = "${WORKDIR}/build"
36do_configure[cleandirs] = "${B}"
37
38#| ./libcrypto.so: undefined reference to `getcontext'
39#| ./libcrypto.so: undefined reference to `setcontext'
40#| ./libcrypto.so: undefined reference to `makecontext'
41EXTRA_OECONF:append:libc-musl = " no-async"
42EXTRA_OECONF:append:libc-musl:powerpc64 = " no-asm"
43
44# adding devrandom prevents openssl from using getrandom() which is not available on older glibc versions
45# (native versions can be built with newer glibc, but then relocated onto a system with older glibc)
46EXTRA_OECONF:class-native = "--with-rand-seed=os,devrandom"
47EXTRA_OECONF:class-nativesdk = "--with-rand-seed=os,devrandom"
48
49# Relying on hardcoded built-in paths causes openssl-native to not be relocateable from sstate.
50CFLAGS:append:class-native = " -DOPENSSLDIR=/not/builtin -DENGINESDIR=/not/builtin"
51CFLAGS:append:class-nativesdk = " -DOPENSSLDIR=/not/builtin -DENGINESDIR=/not/builtin"
52
53# This allows disabling deprecated or undesirable crypto algorithms.
54# The default is to trust upstream choices.
55DEPRECATED_CRYPTO_FLAGS ?= ""
56
57do_configure () {
58 os=${HOST_OS}
59 case $os in
60 linux-gnueabi |\
61 linux-gnuspe |\
62 linux-musleabi |\
63 linux-muslspe |\
64 linux-musl )
65 os=linux
66 ;;
67 *)
68 ;;
69 esac
70 target="$os-${HOST_ARCH}"
71 case $target in
72 linux-arc)
73 target=linux-latomic
74 ;;
75 linux-arm*)
76 target=linux-armv4
77 ;;
78 linux-aarch64*)
79 target=linux-aarch64
80 ;;
81 linux-i?86 | linux-viac3)
82 target=linux-x86
83 ;;
84 linux-gnux32-x86_64 | linux-muslx32-x86_64 )
85 target=linux-x32
86 ;;
87 linux-gnu64-x86_64)
88 target=linux-x86_64
89 ;;
90 linux-mips | linux-mipsel)
91 # specifying TARGET_CC_ARCH prevents openssl from (incorrectly) adding target architecture flags
92 target="linux-mips32 ${TARGET_CC_ARCH}"
93 ;;
94 linux-gnun32-mips*)
95 target=linux-mips64
96 ;;
97 linux-*-mips64 | linux-mips64 | linux-*-mips64el | linux-mips64el)
98 target=linux64-mips64
99 ;;
100 linux-microblaze* | linux-nios2* | linux-sh3 | linux-sh4 | linux-arc*)
101 target=linux-generic32
102 ;;
103 linux-powerpc)
104 target=linux-ppc
105 ;;
106 linux-powerpc64)
107 target=linux-ppc64
108 ;;
109 linux-powerpc64le)
110 target=linux-ppc64le
111 ;;
112 linux-riscv32)
113 target=linux-generic32
114 ;;
115 linux-riscv64)
116 target=linux-generic64
117 ;;
118 linux-sparc | linux-supersparc)
119 target=linux-sparcv9
120 ;;
121 mingw32-x86_64)
122 target=mingw64
123 ;;
124 esac
125
126 useprefix=${prefix}
127 if [ "x$useprefix" = "x" ]; then
128 useprefix=/
129 fi
130 # WARNING: do not set compiler/linker flags (-I/-D etc.) in EXTRA_OECONF, as they will fully replace the
131 # environment variables set by bitbake. Adjust the environment variables instead.
132 HASHBANGPERL="/usr/bin/env perl" PERL=perl PERL5LIB="${S}/external/perl/Text-Template-1.46/lib/" \
133 perl ${S}/Configure ${EXTRA_OECONF} ${PACKAGECONFIG_CONFARGS} ${DEPRECATED_CRYPTO_FLAGS} --prefix=$useprefix --openssldir=${libdir}/ssl-3 --libdir=${libdir} $target
134 perl ${B}/configdata.pm --dump
135}
136
137do_install () {
138 oe_runmake DESTDIR="${D}" MANDIR="${mandir}" MANSUFFIX=ssl install
139
140 oe_multilib_header openssl/opensslconf.h
141 oe_multilib_header openssl/configuration.h
142
143 # Create SSL structure for packages such as ca-certificates which
144 # contain hard-coded paths to /etc/ssl. Debian does the same.
145 install -d ${D}${sysconfdir}/ssl
146 mv ${D}${libdir}/ssl-3/certs \
147 ${D}${libdir}/ssl-3/private \
148 ${D}${libdir}/ssl-3/openssl.cnf \
149 ${D}${sysconfdir}/ssl/
150
151 # Although absolute symlinks would be OK for the target, they become
152 # invalid if native or nativesdk are relocated from sstate.
153 ln -sf ${@oe.path.relative('${libdir}/ssl-3', '${sysconfdir}/ssl/certs')} ${D}${libdir}/ssl-3/certs
154 ln -sf ${@oe.path.relative('${libdir}/ssl-3', '${sysconfdir}/ssl/private')} ${D}${libdir}/ssl-3/private
155 ln -sf ${@oe.path.relative('${libdir}/ssl-3', '${sysconfdir}/ssl/openssl.cnf')} ${D}${libdir}/ssl-3/openssl.cnf
156}
157
158do_install:append:class-native () {
159 create_wrapper ${D}${bindir}/openssl \
160 OPENSSL_CONF=${libdir}/ssl-3/openssl.cnf \
161 SSL_CERT_DIR=${libdir}/ssl-3/certs \
162 SSL_CERT_FILE=${libdir}/ssl-3/cert.pem \
163 OPENSSL_ENGINES=${libdir}/engines-3
164}
165
166do_install:append:class-nativesdk () {
167 mkdir -p ${D}${SDKPATHNATIVE}/environment-setup.d
168 install -m 644 ${WORKDIR}/environment.d-openssl.sh ${D}${SDKPATHNATIVE}/environment-setup.d/openssl.sh
169 sed 's|/usr/lib/ssl/|/usr/lib/ssl-3/|g' -i ${D}${SDKPATHNATIVE}/environment-setup.d/openssl.sh
170}
171
172PTEST_BUILD_HOST_FILES += "configdata.pm"
173PTEST_BUILD_HOST_PATTERN = "perl_version ="
174do_install_ptest () {
175 install -d ${D}${PTEST_PATH}/test
176 install -m755 ${B}/test/p_test.so ${D}${PTEST_PATH}/test
177 install -m755 ${B}/test/provider_internal_test.cnf ${D}${PTEST_PATH}/test
178
179 # Prune the build tree
180 rm -f ${B}/fuzz/*.* ${B}/test/*.*
181
182 cp ${S}/Configure ${B}/configdata.pm ${D}${PTEST_PATH}
183 sed 's|${S}|${PTEST_PATH}|g' -i ${D}${PTEST_PATH}/configdata.pm
184 cp -r ${S}/external ${B}/test ${S}/test ${B}/fuzz ${S}/util ${B}/util ${D}${PTEST_PATH}
185
186 # For test_shlibload
187 ln -s ${libdir}/libcrypto.so.1.1 ${D}${PTEST_PATH}/
188 ln -s ${libdir}/libssl.so.1.1 ${D}${PTEST_PATH}/
189
190 install -d ${D}${PTEST_PATH}/apps
191 ln -s ${bindir}/openssl ${D}${PTEST_PATH}/apps
192 install -m644 ${S}/apps/*.pem ${S}/apps/*.srl ${S}/apps/openssl.cnf ${D}${PTEST_PATH}/apps
193 install -m755 ${B}/apps/CA.pl ${D}${PTEST_PATH}/apps
194
195 install -d ${D}${PTEST_PATH}/engines
196 install -m755 ${B}/engines/dasync.so ${D}${PTEST_PATH}/engines
197 install -m755 ${B}/engines/loader_attic.so ${D}${PTEST_PATH}/engines
198 install -m755 ${B}/engines/ossltest.so ${D}${PTEST_PATH}/engines
199
200 install -d ${D}${PTEST_PATH}/providers
201 install -m755 ${B}/providers/legacy.so ${D}${PTEST_PATH}/providers
202
203 install -d ${D}${PTEST_PATH}/Configurations
204 cp -rf ${S}/Configurations/* ${D}${PTEST_PATH}/Configurations/
205
206 # seems to be needed with perl 5.32.1
207 install -d ${D}${PTEST_PATH}/util/perl/recipes
208 cp ${D}${PTEST_PATH}/test/recipes/tconversion.pl ${D}${PTEST_PATH}/util/perl/recipes/
209
210 sed 's|${S}|${PTEST_PATH}|g' -i ${D}${PTEST_PATH}/util/wrap.pl
211}
212
213# Add the openssl.cnf file to the openssl-conf package. Make the libcrypto
214# package RRECOMMENDS on this package. This will enable the configuration
215# file to be installed for both the openssl-bin package and the libcrypto
216# package since the openssl-bin package depends on the libcrypto package.
217
218PACKAGES =+ "libcrypto libssl openssl-conf ${PN}-engines ${PN}-misc"
219
220FILES:libcrypto = "${libdir}/libcrypto${SOLIBS}"
221FILES:libssl = "${libdir}/libssl${SOLIBS}"
222FILES:openssl-conf = "${sysconfdir}/ssl/openssl.cnf \
223 ${libdir}/ssl-3/openssl.cnf* \
224 "
225FILES:${PN}-engines = "${libdir}/engines-3"
226# ${prefix} comes from what we pass into --prefix at configure time (which is used for INSTALLTOP)
227FILES:${PN}-engines:append:mingw32:class-nativesdk = " ${prefix}${libdir}/engines-3"
228FILES:${PN}-misc = "${libdir}/ssl-3/misc ${bindir}/c_rehash"
229FILES:${PN} =+ "${libdir}/ssl-3/* ${libdir}/ossl-modules/"
230FILES:${PN}:append:class-nativesdk = " ${SDKPATHNATIVE}/environment-setup.d/openssl.sh"
231
232CONFFILES:openssl-conf = "${sysconfdir}/ssl/openssl.cnf"
233
234RRECOMMENDS:libcrypto += "openssl-conf"
235RDEPENDS:${PN}-misc = "perl"
236RDEPENDS:${PN}-ptest += "openssl-bin perl perl-modules bash sed"
237
238RDEPENDS:${PN}-bin += "openssl-conf"
239
240BBCLASSEXTEND = "native nativesdk"
241
242CVE_PRODUCT = "openssl:openssl"
243
244CVE_VERSION_SUFFIX = "alphabetical"
245
246# Only affects OpenSSL >= 1.1.1 in combination with Apache < 2.4.37
247# Apache in meta-webserver is already recent enough
248CVE_CHECK_WHITELIST += "CVE-2019-0190"