怎样编译安装GnuTLS

2020年10月29日 | 分类: 【技术】

参考:https://amon.org/gnutls-old

编译安装 gmp-6.2.0 :

下载:ftp://ftp.gmplib.org/pub/

wget https://gmplib.org/download/gmp/gmp-6.2.0.tar.xz && xz -d gmp-6.2.0.tar.xz && tar -xvf gmp-6.2.0.tar && cd gmp-6.2.0 && ./configure && make && make check && make install
export GMP_CFLAGS="-I/usr/local/include" GMP_LIBS="-L/usr/local/lib -lgmp"

编译安装 nettle-3.6 :

参考:https://amon.org/nettle
参考:http://linuxfromscratch.org/blfs/view/svn/postlfs/nettle.html

wget https://ftp.gnu.org/gnu/nettle/nettle-3.6.tar.gz && tar -xzvf nettle-3.6.tar.gz && cd nettle-3.6
./configure --prefix=/usr --enable-static --enable-mini-gmp
make && make install
chmod -v 755 /usr/lib64/lib{hogweed,nettle}.so && install -v -m755 -d /usr/share/doc/nettle-3.6 && install -v -m644 nettle.html /usr/share/doc/nettle-3.6 

查看版本:

nettle-hash --version

输出:

nettle-hash (nettle 3.6)

如果没有安装,configure gnutls 时将报错:

checking for nettle_get_secp_192r1 in -lhogweed... no
checking for nettle_rsa_sec_decrypt... no
configure: error: Nettle lacks the required rsa_sec_decrypt function

改为使用gnutls-3.5.9 没有此config要求;

基于后续在“gnutls-3.5.9”中遇到的问题点解决,间接理清了以上问题原因:以上问题原因是其调用了OS中发现在/usr/lib/x86_64-linux-gnu 中比较旧版本的 GMP 库,把其修改名字后就能识别到新安装到/usr/lib/ 的新版本

参考:https://blog.csdn.net/sui1005316018/article/details/89133036
参考:https://segmentfault.com/a/1190000017357569

参考:https://blog.csdn.net/weixin_38622593/article/details/108809760
参考:https://www.cnblogs.com/dakewei/p/8292523.html

./configure --prefix=/usr/local --enable-static --enable-mini-gmp

需要安装gmp库。 添加–enable-mini-gmp 否则生成不了libhogweed.so文件

编译安装 libtasn1-4.16.tar.gz :

参考:https://amon.org/libtasn1

参考:http://linuxfromscratch.org/blfs/view/svn/general/libtasn1.html

下载:http://ftp.gnu.org/gnu/libtasn1/

wget https://ftp.gnu.org/gnu/libtasn1/libtasn1-4.16.0.tar.gz && tar -xzvf libtasn1-4.16.0.tar.gz && cd libtasn1-4.16.0
export CFLAGS="-std=c99"
./configure --prefix=/usr --disable-static
make && make install
export CFLAGS=""

编译安装 p11-kit-0.23.21 :

参考:http://linuxfromscratch.org/blfs/view/svn/postlfs/p11-kit.html

下载:https://github.com/p11-glue/p11-kit/releases

wget https://github.com/p11-glue/p11-kit/releases/download/0.23.21/p11-kit-0.23.21.tar.xz && xz -d p11-kit-0.23.21.tar.xz && tar -xvf p11-kit-0.23.21.tar && cd p11-kit-0.23.21
export  LIBTASN1_CFLAGS="-I/usr/include" LIBTASN1_LIBS="-L/usr/lib -ltasn1"
./configure --prefix=/usr --sysconfdir=/etc --with-trust-paths=/etc/pki/anchors --with-included-unistring
make && make check
make install

编译安装 libidn2-2.3.0.tar.gz :

参考:http://linuxfromscratch.org/blfs/view/svn/general/libidn2.html

wget ftp://ftp.gnu.org/gnu/libidn/libidn2-2.3.0.tar.gz && tar -xzvf libidn2-2.3.0.tar.gz && cd libidn2-2.3.0
./configure --prefix=/usr --disable-static
make && make install
export LIBIDN2_CFLAGS="-I/usr/include" LIBIDN2_LIBS="-L/usr/lib -lidn2"

如果没有安装,configure gnutls 时将报错:

configure: WARNING: *** LIBIDN2 was not found. You will not be able to use IDN2008 support

参考:https://blog.csdn.net/sui1005316018/article/details/89133036

编译安装 gnutls-3.6.15 :

wget https://www.gnupg.org/ftp/gcrypt/gnutls/v3.6/gnutls-3.6.15.tar.xz && xz -d gnutls-3.6.15.tar.xz && tar -xvf gnutls-3.6.15.tar && cd gnutls-3.6.15
export NETTLE_CFLAGS="-I/usr/include/nettle" NETTLE_LIBS="-L/usr/lib64 -lnettle" HOGWEED_CFLAGS="-I/usr/include/nettle" HOGWEED_LIBS="-L/usr/lib64 -lhogweed" P11_KIT_CFLAGS="-I/usr/include/p11-kit-1/p11-kit" P11_KIT_LIBS="-L/usr/lib -lp11-kit" LIBTASN1_CFLAGS="-I/usr/include" LIBTASN1_LIBS="-L/usr/lib -ltasn1" LIBIDN2_CFLAGS="-I/usr/include" LIBIDN2_LIBS="-L/usr/lib -lidn2" GMP_CFLAGS="-I/usr/local/include" GMP_LIBS="-L/usr/local/lib -lgmp"
./configure --prefix=/usr --docdir=/usr/share/doc/gnutls-3.6.15 --disable-guile --with-included-unistring
make
make install

make 时报错:fatal error: p11-kit/pkcs11.h: No such file or directory

直接将此文件拷贝过来:

cp -R /usr/include/p11-kit-1/p11-kit /root/gnutls-3.6.15/p11-kit
cp -R /usr/include/p11-kit-1/p11-kit /root/gnutls-3.6.15/lib/p11-kit

查看版本:

ldconfig && gnutls-cli -v

输出:

gnutls-cli 3.6.15
Copyright (C) 2000-2020 Free Software Foundation, and others, all rights reserved.
This is free software. It is licensed for use, modification and
redistribution under the terms of the GNU General Public License,
version 3 or later <http://gnu.org/licenses/gpl.html>


Please send bug reports to:  <[email protected]>