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