Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 1 | SUMMARY = "Secure Socket Layer" |
| 2 | DESCRIPTION = "Secure Socket Layer (SSL) binary and related cryptographic tools." |
| 3 | HOMEPAGE = "http://www.openssl.org/" |
| 4 | BUGTRACKER = "http://www.openssl.org/news/vulnerabilities.html" |
| 5 | SECTION = "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) |
| 9 | LICENSE = "openssl" |
| 10 | LIC_FILES_CHKSUM = "file://LICENSE;md5=d343e62fc9c833710bbbed25f27364c8" |
| 11 | |
| 12 | DEPENDS = "hostperl-runtime-native" |
| 13 | |
| 14 | SRC_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 | |
| 22 | SRC_URI_append_class-nativesdk = " \ |
| 23 | file://environment.d-openssl.sh \ |
| 24 | " |
| 25 | |
Andrew Geissler | 4b740dc | 2020-05-05 08:54:39 -0500 | [diff] [blame] | 26 | SRC_URI[sha256sum] = "ddb04774f1e32f0c49751e21b67216ac87852ceb056b75209af2443400636d46" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 27 | |
| 28 | inherit lib_package multilib_header multilib_script ptest |
| 29 | MULTILIB_SCRIPTS = "${PN}-bin:${bindir}/c_rehash" |
| 30 | |
| 31 | PACKAGECONFIG ?= "" |
| 32 | PACKAGECONFIG_class-native = "" |
| 33 | PACKAGECONFIG_class-nativesdk = "" |
| 34 | |
| 35 | PACKAGECONFIG[cryptodev-linux] = "enable-devcryptoeng,disable-devcryptoeng,cryptodev-linux,,cryptodev-module" |
| 36 | |
| 37 | B = "${WORKDIR}/build" |
| 38 | do_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' |
| 43 | EXTRA_OECONF_append_libc-musl = " no-async" |
| 44 | EXTRA_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) |
| 48 | EXTRA_OECONF_class-native = "--with-rand-seed=os,devrandom" |
| 49 | EXTRA_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. |
| 52 | CFLAGS_append_class-native = " -DOPENSSLDIR=/not/builtin -DENGINESDIR=/not/builtin" |
| 53 | CFLAGS_append_class-nativesdk = " -DOPENSSLDIR=/not/builtin -DENGINESDIR=/not/builtin" |
| 54 | |
| 55 | do_configure () { |
| 56 | os=${HOST_OS} |
| 57 | case $os in |
| 58 | linux-gnueabi |\ |
| 59 | linux-gnuspe |\ |
| 60 | linux-musleabi |\ |
| 61 | linux-muslspe |\ |
| 62 | linux-musl ) |
| 63 | os=linux |
| 64 | ;; |
| 65 | *) |
| 66 | ;; |
| 67 | esac |
| 68 | target="$os-${HOST_ARCH}" |
| 69 | case $target in |
| 70 | linux-arm*) |
| 71 | target=linux-armv4 |
| 72 | ;; |
| 73 | linux-aarch64*) |
| 74 | target=linux-aarch64 |
| 75 | ;; |
| 76 | linux-i?86 | linux-viac3) |
| 77 | target=linux-x86 |
| 78 | ;; |
| 79 | linux-gnux32-x86_64 | linux-muslx32-x86_64 ) |
| 80 | target=linux-x32 |
| 81 | ;; |
| 82 | linux-gnu64-x86_64) |
| 83 | target=linux-x86_64 |
| 84 | ;; |
| 85 | linux-mips | linux-mipsel) |
| 86 | # specifying TARGET_CC_ARCH prevents openssl from (incorrectly) adding target architecture flags |
| 87 | target="linux-mips32 ${TARGET_CC_ARCH}" |
| 88 | ;; |
| 89 | linux-gnun32-mips*) |
| 90 | target=linux-mips64 |
| 91 | ;; |
| 92 | linux-*-mips64 | linux-mips64 | linux-*-mips64el | linux-mips64el) |
| 93 | target=linux64-mips64 |
| 94 | ;; |
| 95 | linux-microblaze* | linux-nios2* | linux-sh3 | linux-sh4 | linux-arc*) |
| 96 | target=linux-generic32 |
| 97 | ;; |
| 98 | linux-powerpc) |
| 99 | target=linux-ppc |
| 100 | ;; |
| 101 | linux-powerpc64) |
| 102 | target=linux-ppc64 |
| 103 | ;; |
| 104 | linux-powerpc64le) |
| 105 | target=linux-ppc64le |
| 106 | ;; |
| 107 | linux-riscv32) |
| 108 | target=linux-generic32 |
| 109 | ;; |
| 110 | linux-riscv64) |
| 111 | target=linux-generic64 |
| 112 | ;; |
| 113 | linux-sparc | linux-supersparc) |
| 114 | target=linux-sparcv9 |
| 115 | ;; |
| 116 | esac |
| 117 | |
| 118 | useprefix=${prefix} |
| 119 | if [ "x$useprefix" = "x" ]; then |
| 120 | useprefix=/ |
| 121 | fi |
| 122 | # WARNING: do not set compiler/linker flags (-I/-D etc.) in EXTRA_OECONF, as they will fully replace the |
| 123 | # environment variables set by bitbake. Adjust the environment variables instead. |
| 124 | HASHBANGPERL="/usr/bin/env perl" PERL=perl PERL5LIB="${S}/external/perl/Text-Template-1.46/lib/" \ |
| 125 | perl ${S}/Configure ${EXTRA_OECONF} ${PACKAGECONFIG_CONFARGS} --prefix=$useprefix --openssldir=${libdir}/ssl-1.1 --libdir=${libdir} $target |
| 126 | perl ${B}/configdata.pm --dump |
| 127 | } |
| 128 | |
| 129 | do_install () { |
| 130 | oe_runmake DESTDIR="${D}" MANDIR="${mandir}" MANSUFFIX=ssl install |
| 131 | |
| 132 | oe_multilib_header openssl/opensslconf.h |
| 133 | |
| 134 | # Create SSL structure for packages such as ca-certificates which |
| 135 | # contain hard-coded paths to /etc/ssl. Debian does the same. |
| 136 | install -d ${D}${sysconfdir}/ssl |
| 137 | mv ${D}${libdir}/ssl-1.1/certs \ |
| 138 | ${D}${libdir}/ssl-1.1/private \ |
| 139 | ${D}${libdir}/ssl-1.1/openssl.cnf \ |
| 140 | ${D}${sysconfdir}/ssl/ |
| 141 | |
| 142 | # Although absolute symlinks would be OK for the target, they become |
| 143 | # invalid if native or nativesdk are relocated from sstate. |
| 144 | ln -sf ${@oe.path.relative('${libdir}/ssl-1.1', '${sysconfdir}/ssl/certs')} ${D}${libdir}/ssl-1.1/certs |
| 145 | ln -sf ${@oe.path.relative('${libdir}/ssl-1.1', '${sysconfdir}/ssl/private')} ${D}${libdir}/ssl-1.1/private |
| 146 | ln -sf ${@oe.path.relative('${libdir}/ssl-1.1', '${sysconfdir}/ssl/openssl.cnf')} ${D}${libdir}/ssl-1.1/openssl.cnf |
| 147 | } |
| 148 | |
| 149 | do_install_append_class-native () { |
| 150 | create_wrapper ${D}${bindir}/openssl \ |
| 151 | OPENSSL_CONF=${libdir}/ssl-1.1/openssl.cnf \ |
| 152 | SSL_CERT_DIR=${libdir}/ssl-1.1/certs \ |
| 153 | SSL_CERT_FILE=${libdir}/ssl-1.1/cert.pem \ |
| 154 | OPENSSL_ENGINES=${libdir}/engines-1.1 |
| 155 | } |
| 156 | |
| 157 | do_install_append_class-nativesdk () { |
| 158 | mkdir -p ${D}${SDKPATHNATIVE}/environment-setup.d |
| 159 | install -m 644 ${WORKDIR}/environment.d-openssl.sh ${D}${SDKPATHNATIVE}/environment-setup.d/openssl.sh |
| 160 | sed 's|/usr/lib/ssl/|/usr/lib/ssl-1.1/|g' -i ${D}${SDKPATHNATIVE}/environment-setup.d/openssl.sh |
| 161 | } |
| 162 | |
| 163 | PTEST_BUILD_HOST_FILES += "configdata.pm" |
| 164 | PTEST_BUILD_HOST_PATTERN = "perl_version =" |
| 165 | do_install_ptest () { |
| 166 | # Prune the build tree |
| 167 | rm -f ${B}/fuzz/*.* ${B}/test/*.* |
| 168 | |
| 169 | cp ${S}/Configure ${B}/configdata.pm ${D}${PTEST_PATH} |
| 170 | cp -r ${S}/external ${B}/test ${S}/test ${B}/fuzz ${S}/util ${B}/util ${D}${PTEST_PATH} |
| 171 | |
| 172 | # For test_shlibload |
| 173 | ln -s ${libdir}/libcrypto.so.1.1 ${D}${PTEST_PATH}/ |
| 174 | ln -s ${libdir}/libssl.so.1.1 ${D}${PTEST_PATH}/ |
| 175 | |
| 176 | install -d ${D}${PTEST_PATH}/apps |
| 177 | ln -s ${bindir}/openssl ${D}${PTEST_PATH}/apps |
| 178 | install -m644 ${S}/apps/*.pem ${S}/apps/*.srl ${S}/apps/openssl.cnf ${D}${PTEST_PATH}/apps |
| 179 | install -m755 ${B}/apps/CA.pl ${D}${PTEST_PATH}/apps |
| 180 | |
| 181 | install -d ${D}${PTEST_PATH}/engines |
| 182 | install -m755 ${B}/engines/ossltest.so ${D}${PTEST_PATH}/engines |
| 183 | } |
| 184 | |
| 185 | # Add the openssl.cnf file to the openssl-conf package. Make the libcrypto |
| 186 | # package RRECOMMENDS on this package. This will enable the configuration |
| 187 | # file to be installed for both the openssl-bin package and the libcrypto |
| 188 | # package since the openssl-bin package depends on the libcrypto package. |
| 189 | |
| 190 | PACKAGES =+ "libcrypto libssl openssl-conf ${PN}-engines ${PN}-misc" |
| 191 | |
| 192 | FILES_libcrypto = "${libdir}/libcrypto${SOLIBS}" |
| 193 | FILES_libssl = "${libdir}/libssl${SOLIBS}" |
| 194 | FILES_openssl-conf = "${sysconfdir}/ssl/openssl.cnf" |
| 195 | FILES_${PN}-engines = "${libdir}/engines-1.1" |
| 196 | FILES_${PN}-misc = "${libdir}/ssl-1.1/misc" |
| 197 | FILES_${PN} =+ "${libdir}/ssl-1.1/*" |
| 198 | FILES_${PN}_append_class-nativesdk = " ${SDKPATHNATIVE}/environment-setup.d/openssl.sh" |
| 199 | |
| 200 | CONFFILES_openssl-conf = "${sysconfdir}/ssl/openssl.cnf" |
| 201 | |
| 202 | RRECOMMENDS_libcrypto += "openssl-conf" |
| 203 | RDEPENDS_${PN}-ptest += "openssl-bin perl perl-modules bash" |
| 204 | |
| 205 | BBCLASSEXTEND = "native nativesdk" |
| 206 | |
| 207 | CVE_PRODUCT = "openssl:openssl" |
| 208 | |
| 209 | # Only affects OpenSSL >= 1.1.1 in combination with Apache < 2.4.37 |
| 210 | # Apache in meta-webserver is already recent enough |
| 211 | CVE_CHECK_WHITELIST += "CVE-2019-0190" |