SSL,全称Secure Socket

Layer,为Netscape所研发,用以保障在Internet上数据传输之安全,利用数据加密(Encryption)技术,可确保数据在网络上之传输过程中不会被截取及窃听。简单的说,就是加密传输的数据,避免被截取监听等。

简单的理解,OpenSSL是一个强大的支持库,更是一个强大的密码工具。虽然要支持SSL协议不一定得采用OpenSSL,但是基本大部分的都是采用OpenSSL.

        由于最近互联网安全协议OpenSSL v1.0.1到1.0.1f的密码算法库中发现了一个非常严重bug(CVE-2014-0160),该bug允许攻击者读取存在bug的系统的64kb处理内存,暴露加密流量的密钥,用户的名字和密码,以及访问的内容。这个漏洞被认为是heartbleed,心脏流血..... 可见严重性.

 据solidot报道,OpenSSL已经发布了1.0.1g修正bug,Debian发行版也在半小时修复了bug,Fedora发布了一个权宜的修正方案。 该bug是在2011年引入到OpenSSL中,使用OpenSSL 0.9.8的发行版不受影响,但Debian Wheezy、Ubuntu 12.04.4、 CentOS 6.5、Fedora 18、SUSE 12.2、OpenBSD 5.4、FreeBSD 8.4和NetBSD 5.0.2之后的版本都受到影响。如果你运行存在该bug的系统,那么最好废除所有密钥。

修复建议:

使用低版本SSL的网站,并尽快按如下方案修复该漏洞:

升级OpenSSL 1.0.1g

使用-DOPENSSL_NO_HEARTBEATS参数重新编译低版本的OpenSSL以禁用Heartbleed模块

这里由于我们大部分使用debian5 里面还是0.9.8e, 该版本不受影响.有些新上项目用的是debian 7  1.0.1e需要升级openssl 到1.0.1g


?



debian          5        
         root@debian         # openssl version -a        
         OpenSSL          0.9         .         8g          19          Oct          2007          (Library: OpenSSL          0.9         .         8o          01          Jun          2010         )        
         built on: Thu Feb          10          19         :         15         :         33          UTC          2011        
         platform: debian         -         amd64        
         options:  bn(         64         ,         64         ) md2(         int         ) rc4(ptr,char) des(idx,cisc,         16         ,         int         ) blowfish(ptr2)         
         compiler: gcc          -         fPIC          -         DOPENSSL_PIC          -         DZLIB          -         DOPENSSL_THREADS          -         D_REENTRANT          -         DDSO_DLFCN          -         DHAVE_DLFCN_H          -         m64          -         DL_ENDIAN          -         DTERMIO          -         O3          -         Wa,         -         -         noexecstack          -         g          -         Wall          -         DMD32_REG_T         =         int          -         DOPENSSL_BN_ASM_MONT          -         DSHA1_ASM          -         DSHA256_ASM          -         DSHA512_ASM          -         DMD5_ASM          -         DAES_ASM        
         OPENSSLDIR:          "/usr/lib/ssl"        
                  
                  
         debian          7        
         root@         10.1         .         1.100         :~         # openssl version -a        
         OpenSSL          1.0         .         1e          11          Feb          2013        
         built on: Sat Feb           1          22         :         14         :         33          UTC          2014        
         platform: debian         -         amd64        
         options:  bn(         64         ,         64         ) rc4(         16x         ,         int         ) des(idx,cisc,         16         ,         int         ) blowfish(idx)         
         compiler: gcc          -         fPIC          -         DOPENSSL_PIC          -         DZLIB          -         DOPENSSL_THREADS          -         D_REENTRANT          -         DDSO_DLFCN          -         DHAVE_DLFCN_H          -         m64          -         DL_ENDIAN          -         DTERMIO          -         g          -         O2          -         fstack         -         protector          -         -         param         =         ssp         -         buffer         -         size         =         4          -         Wformat          -         Werror         =         format         -         security          -         D_FORTIFY_SOURCE         =         2          -         Wl,         -         z,relro          -         Wa,         -         -         noexecstack          -         Wall          -         DMD32_REG_T         =         int          -         DOPENSSL_IA32_SSE2          -         DOPENSSL_BN_ASM_MONT          -         DOPENSSL_BN_ASM_MONT5          -         DOPENSSL_BN_ASM_GF2m          -         DSHA1_ASM          -         DSHA256_ASM          -         DSHA512_ASM          -         DMD5_ASM          -         DAES_ASM          -         DVPAES_ASM          -         DBSAES_ASM          -         DWHIRLPOOL_ASM          -         DGHASH_ASM        
         OPENSSLDIR:          "/usr/lib/ssl"



 1.安装相关依赖


?



root10.         1.1         .         100         @:~         # apt-get install zlib1g zlib1g-dev


 2. 下载源码


?



root10.         1.1         .         100         @         192.168         .         37.48         :~         # wget ftp://ftp.openssl.org/source/openssl-1.0.1g.tar.gz




?



root@         10.1         .         1.100         :~         # tar xf openssl-1.0.1g.tar.gz         
         root@         10.1         .         1.100         :~         # cd openssl-1.0.1g/        
         root@         10.1         .         1.100         :openssl         -         1.0         .         1g         # ./config shared zlib        
         root@         10.1         .         1.100         :openssl         -         1.0         .         1g         # make         
         root@         10.1         .         1.100         :openssl         -         1.0         .         1g         # make install        
         root@         10.1         .         1.100         :openssl         -         1.0         .         1g         # mv /usr/bin/openssl /tmp/        
         root@         10.1         .         1.100         :openssl         -         1.0         .         1g         # mv /usr/include/openssl/ /tmp/        
         root@         10.1         .         1.100         :openssl         -         1.0         .         1g         # ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl        
         root@         10.1         .         1.100         :openssl         -         1.0         .         1g         # ln -s /usr/local/ssl/include/openssl/ /usr/include/openssl        
         #配置文件搜索路径        
         root@         10.1         .         1.100         :openssl         -         1.0         .         1g         # echo "/usr/local/ssl/lib" >> /etc/ld.so.conf         
         root@         10.1         .         1.100         :openssl         -         1.0         .         1g         # ldconfig -v | grep openssl        
         ldconfig: Path `         /         lib         /         x86_64         -         linux         -         gnu' given more than once        
         ldconfig: Path `         /         usr         /         lib         /         x86_64         -         linux         -         gnu' given more than once        
                  libgnutls         -         openssl.so.         27          -         > libgnutls         -         openssl.so.         27.0         .         0        
                  libevent_openssl         -         2.0         .so.         5          -         > libevent_openssl         -         2.0         .so.         5.1         .         7        
                  
         #查看最新版本        
         root@         10.1         .         1.100         :openssl         -         1.0         .         1g         # openssl version -a        
         OpenSSL          1.0         .         1g          7          Apr          2014        
         built on: Wed Apr           9          17         :         15         :         00          CST          2014        
         platform: linux         -         x86_64        
         options:  bn(         64         ,         64         ) rc4(         16x         ,         int         ) des(idx,cisc,         16         ,         int         ) idea(         int         ) blowfish(idx)         
         compiler: gcc          -         fPIC          -         DOPENSSL_PIC          -         DZLIB          -         DOPENSSL_THREADS          -         D_REENTRANT          -         DDSO_DLFCN          -         DHAVE_DLFCN_H          -         Wa,         -         -         noexecstack          -         m64          -         DL_ENDIAN          -         DTERMIO          -         O3          -         Wall          -         DOPENSSL_IA32_SSE2          -         DOPENSSL_BN_ASM_MONT          -         DOPENSSL_BN_ASM_MONT5          -         DOPENSSL_BN_ASM_GF2m          -         DSHA1_ASM          -         DSHA256_ASM          -         DSHA512_ASM          -         DMD5_ASM          -         DAES_ASM          -         DVPAES_ASM          -         DBSAES_ASM          -         DWHIRLPOOL_ASM          -         DGHASH_ASM        
         OPENSSLDIR:          "/usr/local/ssl"