ubuntu10.04 apache2.2开启tls1.2的支持,使现代的edge和firefox浏览器能正常访问https

最近发现自己ubuntu10.04服务器上的apache https无法通过win11上的edge和firefox浏览器访问,但xp下的ie6和ie8没有问题。
firefox的错误提示为“此网站可能不支持TLS 1.2协议,而这是Firefox支持的最低版本”。
经过检查发现:
IE6访问https所需的版本是SSLv3。
IE8访问https所需的版本是TLS1.0。
但win11上的edge和最新版本的firefox浏览器访问https所需的版本是TLS1.2。

使apache服务器支持TLS1.2需要的服务器运行环境:
apache对应版本应>=2.2.23
OpenSSL对应版本应>=1.0.1

查看apache和openssl的版本:
apache2 -v
openssl version -a
查看openssl支持的加密算法:
openssl ciphers -v

ubuntu10.04里面能用sudo apt-get安装的最高版本是
Server version: Apache/2.2.14 (Ubuntu)
Server built:   Mar  5 2015 18:11:29
OpenSSL 0.9.8k 25 Mar 2009
built on: Thu Mar 19 15:32:30 UTC 2015
所以必须自己编译新版的apache2和openssl。

系统默认的apache2和openssl都是安装在/usr下的。两者安装在同一目录下,安装文件直接混合在一起。
我们自己源码编译安装的默认是/usr/local/apache2和/usr/local/ssl,两者是分开的。

源码编译安装openssl 1.0.1f:
wget https://www.openssl.org/source/old/1.0.1/openssl-1.0.1f.tar.gz --no-check-certificate
tar xf openssl-1.0.1f.tar.gz
cd openssl-1.0.1f/
./config shared
make
sudo make install

查看刚安装的openssl版本:
/usr/local/ssl/bin/openssl version -a
/usr/local/ssl/bin/openssl ciphers -v

源码编译安装apache2,注意用--with-ssl绑定新安装的openssl:
在浏览器里面下载https://archive.apache.org/dist/httpd/httpd-2.2.23.tar.gz (wget命令不好使了)
tar xf httpd-2.2.23.tar.gz
cd httpd-2.2.23
./configure --enable-deflate --enable-expires --enable-heads --with-mpm-worker --enable-rewrite --enable-so --with-included-apr --enable-ssl --with-ssl=/usr/local/ssl --enable-mods-shared=all
make
sudo make install

查看新安装的apache2里面的mod_ssl模块:
ls -l /usr/local/apache2/modules/mod_ssl.so

将新安装的libssl.so.1.0.0所在的路径加入LD_LIBRARY_PATH列表中:
在/etc/ld.so.conf.d文件夹中新建一个mynewssl.conf文件,内容为/usr/local/ssl/lib。
然后执行sudo ldconfig。

打开/usr/local/apache2/conf/httpd.conf,将
Include conf/extra/httpd-ssl.conf
取消注释。

打开/usr/local/apache2/conf/extra/httpd-ssl.conf,正确配置证书文件路径,如:
SSLCertificateFile    /etc/ssl/certs/ssl-cert-snakeoil.pem
SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key

启动新安装的apache2:
sudo /usr/local/apache2/bin/apachectl start
停止新安装的apache2:
sudo /usr/local/apache2/bin/apachectl stop

然后再访问https,就可以访问成功了。在firefox里面也可以看到apache已经支持tls1.2了。

IE6:

IE8:

win11下的edge浏览器:

win11下的ie11浏览器:

 


新安装的apache2.2.23绑定系统已有的php:
在/usr/local/apache2/conf/httpd.conf末尾加入
Include /etc/apache2/mods-available/php5.load
Include /etc/apache2/mods-available/php5.conf

【可选】引用以前的VirtualHost虚拟主机配置文件:
(不用补加NameVirtualHost指令)
Include /etc/apache2/sites-available/myoldsite.conf
如果访问出现
Forbidden
You don't have permission to access / on this server.
则需要在myoldsite.conf的<VirtualHost>的<Directory>下加入Allow from All指令。

重启新安装的apache2:
sudo /usr/local/apache2/bin/apachectl restart

禁止ubuntu10.04原有的apache2开机自启动:
$ sudo update-rc.d -f apache2 remove
 Removing any system startup links for /etc/init.d/apache2 ...
   /etc/rc0.d/K20apache2
   /etc/rc1.d/K20apache2
   /etc/rc2.d/S20apache2
   /etc/rc3.d/S20apache2
   /etc/rc4.d/S20apache2
   /etc/rc5.d/S20apache2
   /etc/rc6.d/K20apache2