前言

前段时间由于业务需要,在服务器上新增一个服务专门接收各个门店的业务结算数据,接口文档指明需要使用https协议。这本不是什么问题,因为之前服务器已经有配置过https。但等到服务部署之后才发现这些客户端死活连接不上。一直提示“Error connecting with SSL”的错误。服务器明明已经配置好了,而且其它服务使用https协议通信都正常,为什么偏偏这些客户端连接不上呢?

故障排解

windows软件使用https协议访问服务器时无法成功连接,通过wireshark发现客户端软件所发送的client hello请求所支持的cipher suites的版本比较老旧,而服务器返回handshake failure的提示。

客户端软件所发送的握手请求中cipher suites的支持如下:
Cipher Specs (29 specs)
Cipher Spec: TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA (0x000016)
Cipher Spec: TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA (0x000013)
Cipher Spec: TLS_RSA_WITH_3DES_EDE_CBC_SHA (0x00000a)
Cipher Spec: TLS_DHE_DSS_WITH_RC4_128_SHA (0x000066)
Cipher Spec: TLS_RSA_WITH_IDEA_CBC_SHA (0x000007)
Cipher Spec: TLS_RSA_WITH_RC4_128_SHA (0x000005)
Cipher Spec: TLS_RSA_WITH_RC4_128_MD5 (0x000004)
Cipher Spec: TLS_DHE_RSA_WITH_DES_CBC_SHA (0x000015)
Cipher Spec: TLS_DHE_DSS_WITH_DES_CBC_SHA (0x000012)
Cipher Spec: TLS_RSA_WITH_DES_CBC_SHA (0x000009)
Cipher Spec: SSL2_DES_192_EDE3_CBC_WITH_MD5 (0x0700c0)
Cipher Spec: SSL2_IDEA_128_CBC_WITH_MD5 (0x050080)
Cipher Spec: SSL2_RC2_128_CBC_WITH_MD5 (0x030080)
Cipher Spec: SSL2_RC4_128_WITH_MD5 (0x010080)
Cipher Spec: SSL2_RC4_64_WITH_MD5 (0x080080)
Cipher Spec: SSL2_DES_64_CBC_WITH_MD5 (0x060040)
Cipher Spec: TLS_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA (0x000065)
Cipher Spec: TLS_RSA_EXPORT1024_WITH_RC4_56_SHA (0x000064)
Cipher Spec: TLS_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA (0x000063)
Cipher Spec: TLS_RSA_EXPORT1024_WITH_DES_CBC_SHA (0x000062)
Cipher Spec: TLS_RSA_EXPORT1024_WITH_RC2_CBC_56_MD5 (0x000061)
Cipher Spec: TLS_RSA_EXPORT1024_WITH_RC4_56_MD5 (0x000060)
Cipher Spec: TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA (0x000014)
Cipher Spec: TLS_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA (0x000011)
Cipher Spec: TLS_RSA_EXPORT_WITH_DES40_CBC_SHA (0x000008)
Cipher Spec: TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5 (0x000006)
Cipher Spec: TLS_RSA_EXPORT_WITH_RC4_40_MD5 (0x000003)
Cipher Spec: SSL2_RC2_128_CBC_EXPORT40_WITH_MD5 (0x040080)
Cipher Spec: SSL2_RC4_128_EXPORT40_WITH_MD5 (0x020080)

google资料发现这些加密套件都是很老旧的,有人(https://www.v2ex.com/amp/t/355178)指出,“XP 版本的 IE 8 只支持 SSLv3 和 TLS 1.0 的 Cipher Suite ,另外 nginx 自 1.9.1 开始默认不会开启 SSLv3”。因此,为了让服务器支持像IE8/XP这类客户端,就不得不重新编译Nginx,在其中加入支持3DES的参数。

编译安装Nginx

依赖工具/库
dev@ubuntu:~$ sudo apt-get install build-essential libpcre3 libpcre3-dev zlib1g-dev unzip git
下载Nginx
dev@ubuntu:~$ wget -c https://nginx.org/download/nginx-1.12.2.tar.gz
dev@ubuntu:~$ tar zxf nginx-1.12.2.tar.gz
查看openSSL版本

本机的openSSL是否支持3DES算法并不影响Nginx是否支持3DES,Nginx是否支持只与它编译时所使用的openSSL版本有关,从上面的讨论中可以知道当前版本的Nginx默认是不支持3DES算法的。而openSSL 1.1.0 以上版本默认不支持也3DES加密。

dev@ubuntu:~$ openssl version
查看openssl是否支持 3DES加密
dev@ubuntu:~$ openssl ciphers -v "3DES"
下载openssl源

此处的openSSL源码只是为了用来编译Nginx,跟已经安装在本机上的openSSL没有任何关系。

dev@ubuntu:~$  wget -O openssl.zip -c https://github.com/openssl/openssl/archive/OpenSSL_1_0_1f.zip
dev@ubuntu:~$ unzip openssl.zip
dev@ubuntu:~$ mv openssl-OpenSSL_1_0_1f/ openssl
编译安装Nginx

其中--with-openssl指向openssl源文件 --with-http_ssl_module指明支持ssl 参数--with-openssl-opt指明openssl的选项,其中若要兼容IE8则要添加'enable-weak-ssl-ciphers'。其它的参数可按需配置。

(--with-cc-opt='-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fPIC' --with-ld-opt='-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -pie' 这两个参数添加之后有时候会报错)

dev@ubuntu:~$   cd nginx-1.12.2
dev@ubuntu:~/nginx-1.12.2$  ./configure --with-openssl=../openssl --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module  --with-openssl-opt='enable-weak-ssl-ciphers' --with-http_ssl_module
dev@ubuntu:~/nginx-1.12.2$  make
dev@ubuntu:~/nginx-1.12.2$ sudo make install
配置Nginx

下面是Nginx关于SSL/TLS的相关配置。

server {
listen 443 ssl;
proxy_set_header X-Real-IP $remote_addr;
server_name a.example.com;
ssl_certificate /etc/nginx/cert/cert.pem;
ssl_certificate_key /etc/nginx/cert/cert.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers EECDH+CHACHA20-draft:EECDH+CHACHA20:EECDH+ECDSA+AES128:EECDH+aRSA+AES128:RSA+AES128:EECDH+ECDSA+AES256:EECDH+aRSA+AES256:RSA+AES256:EECDH+ECDSA+3DES:EECDH+aRSA+3DES:RSA+3DES:!MD5;
ssl_prefer_server_ciphers on;
root /home/www/html;
index index.html index.htm;
location /api {
proxy_pass http://localhost:8000;
}
}

参考

https://imququ.com/post/troubleshooting-https.html
https://www.centos.bz/2017/08/nginx-enable-tls-1-3/
https://dyn.im/2016/09/14/21/
https://www.feistyduck.com/library/openssl%2dcookbook/online/
https://www.ssllabs.com/ssltest/analyze.html

Nginx 兼容IE8的更多相关文章

  1. Bootstrap 3 兼容 IE8 浏览器

    公司新上的项目,前端用的Bootstrap3的框架,但它已经放弃对IE9下的支持了.可IE8还是有着许多用户,不能不照顾到他们,IE7以下的,我只想说,现在什么年代了,要解放思想,与时俱进啊,就不能动 ...

  2. 兼容IE8以下浏览器input表单属性placeholder不能智能提示功能

    当前很多表单提示使用了表单属性placeholder,可这属性不兼容IE8以下的浏览器,我自己写了一个兼容处理js // 兼容IE8以下浏览器input不能智能提示功能 if(navigator.ap ...

  3. 如何使用videojs兼容IE8浏览器

    需要在服务器下运行 首先我们需要下载videojs包 https://github.com/videojs/video.js/releases 这里简单写了一个小栗子 <!DOCTYPE htm ...

  4. jQuery validate兼容IE8写法

    最近做项目的时候遇到一个validate插件在IE8下面点击submit按钮没有执行检查的BUG 在chrome和FF,还有IE9以上都可以.百度了好多文章都没有找到解决方法,后面自己测试找到了问题. ...

  5. 兼容ie8 rgba()用法

    今天遇到了一个问题,要在一个页面中设置一个半透明的白色div.这个貌似不是难题,只需要给这个div设置如下的属性即可: background: rgba(255,255,255,.1); 但是要兼容到 ...

  6. 【转】让Bootstrap 3兼容IE8浏览器

    FROM : http://www.ijophy.com/2014/05/bootstrap3-compatible-with-ie8.html 最近在研究Bootstrap(官方,Github)这个 ...

  7. 让Bootstrap 3兼容IE8浏览器

    最近在研究Bootstrap(官方,Github)这个优秀的前端框架,Bootstrap最开始是Twitter团队内部的一个前端框架,所谓前端框架就是一个CSS/HTML框架,框架里面有下拉菜单.按钮 ...

  8. css样式设置图片半透明度,兼容IE8,火狐

    关于背景颜色透明的兼容浏览器的问题,一直是个问题,我所写的兼容IE8,和火狐,说是兼容所有浏览器我就没有测试,有兴趣的朋友可以自己测试下吧. background-color:white;filter ...

  9. 兼容ie8 rgba()用法 滤镜filter的用法

    原文  http://blog.csdn.net/westernranger/article/details/40836861 今天遇到了一个问题,要在一个页面中设置一个半透明的白色div.这个貌似不 ...

随机推荐

  1. spark streaming的应用

    今天我们讲spark streaming的应用,这个是实时处理的,类似于Storm以及Flink相关的知识点, 说来也巧,今天的自己也去听了关于Flink的相关的讲座,可惜自己没有听得特别清楚,好像是 ...

  2. 5.Mongodb聚合

    聚合 aggregate 聚合(aggregate)主要用于计算数据,类似sql中的sum().avg() 语法 db.集合名称.aggregate([{管道:{表达式}}]) 1.管道 管道在Uni ...

  3. CC3200在AP模式的TCP sock作为客户端连接时返回SL_ECONNREFUSED(-111) Connection refused

    1. CC3200处于AP模式(电脑无线连接CC3200的WIFI信号),开启一个TCP socket,这个socket作为TCP客户端去连接TCP服务器端 struct sockaddr_in ad ...

  4. loj2100 「TJOI2015」线性代数

    先推公式,推出个这,然后因为是 \(0/1\) 矩阵,选一个有损耗,两个一组有加成,就想到了最大权闭合子图,(飞行计划问题) #include <iostream> #include &l ...

  5. groupSum6后向遍历

    http://codingbat.com/prob/p199368 public boolean groupSum6(int start, int[] nums, int target) { if( ...

  6. js学习日记-各种宽高总结(配图)

    1.窗口和浏览器 window.innerWidth.window.innerHeight   浏览器内部可用宽高 window.outerWidth.window.outerHeight   浏览器 ...

  7. Java8 时间处理

    Table of Contents 前言 时间单位和时区 时间点 时间段 时间的解析和格式化 时区时间 兼容旧接口 结语 前言 时间处理是一个经常会用到但又不那么好用的功能,其中的主要问题在于对人友好 ...

  8. Python 协程与事件循环

    Table of Contents 前言 协程 async & await 事件循环 asyncio 的事件循环 结语 参考链接 前言 Python 标准库 asyncio 是我目前接触过的最 ...

  9. save?commit

    数据库的隐式提交 先看一段SQL,最后一条SQL的输出你认为是什么? 1 2 3 4 5 6 7 SET AUTOCOMMIT = 1; BEGIN; INSERT INTO t1 VALUES (1 ...

  10. 孤荷凌寒自学python第四天 安装python的其它IDE环境

    孤荷凌寒自学python第四天 安装python的其它IDE环境 (完整学习过程屏幕记录视频地址在文末) 因为是完全的新手,对python环境搭建完全一无所知,因此,可真是大费周章才配置了其它多个Id ...