gmssl编译安装过程,避免与服务器已安装的openssl冲突

1、登录服务器,从Git上把源码拿下来:

git clone git://github.com/guanzhi/GmSSL.git

$ git clone git://github.com/guanzhi/GmSSL.git
正克隆到 'GmSSL'...
remote: Enumerating objects: 2, done.
remote: Counting objects: 100% (2/2), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 15804 (delta 0), reused 0 (delta 0), pack-reused 15802
接收对象中: 100% (15804/15804), 36.80 MiB | 5.14 MiB/s, 完成.
处理 delta 中: 100% (9244/9244), 完成.
$ 

2、修改Makefile.shared文件中的soname参数变量值:

DO_GNU_SO_COMMON=\
	SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -Wl,-Bsymbolic -Wl,-soname=libgm$(LIBNAME)$$SHLIB_SOVER$$SHLIB_SUFFIX"

gmssl编译安装过程,避免与服务器已安装的openssl冲突_第1张图片

3、按照官网说明进行编译安装:

http://gmssl.org/docs/install.html

gmssl编译安装过程,避免与服务器已安装的openssl冲突_第2张图片

$ ./config  --prefix=/usr/local --openssldir=/usr/local/ssl
$ sudo make
$ sudo make install
$ openssl version
openssl: error while loading shared libraries: libgmssl.1.1: cannot open shared object file: No such file or directory
$ gmssl version
gmssl: error while loading shared libraries: libgmssl.1.1: cannot open shared object file: No such file or directory

a、此时发现openssl和gmssl加载不到依赖包。

4、重新编译openssl并安装:

#./config shared --prefix=/usr/local --openssldir=/usr/local/ssl
#make && make install
# openssl version
OpenSSL 1.1.0d  26 Jan 2017

# gmssl version
gmssl: error while loading shared libraries: libgmssl.1.1: cannot open shared object file: No such file or directory

b、解决了openssl的问题

5、查看gmssl安装路径并拷贝so文件到依赖包文件夹下:

# ldd /usr/local/bin/gmssl
        linux-vdso.so.1 (0x00007ffc9a9b3000)
        libgmssl.1.1 => not found
        libgmcrypto.1.1 => not found
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fdf82142000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fdf81d51000)
        /lib64/ld-linux-x86-64.so.2 (0x00007fdf8261d000)

# cp libcrypto.so.1.1 /usr/local/lib/libgmcrypto.1.1
# cp libssl.so.1.1 /usr/local/lib/libgmssl.1.1

6、gmssl 找不到链接库:

/etc/ld.so.conf.d/路径下配置链接库路径,然后重新执行ldconfig

# gmssl version
gmssl: error while loading shared libraries: libgmssl.1.1: cannot open shared object file: No such file or directory

# cd /etc/ld.so.conf.d/

# more openssl-1.1.0d.conf 
/usr/local/ssl/lib

7、重启服务器即可:

reboot命令重启服务器即可:

# gmssl version
GmSSL 2.5.4 - OpenSSL 1.1.0d  3 Sep 2019
# openssl version
OpenSSL 1.1.0d  26 Jan 2017

完~

你可能感兴趣的:(gmssl编译安装过程,避免与服务器已安装的openssl冲突)