在 ARM 设备上运行 ntp-keygen(或 ntpd)时收到的错误消息是:
./ntp-keygen: relocation error: ./ntp-keygen: symbol DSA_generate_parameters_ex, version OPENSSL_1_1_0 not defined in file libcrypto.so.1.1 with link time reference
配置、构建和安装 OpenSSL 的脚本如下:
#!/bin/bash
# Build dependencies if any.
depends()
{
cd $buildDir
if [ "x${PERL}" = "x" ]; then
export PERL=`which perl`
fi
return $?
}
# Configure software package.
configure()
{
depends
cd $packageDir
# Available ciphers:
# DES, AES, CAMELLIA, MD2, MDC2, MD4, MD5, HMAC, SHA, RIPEMD, WHIRLPOOL,
# RC4, RC5, RC2, IDEA, SEED, BF(blowfish), CAST, RSA, DSA, ECDSA, ECDH
# We use:
# DES, AES, MD4, MD5, HMAC, SHA, RSA, ECDSA, ECDH
./Configure shared threads --prefix=$PWD/install-arm linux-armv4
return $?
}
# Build the software package.
compile()
{
local mmx_machine_type=`echo $MMX_MACHINE_TYPE | tr '[:upper:]' '[:lower:]'`
depends
cd $packageDir
export CFLAGS="$CFLAGS -DCONFIG_MACHINE_${MMX_MACHINE_TYPE}"
configure
if [ "$?" -ne "0" ]; then return 1; fi
make CC=$CC AR=$AR NM=$NM RANLIB=$RANLIB
if [ "$?" -ne "0" ]; then return 1; fi
make CC=$CC AR=$AR NM=$NM RANLIB=$RANLIB install
if [ "$?" -ne "0" ]; then return 1; fi
return 0
}
# Clean-up.
clean()
{
depends
cd $packageDir
rm -rf install-arm/*
rm -rf install-i386/*
make clean
}
# Install to rootfs the necessary pieces (e.g. directories, links...)
install()
{
targetPath=${buildDir}/.tmp.rootfs/rootfs
local openssl="bin/openssl"
local libssl="lib/libssl.so.1.1"
local libcrypto="lib/libcrypto.so.1.1"
cd ${packageDir}/install-arm
if [ -f ${openssl} -a -f ${libssl} -a -f ${libcrypto} ]
then
cp ${openssl} ${targetPath}/sbin/
cp ${libssl} ${targetPath}/lib/
cp ${libcrypto} ${targetPath}/lib/
else
printf " $package not built.\n"
fi
return 0
}
对于 ntp 包,对 OpenSSL 的唯一引用是在配置选项中。以下是完整的 ntp 包配置:
#!/bin/sh
# Configure software package.
configure()
{
cd $packageDir
./bootstrap
./configure --host=arm-linux --with-yielding-select=yes --with-crypto=openssl \
--with-openssl-incdir=$OPENSSL_DIR/install-arm/include/ \
--with-openssl-libdir=$OPENSSL_DIR/install-arm/lib/ \
return $?
}
# Build the software package.
compile()
{
cd $packageDir
# make PROJECT_NAME=$project
make
if [ "$?" -ne "0" ]; then return 1; fi
return 0
}
# Clean-up.
clean()
{
cd $packageDir
make clean
}
# Install to rootfs the necessary pieces (e.g. directories, links...)
install()
{
cd $packageDir
sourcePath=.
targetPath=$buildDir/.tmp.rootfs/rootfs
if [[ -f $sourcePath/ntpclient ]]; then
cp $sourcePath/$package $targetPath/sbin/
else
printf " $package not built.\n"
return 1
fi
return 0
}
答案1
根据您收到的错误消息,ntp-keygen 命令似乎正在尝试使用 OpenSSL 库中名为 DSA_generate_parameters_ex 的函数,但您安装的库版本中未定义此函数。这可能是因为您使用的是不包含此功能的旧版本 OpenSSL,或者因为该库链接到 ntp-keygen 的方式存在问题。
要修复此错误,您可以尝试更新到包含 DSA_generate_parameters_ex 函数的 OpenSSL 较新版本,或者您可以尝试重新构建 OpenSSL 库和 ntp-keygen 以确保它们正确链接。您还可以尝试使用 ldd 命令检查 ntp-keygen 二进制文件的依赖关系,并确保它链接到正确版本的 OpenSSL 库。