openssl升级并发症

简单介绍一下系统环境:

操作系统:redhat6.3 ,安装的主要涉及到的包有:

root@192.168.100.252:/root# rpm -qa | grep ssh
openssh-5.3p1-52.el6.x86_64
openssh-server-5.3p1-52.el6.x86_64
openssh-clients-5.3p1-52.el6.x86_64
libssh2-1.2.2-7.el6.x86_64
root@192.168.100.252:/root# rpm -qa | grep openssl 
openssl-1.0.0-10.el6.x86_64
openssl-devel-1.0.0-10.el6.x86_64

下面要做的就是把openssl升级到当前稳定版本 [源码升级,简单透明]

root@192.168.100.252:/data/installs/openssl-1.0.0m# ./config --prefix=/usr/local/openssl/ --openssldir=/usr/local/ssl shared zlib-dynamic
root@192.168.100.252:/data/installs/openssl-1.0.0m# make
root@192.168.100.252:/data/installs/openssl-1.0.0m# make test
root@192.168.100.252:/data/installs/openssl-1.0.0m# make install
...[回显省略]....
root@192.168.100.252:/data/installs/openssl-1.0.0m# cd /usr/local/openssl/
root@192.168.100.252:/usr/local/openssl# ls include/
openssl
root@192.168.100.252:/usr/local/openssl# ls lib/
engines  libcrypto.a  libcrypto.so  libcrypto.so.1.0.0  libssl.a  libssl.so  libssl.so.1.0.0  pkgconfig

 config参数解析一下:

--prefix=DIR : Install in DIR/bin, DIR/lib, DIR/include/openssl. Configuration files used by OpenSSL will be in DIR/ssl or the directory specified by --openssldir.

--openssldir=DIR : Directory for OpenSSL files. If no prefix is specified, the library files and binaries are also installed there.

shared : In addition to the usual static libraries, create shared libraries on platforms where it's supported. See "Note on shared libraries" below.

zlib-dynamic : Like "zlib", but has OpenSSL load the zlib library dynamically when needed. This is only supported on systems where loading of shared libraries is supported. This is the default choice.


-------------Note on shared libraries----------- 

Shared libraries have certain caveats. Binary backward compatibility can't be guaranteed before OpenSSL version 1.0. The only reason to use them would be to conserve memory on systems where several programs are using OpenSSL. For some systems, the OpenSSL Configure script knows what is needed to build shared libraries for libcrypto and libssl. On these systems, the shared libraries are currently not created by default, but giving the option "shared" will get them created. This method supports Makefile targets for shared library creation, like linux-shared. Those targets can currently be used on their own just as well, but this is expected to change in future versions of OpenSSL.

生词比较多,翻译一下:共享库一些说明:1.0之前的版本不保证向后的兼容性,而且还坚持使用1.0之前的版本的唯一目的是为了保存多个正在使用openssl的程序的内存,某些系统在使用openssl编译的时候,脚本会识别需要添加的libcrypto和libssh库,对于这些系统,共享库没有默认立即创建,而是提供shared选项,以这种方式提供共享库的创建。例如linux-shared,这些编译出来的文件可以在当前系统上正常运行,但是这些对于以后的版本,openssl可能会做一些修改。

从INSTALL文件上可以看到,openssl升级对于某些正在使用openssl动态链接库的程序保持了兼容性,但是如果要坚持编译新的动态链接库,将导致基于老版本的openssl的其他程序出现未知的错误(下面的sshd的问题就讲到了这个问题)

下面来查查sshd服务启动失败的原因

上面的图中可以看到/usr/bin/ssh调用了三个有crypt字段动态链接库:

libcrypto.so.10 => /usr/lib64/libcrypto.so.10 (0x00007f89404a7000)
libcrypt.so.1 => /lib64/libcrypt.so.1 (0x00007f893fc3e000)
libk5crypto.so.3 => /lib64/libk5crypto.so.3 (0x00007f893f2d8000)

其中/usr/lib64/libcrypto.so.10 是调用了最新编译的动态链接库,这个库也是前面编译出来的库之一,很明显是由于这个库的替换导致sshd服务启动失败。

 

下面讲下外网服务器openssl升级的情况:

升级脚本:

./config --prefix=/usr/ --openssldir=/usr/local/openssl
make
make test
make install

 

这样升级会产生一堆的新文件替换原来的旧文件:

 

/usr/lib64
drwxr-xr-x 2 root root    4096 Jan 23 11:57 engines
-rw-r--r-- 1 root root 3715046 Jan 23 11:57 libcrypto.a
-rw-r--r-- 1 root root  672190 Jan 23 11:57 libssl.a
drwxr-xr-x 2 root root    4096 Jan 23 11:57 pkgconfig

/usr/include/openssl/*.h

/usr/bin
-rwxr-xr-x 1 root root   4265 Jan 23 11:57 c_rehash
-rwxr-xr-x 1 root root 569237 Jan 23 11:57 openssl

 

这些文件都是直接替换,如果不做备份,根本没法还原。。。外网服务器上的窟噜够大啦

建议小伙伴们没事就别去做这个升级了,除非你深刻的知道你的系统调用openssl动态链接库的程序很少,否则,极其有可能导致你系统在重启后一堆的未知error。

posted @ 2015-01-23 14:15  forilen  阅读(2094)  评论(0编辑  收藏  举报