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