1SUMMARY = "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 \ 14 file://0001-Added-handshake-history-reporting-when-test-fails.patch \ 15 " 16 17SRC_URI:append:class-nativesdk = " \ 18 file://environment.d-openssl.sh \ 19 " 20 21SRC_URI[sha256sum] = "83c7329fe52c850677d75e5d0b0ca245309b97e8ecbcfdc1dfdc4ab9fac35b39" 22 23inherit lib_package multilib_header multilib_script ptest perlnative manpages 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" 33PACKAGECONFIG[manpages] = "" 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 # When we upgrade glibc but not uninative we see obtuse failures in openssl. Make 59 # the issue really clear that perl isn't functional due to symbol mismatch issues. 60 cat <<- EOF > ${WORKDIR}/perltest 61 #!/usr/bin/env perl 62 use POSIX; 63 EOF 64 chmod a+x ${WORKDIR}/perltest 65 ${WORKDIR}/perltest 66 67 os=${HOST_OS} 68 case $os in 69 linux-gnueabi |\ 70 linux-gnuspe |\ 71 linux-musleabi |\ 72 linux-muslspe |\ 73 linux-musl ) 74 os=linux 75 ;; 76 *) 77 ;; 78 esac 79 target="$os-${HOST_ARCH}" 80 case $target in 81 linux-arc | linux-microblaze*) 82 target=linux-latomic 83 ;; 84 linux-arm*) 85 target=linux-armv4 86 ;; 87 linux-aarch64*) 88 target=linux-aarch64 89 ;; 90 linux-i?86 | linux-viac3) 91 target=linux-x86 92 ;; 93 linux-gnux32-x86_64 | linux-muslx32-x86_64 ) 94 target=linux-x32 95 ;; 96 linux-gnu64-x86_64) 97 target=linux-x86_64 98 ;; 99 linux-loongarch64) 100 target=linux64-loongarch64 101 ;; 102 linux-mips | linux-mipsel) 103 # specifying TARGET_CC_ARCH prevents openssl from (incorrectly) adding target architecture flags 104 target="linux-mips32 ${TARGET_CC_ARCH}" 105 ;; 106 linux-gnun32-mips*) 107 target=linux-mips64 108 ;; 109 linux-*-mips64 | linux-mips64 | linux-*-mips64el | linux-mips64el) 110 target=linux64-mips64 111 ;; 112 linux-nios2* | linux-sh3 | linux-sh4 | linux-arc*) 113 target=linux-generic32 114 ;; 115 linux-powerpc) 116 target=linux-ppc 117 ;; 118 linux-powerpc64) 119 target=linux-ppc64 120 ;; 121 linux-powerpc64le) 122 target=linux-ppc64le 123 ;; 124 linux-riscv32) 125 target=linux32-riscv32 126 ;; 127 linux-riscv64) 128 target=linux64-riscv64 129 ;; 130 linux-sparc | linux-supersparc) 131 target=linux-sparcv9 132 ;; 133 mingw32-x86_64) 134 target=mingw64 135 ;; 136 esac 137 138 useprefix=${prefix} 139 if [ "x$useprefix" = "x" ]; then 140 useprefix=/ 141 fi 142 # WARNING: do not set compiler/linker flags (-I/-D etc.) in EXTRA_OECONF, as they will fully replace the 143 # environment variables set by bitbake. Adjust the environment variables instead. 144 PERLEXTERNAL="$(realpath ${S}/external/perl/Text-Template-*/lib)" 145 test -d "$PERLEXTERNAL" || bberror "PERLEXTERNAL '$PERLEXTERNAL' not found!" 146 HASHBANGPERL="/usr/bin/env perl" PERL=perl PERL5LIB="$PERLEXTERNAL" \ 147 perl ${S}/Configure ${EXTRA_OECONF} ${PACKAGECONFIG_CONFARGS} ${DEPRECATED_CRYPTO_FLAGS} --prefix=$useprefix --openssldir=${libdir}/ssl-3 --libdir=${libdir} $target 148 perl ${B}/configdata.pm --dump 149} 150 151do_install () { 152 oe_runmake DESTDIR="${D}" MANDIR="${mandir}" MANSUFFIX=ssl install_sw install_ssldirs ${@bb.utils.contains('PACKAGECONFIG', 'manpages', 'install_docs', '', d)} 153 154 oe_multilib_header openssl/opensslconf.h 155 oe_multilib_header openssl/configuration.h 156 157 # Create SSL structure for packages such as ca-certificates which 158 # contain hard-coded paths to /etc/ssl. Debian does the same. 159 install -d ${D}${sysconfdir}/ssl 160 mv ${D}${libdir}/ssl-3/certs \ 161 ${D}${libdir}/ssl-3/private \ 162 ${D}${libdir}/ssl-3/openssl.cnf \ 163 ${D}${sysconfdir}/ssl/ 164 165 # Although absolute symlinks would be OK for the target, they become 166 # invalid if native or nativesdk are relocated from sstate. 167 ln -sf ${@oe.path.relative('${libdir}/ssl-3', '${sysconfdir}/ssl/certs')} ${D}${libdir}/ssl-3/certs 168 ln -sf ${@oe.path.relative('${libdir}/ssl-3', '${sysconfdir}/ssl/private')} ${D}${libdir}/ssl-3/private 169 ln -sf ${@oe.path.relative('${libdir}/ssl-3', '${sysconfdir}/ssl/openssl.cnf')} ${D}${libdir}/ssl-3/openssl.cnf 170} 171 172do_install:append:class-native () { 173 create_wrapper ${D}${bindir}/openssl \ 174 OPENSSL_CONF=${libdir}/ssl-3/openssl.cnf \ 175 SSL_CERT_DIR=${libdir}/ssl-3/certs \ 176 SSL_CERT_FILE=${libdir}/ssl-3/cert.pem \ 177 OPENSSL_ENGINES=${libdir}/engines-3 \ 178 OPENSSL_MODULES=${libdir}/ossl-modules 179} 180 181do_install:append:class-nativesdk () { 182 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-3/|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 install -d ${D}${PTEST_PATH}/test 191 install -m755 ${B}/test/p_test.so ${D}${PTEST_PATH}/test 192 install -m755 ${B}/test/p_minimal.so ${D}${PTEST_PATH}/test 193 install -m755 ${B}/test/provider_internal_test.cnf ${D}${PTEST_PATH}/test 194 195 # Prune the build tree 196 rm -f ${B}/fuzz/*.* ${B}/test/*.* 197 198 cp ${S}/Configure ${B}/configdata.pm ${D}${PTEST_PATH} 199 sed 's|${S}|${PTEST_PATH}|g' -i ${D}${PTEST_PATH}/configdata.pm 200 cp -r ${S}/external ${B}/test ${S}/test ${B}/fuzz ${S}/util ${B}/util ${D}${PTEST_PATH} 201 202 # For test_shlibload 203 ln -s ${libdir}/libcrypto.so.1.1 ${D}${PTEST_PATH}/ 204 ln -s ${libdir}/libssl.so.1.1 ${D}${PTEST_PATH}/ 205 206 install -d ${D}${PTEST_PATH}/apps 207 ln -s ${bindir}/openssl ${D}${PTEST_PATH}/apps 208 install -m644 ${S}/apps/*.pem ${S}/apps/*.srl ${S}/apps/openssl.cnf ${D}${PTEST_PATH}/apps 209 install -m755 ${B}/apps/CA.pl ${D}${PTEST_PATH}/apps 210 211 install -d ${D}${PTEST_PATH}/engines 212 install -m755 ${B}/engines/dasync.so ${D}${PTEST_PATH}/engines 213 install -m755 ${B}/engines/loader_attic.so ${D}${PTEST_PATH}/engines 214 install -m755 ${B}/engines/ossltest.so ${D}${PTEST_PATH}/engines 215 216 install -d ${D}${PTEST_PATH}/providers 217 install -m755 ${B}/providers/legacy.so ${D}${PTEST_PATH}/providers 218 219 install -d ${D}${PTEST_PATH}/Configurations 220 cp -rf ${S}/Configurations/* ${D}${PTEST_PATH}/Configurations/ 221 222 # seems to be needed with perl 5.32.1 223 install -d ${D}${PTEST_PATH}/util/perl/recipes 224 cp ${D}${PTEST_PATH}/test/recipes/tconversion.pl ${D}${PTEST_PATH}/util/perl/recipes/ 225 226 sed 's|${S}|${PTEST_PATH}|g' -i ${D}${PTEST_PATH}/util/wrap.pl 227} 228 229# Add the openssl.cnf file to the openssl-conf package. Make the libcrypto 230# package RRECOMMENDS on this package. This will enable the configuration 231# file to be installed for both the openssl-bin package and the libcrypto 232# package since the openssl-bin package depends on the libcrypto package. 233 234PACKAGES =+ "libcrypto libssl openssl-conf ${PN}-engines ${PN}-misc ${PN}-ossl-module-legacy" 235 236FILES:libcrypto = "${libdir}/libcrypto${SOLIBS}" 237FILES:libssl = "${libdir}/libssl${SOLIBS}" 238FILES:openssl-conf = "${sysconfdir}/ssl/openssl.cnf \ 239 ${libdir}/ssl-3/openssl.cnf* \ 240 " 241FILES:${PN}-engines = "${libdir}/engines-3" 242# ${prefix} comes from what we pass into --prefix at configure time (which is used for INSTALLTOP) 243FILES:${PN}-engines:append:mingw32:class-nativesdk = " ${prefix}${libdir}/engines-3" 244FILES:${PN}-misc = "${libdir}/ssl-3/misc ${bindir}/c_rehash" 245FILES:${PN}-ossl-module-legacy = "${libdir}/ossl-modules/legacy.so" 246FILES:${PN} =+ "${libdir}/ssl-3/* ${libdir}/ossl-modules/" 247FILES:${PN}:append:class-nativesdk = " ${SDKPATHNATIVE}/environment-setup.d/openssl.sh" 248 249CONFFILES:openssl-conf = "${sysconfdir}/ssl/openssl.cnf" 250 251RRECOMMENDS:libcrypto += "openssl-conf ${PN}-ossl-module-legacy" 252RDEPENDS:${PN}-misc = "perl" 253RDEPENDS:${PN}-ptest += "openssl-bin perl perl-modules bash sed" 254 255RDEPENDS:${PN}-bin += "openssl-conf" 256 257BBCLASSEXTEND = "native nativesdk" 258 259CVE_PRODUCT = "openssl:openssl" 260 261CVE_VERSION_SUFFIX = "alphabetical" 262 263