blob: b241ba78bcc2714d9144443ae20cda1128139f5b [file] [log] [blame]
Andrew Geissler82c905d2020-04-13 13:39:40 -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
7# "openssl" here actually means both OpenSSL and SSLeay licenses apply
8# (see meta/files/common-licenses/OpenSSL to which "openssl" is SPDXLICENSEMAPped)
9LICENSE = "openssl"
10LIC_FILES_CHKSUM = "file://LICENSE;md5=d343e62fc9c833710bbbed25f27364c8"
11
12DEPENDS = "hostperl-runtime-native"
13
14SRC_URI = "http://www.openssl.org/source/openssl-${PV}.tar.gz \
15 file://run-ptest \
16 file://0001-skip-test_symbol_presence.patch \
17 file://0001-buildinfo-strip-sysroot-and-debug-prefix-map-from-co.patch \
18 file://afalg.patch \
19 file://reproducible.patch \
20 "
21
Patrick Williams213cb262021-08-07 19:21:33 -050022SRC_URI:append:class-nativesdk = " \
Andrew Geissler82c905d2020-04-13 13:39:40 -050023 file://environment.d-openssl.sh \
24 "
25
Patrick Williams213cb262021-08-07 19:21:33 -050026SRC_URI:append:riscv32 = " \
Andrew Geissler95ac1b82021-03-31 14:34:31 -050027 file://0003-Add-support-for-io_pgetevents_time64-syscall.patch \
28 file://0004-Fixup-support-for-io_pgetevents_time64-syscall.patch \
29 "
30
Andrew Geisslerd159c7f2021-09-02 21:05:58 -050031SRC_URI[sha256sum] = "0b7a3e5e59c34827fe0c3a74b7ec8baef302b98fa80088d7f9153aa16fa76bd1"
Andrew Geissler82c905d2020-04-13 13:39:40 -050032
33inherit lib_package multilib_header multilib_script ptest
34MULTILIB_SCRIPTS = "${PN}-bin:${bindir}/c_rehash"
35
36PACKAGECONFIG ?= ""
Patrick Williams213cb262021-08-07 19:21:33 -050037PACKAGECONFIG:class-native = ""
38PACKAGECONFIG:class-nativesdk = ""
Andrew Geissler82c905d2020-04-13 13:39:40 -050039
40PACKAGECONFIG[cryptodev-linux] = "enable-devcryptoeng,disable-devcryptoeng,cryptodev-linux,,cryptodev-module"
Andrew Geisslerd1e89492021-02-12 15:35:20 -060041PACKAGECONFIG[no-tls1] = "no-tls1"
42PACKAGECONFIG[no-tls1_1] = "no-tls1_1"
Andrew Geissler82c905d2020-04-13 13:39:40 -050043
44B = "${WORKDIR}/build"
45do_configure[cleandirs] = "${B}"
46
47#| ./libcrypto.so: undefined reference to `getcontext'
48#| ./libcrypto.so: undefined reference to `setcontext'
49#| ./libcrypto.so: undefined reference to `makecontext'
Patrick Williams213cb262021-08-07 19:21:33 -050050EXTRA_OECONF:append:libc-musl = " no-async"
51EXTRA_OECONF:append:libc-musl:powerpc64 = " no-asm"
Andrew Geissler82c905d2020-04-13 13:39:40 -050052
53# adding devrandom prevents openssl from using getrandom() which is not available on older glibc versions
54# (native versions can be built with newer glibc, but then relocated onto a system with older glibc)
Patrick Williams213cb262021-08-07 19:21:33 -050055EXTRA_OECONF:class-native = "--with-rand-seed=os,devrandom"
56EXTRA_OECONF:class-nativesdk = "--with-rand-seed=os,devrandom"
Andrew Geissler82c905d2020-04-13 13:39:40 -050057
58# Relying on hardcoded built-in paths causes openssl-native to not be relocateable from sstate.
Patrick Williams213cb262021-08-07 19:21:33 -050059CFLAGS:append:class-native = " -DOPENSSLDIR=/not/builtin -DENGINESDIR=/not/builtin"
60CFLAGS:append:class-nativesdk = " -DOPENSSLDIR=/not/builtin -DENGINESDIR=/not/builtin"
Andrew Geissler82c905d2020-04-13 13:39:40 -050061
Andrew Geisslerd1e89492021-02-12 15:35:20 -060062# Disable deprecated crypto algorithms
63# Retained for compatibilty
64# des (curl)
65# dh (python-ssl)
66# dsa (rpm)
67# md4 (cyrus-sasl freeradius hostapd)
68# bf (wvstreams postgresql x11vnc crda znc cfengine)
69# rc4 (freerdp librtorrent ettercap xrdp transmission pam-ssh-agent-auth php)
70# rc2 (mailx)
71# psk (qt5)
72# srp (libest)
73# whirlpool (qca)
74DEPRECATED_CRYPTO_FLAGS = "no-ssl no-idea no-rc5 no-md2 no-camellia no-mdc2 no-scrypt no-seed no-siphash no-sm2 no-sm3 no-sm4"
75
Andrew Geissler82c905d2020-04-13 13:39:40 -050076do_configure () {
77 os=${HOST_OS}
78 case $os in
79 linux-gnueabi |\
80 linux-gnuspe |\
81 linux-musleabi |\
82 linux-muslspe |\
83 linux-musl )
84 os=linux
85 ;;
86 *)
87 ;;
88 esac
89 target="$os-${HOST_ARCH}"
90 case $target in
91 linux-arm*)
92 target=linux-armv4
93 ;;
94 linux-aarch64*)
95 target=linux-aarch64
96 ;;
97 linux-i?86 | linux-viac3)
98 target=linux-x86
99 ;;
100 linux-gnux32-x86_64 | linux-muslx32-x86_64 )
101 target=linux-x32
102 ;;
103 linux-gnu64-x86_64)
104 target=linux-x86_64
105 ;;
106 linux-mips | linux-mipsel)
107 # specifying TARGET_CC_ARCH prevents openssl from (incorrectly) adding target architecture flags
108 target="linux-mips32 ${TARGET_CC_ARCH}"
109 ;;
110 linux-gnun32-mips*)
111 target=linux-mips64
112 ;;
113 linux-*-mips64 | linux-mips64 | linux-*-mips64el | linux-mips64el)
114 target=linux64-mips64
115 ;;
116 linux-microblaze* | linux-nios2* | linux-sh3 | linux-sh4 | linux-arc*)
117 target=linux-generic32
118 ;;
119 linux-powerpc)
120 target=linux-ppc
121 ;;
122 linux-powerpc64)
123 target=linux-ppc64
124 ;;
125 linux-powerpc64le)
126 target=linux-ppc64le
127 ;;
128 linux-riscv32)
129 target=linux-generic32
130 ;;
131 linux-riscv64)
132 target=linux-generic64
133 ;;
134 linux-sparc | linux-supersparc)
135 target=linux-sparcv9
136 ;;
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600137 mingw32-x86_64)
138 target=mingw64
139 ;;
Andrew Geissler82c905d2020-04-13 13:39:40 -0500140 esac
141
142 useprefix=${prefix}
143 if [ "x$useprefix" = "x" ]; then
144 useprefix=/
145 fi
146 # WARNING: do not set compiler/linker flags (-I/-D etc.) in EXTRA_OECONF, as they will fully replace the
147 # environment variables set by bitbake. Adjust the environment variables instead.
148 HASHBANGPERL="/usr/bin/env perl" PERL=perl PERL5LIB="${S}/external/perl/Text-Template-1.46/lib/" \
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600149 perl ${S}/Configure ${EXTRA_OECONF} ${PACKAGECONFIG_CONFARGS} ${DEPRECATED_CRYPTO_FLAGS} --prefix=$useprefix --openssldir=${libdir}/ssl-1.1 --libdir=${libdir} $target
Andrew Geissler82c905d2020-04-13 13:39:40 -0500150 perl ${B}/configdata.pm --dump
151}
152
153do_install () {
154 oe_runmake DESTDIR="${D}" MANDIR="${mandir}" MANSUFFIX=ssl install
155
156 oe_multilib_header openssl/opensslconf.h
157
158 # Create SSL structure for packages such as ca-certificates which
159 # contain hard-coded paths to /etc/ssl. Debian does the same.
160 install -d ${D}${sysconfdir}/ssl
161 mv ${D}${libdir}/ssl-1.1/certs \
162 ${D}${libdir}/ssl-1.1/private \
163 ${D}${libdir}/ssl-1.1/openssl.cnf \
164 ${D}${sysconfdir}/ssl/
165
166 # Although absolute symlinks would be OK for the target, they become
167 # invalid if native or nativesdk are relocated from sstate.
168 ln -sf ${@oe.path.relative('${libdir}/ssl-1.1', '${sysconfdir}/ssl/certs')} ${D}${libdir}/ssl-1.1/certs
169 ln -sf ${@oe.path.relative('${libdir}/ssl-1.1', '${sysconfdir}/ssl/private')} ${D}${libdir}/ssl-1.1/private
170 ln -sf ${@oe.path.relative('${libdir}/ssl-1.1', '${sysconfdir}/ssl/openssl.cnf')} ${D}${libdir}/ssl-1.1/openssl.cnf
171}
172
Patrick Williams213cb262021-08-07 19:21:33 -0500173do_install:append:class-native () {
Andrew Geissler82c905d2020-04-13 13:39:40 -0500174 create_wrapper ${D}${bindir}/openssl \
175 OPENSSL_CONF=${libdir}/ssl-1.1/openssl.cnf \
176 SSL_CERT_DIR=${libdir}/ssl-1.1/certs \
177 SSL_CERT_FILE=${libdir}/ssl-1.1/cert.pem \
178 OPENSSL_ENGINES=${libdir}/engines-1.1
179}
180
Patrick Williams213cb262021-08-07 19:21:33 -0500181do_install:append:class-nativesdk () {
Andrew Geissler82c905d2020-04-13 13:39:40 -0500182 mkdir -p ${D}${SDKPATHNATIVE}/environment-setup.d
183 install -m 644 ${WORKDIR}/environment.d-openssl.sh ${D}${SDKPATHNATIVE}/environment-setup.d/openssl.sh
184 sed 's|/usr/lib/ssl/|/usr/lib/ssl-1.1/|g' -i ${D}${SDKPATHNATIVE}/environment-setup.d/openssl.sh
185}
186
187PTEST_BUILD_HOST_FILES += "configdata.pm"
188PTEST_BUILD_HOST_PATTERN = "perl_version ="
189do_install_ptest () {
190 # Prune the build tree
191 rm -f ${B}/fuzz/*.* ${B}/test/*.*
192
193 cp ${S}/Configure ${B}/configdata.pm ${D}${PTEST_PATH}
194 cp -r ${S}/external ${B}/test ${S}/test ${B}/fuzz ${S}/util ${B}/util ${D}${PTEST_PATH}
195
196 # For test_shlibload
197 ln -s ${libdir}/libcrypto.so.1.1 ${D}${PTEST_PATH}/
198 ln -s ${libdir}/libssl.so.1.1 ${D}${PTEST_PATH}/
199
200 install -d ${D}${PTEST_PATH}/apps
201 ln -s ${bindir}/openssl ${D}${PTEST_PATH}/apps
202 install -m644 ${S}/apps/*.pem ${S}/apps/*.srl ${S}/apps/openssl.cnf ${D}${PTEST_PATH}/apps
203 install -m755 ${B}/apps/CA.pl ${D}${PTEST_PATH}/apps
204
205 install -d ${D}${PTEST_PATH}/engines
206 install -m755 ${B}/engines/ossltest.so ${D}${PTEST_PATH}/engines
Andrew Geissler90fd73c2021-03-05 15:25:55 -0600207
208 # seems to be needed with perl 5.32.1
209 install -d ${D}${PTEST_PATH}/util/perl/recipes
210 cp ${D}${PTEST_PATH}/test/recipes/tconversion.pl ${D}${PTEST_PATH}/util/perl/recipes/
Andrew Geissler82c905d2020-04-13 13:39:40 -0500211}
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
Patrick Williams213cb262021-08-07 19:21:33 -0500220FILES:libcrypto = "${libdir}/libcrypto${SOLIBS}"
221FILES:libssl = "${libdir}/libssl${SOLIBS}"
222FILES:openssl-conf = "${sysconfdir}/ssl/openssl.cnf \
Andrew Geissler475cb722020-07-10 16:00:51 -0500223 ${libdir}/ssl-1.1/openssl.cnf* \
224 "
Patrick Williams213cb262021-08-07 19:21:33 -0500225FILES:${PN}-engines = "${libdir}/engines-1.1"
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600226# ${prefix} comes from what we pass into --prefix at configure time (which is used for INSTALLTOP)
Patrick Williams213cb262021-08-07 19:21:33 -0500227FILES:${PN}-engines:append:mingw32:class-nativesdk = " ${prefix}${libdir}/engines-1_1"
228FILES:${PN}-misc = "${libdir}/ssl-1.1/misc ${bindir}/c_rehash"
229FILES:${PN} =+ "${libdir}/ssl-1.1/*"
230FILES:${PN}:append:class-nativesdk = " ${SDKPATHNATIVE}/environment-setup.d/openssl.sh"
Andrew Geissler82c905d2020-04-13 13:39:40 -0500231
Patrick Williams213cb262021-08-07 19:21:33 -0500232CONFFILES:openssl-conf = "${sysconfdir}/ssl/openssl.cnf"
Andrew Geissler82c905d2020-04-13 13:39:40 -0500233
Patrick Williams213cb262021-08-07 19:21:33 -0500234RRECOMMENDS:libcrypto += "openssl-conf"
235RDEPENDS:${PN}-misc = "perl"
236RDEPENDS:${PN}-ptest += "openssl-bin perl perl-modules bash"
Andrew Geissler82c905d2020-04-13 13:39:40 -0500237
Patrick Williams213cb262021-08-07 19:21:33 -0500238RDEPENDS:${PN}-bin += "openssl-conf"
Andrew Geisslerb7d28612020-07-24 16:15:54 -0500239
Andrew Geissler82c905d2020-04-13 13:39:40 -0500240BBCLASSEXTEND = "native nativesdk"
241
242CVE_PRODUCT = "openssl:openssl"
243
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600244CVE_VERSION_SUFFIX = "alphabetical"
245
Andrew Geissler82c905d2020-04-13 13:39:40 -0500246# 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"