Nginx / HaproxyはOpenSSLアップグレードソリューション+証明書セキュリティ検出手順を実装しています

偽造防止コード:ヒーローとして生まれ、ゴーストとして死んだ。

1. Haproxy:

1、centos6.5系统
[root @ yangwen〜]#cat / etc / redhat-release
CentOS release 6.5(Final)
[root @ yangwen〜]
#uname -r 2.6.32-431.el6.x86_64
2、下载合编译
安装openssl [root @ yangwen〜]#wget https://www.openssl.org/source/openssl-1.1.1.tar.gz
[root @ yangwen〜]#tar zxf openssl-1.1.1.tar.gz
[ root @ yangwen〜]#cd openssl-1.1.1
[root @ yangwen openssl-1.1.1]#./config --prefix = / usr / local /
[root @ yangwen openssl-1.1.1]#make && make install
[root @ yangwen openssl-1.1.1]#echo / usr / local / openssl / lib >> / etc / ld.so.conf
[root @ yangwen〜]#ln -sf /usr/local/lib64/libcrypto.so .1.1 /lib64/libcrypto.so.1.1
[root @ yangwen〜]#ln -sf /usr/local/lib64/libssl.so.1.1 /lib64/libssl.so.1.1
[root @ yangwen〜]#opensslバージョン
OpenSSL 1.1.1 2018年9月11日
haproxをダウンロードしてコンパイルしてインストールします(opensslをサポートします。このWebサイトにアクセスしてhttp://down.51cto.com/をダウンロードできます)。

%M(S%9K%){A`R5KC4 $ RQV [1.png [root @ yangwen local]#ls haproxy-1.7.5.tar.gz
haproxy-1.7.5.tar.gz
[root @ yangwen local]#tar zxf haproxy-1.7.5.tar.gz
[root @ yangwen local] #cd haproxy-1.7.5
[root @ yangwen haproxy-1.7.5]#yum -y install pcre-devel zlib-devel
[root @ yangwen haproxy-1.7.5]#make TARGET = linux \
USE_ZLIB = 1 \
USE_PCRE = 1 \
USE_OPENSSL = 1 \
SSL_INC = / usr / local / include \
SSL_LIB = / usr / local / lib
[root @ yangwen haproxy-1.7.5]
#make install 验证:ldd / usr / local / sbin / haproxy | fgrep ssl应该输出:
[root @ yangwen〜]#ldd / usr / local / sbin / haproxy | fgrep ssl
 libssl.so.1.1 => /lib64/libssl.so.1.1(0x00007f91364b8000) 

2. Nginxの記事

1. centos6.5システムを準備します
[root @ yangwen〜]#cat / etc / redhat-release
CentOS release 6.5(Final)
[root @ yangwen〜]
#uname -r 2.6.32-431.el6.x86_64
2.コンパイルしてインストールしますnginxおよびopensslをサポート

スクリプトは次のとおりです。

#!/ bin / bash
wget -P / usr / local / src http://nginx.org/download/nginx-1.15.6.tar.gz
wget -P / usr / local / src https://www.openssl.org/source/openssl-1.1.1.tar.gz
yum -y install epel-release
yum -yインストールパッチgcc gcc-c ++ readline-devel zlib-devel libffi-devel \
 openssl openssl-devel make autoconf automake libtool bison libxml2 \
 libxml2-devel libxslt-devel libyaml-devel python python-docutils \
 cmake imake expat-devel libaio libaio-devel bzr ncurses-devel wget \
 libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel¥
 pcre-devel curl-devel libmcrypt libmcrypt-devel
id nginx&> / dev / null
もし[$?-ne 0];その後
  groupadd -r nginx
  useradd -g nginx -r nginx
されます
cd / usr / local / src
tar -xvf openssl-1.1.1.tar.gz
tar -xvf nginx-1.15.6.tar.gz
cd /usr/local/src/nginx-1.15.6
./configure --prefix = / usr / local / nginx \
--sbin-path = / usr / sbin / nginx \
--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-http_ssl_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_sub_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_random_index_module \
--with-http_secure_link_module \
--with-http_stub_status_module \
--with-http_auth_request_module \
--with-threads \
--with-stream \
--with-openssl = / usr / local / src / openssl-1.1.1 \
--with-stream_ssl_module \
--with-http_slice_module \
--with-mail \
--with-mail_ssl_module \
--with-file-aio \
--with-http_v2_module \
--with-ipv6 
mkdir -pv / var / cache / nginx / {client_temp、proxy_temp、fastcgi_temp、uwsgi_temp、scgi_temp}
make && make install

[root @ yangwen〜]#/ usr / sbin / nginx
[root @ yangwen〜]#ps -ef | grep nginx
root 15935 1 0 20:38?00:00:00 nginx:マスタープロセス/ usr / sbin / nginx
nginx 15936 15935 0 20:38?00:00:00 nginx:ワーカープロセス
ルート15939 2510 0 20:38 pts / 1 00:00:00 grep nginx
[root @ yangwen〜]#netstat -anpt | grep nginx
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 15935 / nginx        
[root @ yangwen〜]#curl -I 127.0.0.1
HTTP / 1.1 200 OK
Server:nginx / 1.11.7
Date:Tue、20 Nov 2018 12:38:58 GMT
Content-Type:text / html
Content-Length:612
Last-Modified:Tue、20 Nov 2018 12:38:07 GMT
Connection:keep-alive
ETag:「5bf4002f-264」
Accept-Ranges:バイト

[root @ yangwen〜]#nginx -V
nginxバージョン:
gcc 4.4.7で構築されたnginx / 1.11.7 20120313(Red Hat 4.4.7-23)(GCC)
OpenSSL 1.1.0eで構築されました2017年2月16日
TLS SNIサポートが有効
引数を設定します:--prefix = / usr / local / nginx --sbin-path = / usr / sbin / nginx --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。ロック--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-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module- with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-threads --with-stream --with-openssl = / usr / local / src / openssl-1.1.0e --with- stream_ssl_module --with-http_slice_module --with-mail --with-mail_ssl_module --with-file-aio --with-http_v2_module --with-ipv60e --with-stream_ssl_module --with-http_slice_module --with-mail --with-mail_ssl_module --with-file-aio --with-http_v2_module --with-ipv60e --with-stream_ssl_module --with-http_slice_module --with-mail --with-mail_ssl_module --with-file-aio --with-http_v2_module --with-ipv6

3、升级openssl
[root @ yangwen〜]#wget https://www.openssl.org/source/openssl-1.1.1.tar.gz
[root @ yangwen〜]#tar zxf openssl-1.1.1.tar。 gz
[root @ yangwen〜]#cd openssl-1.1.1
[root @ yangwen openssl-1.1.1]#mkdir -p / usr / local / ssl
[root @ yangwen openssl-1.1.1]#. / config- openssldir = / usr / local / ssl
[root @ yangwen openssl-1.1.1]#make -j $(nproc)&& make -j $(nproc)install

[ルート@ヤンウェンopenssl-1.1.1]#ln -sf /usr/local/lib64/libcrypto.so.1.1
/lib64/libcrypto.so.1.1 [ルート@ヤンウェンopenssl-1.1.1]#ln -sf / usr /local/lib64/libssl.so.1.1 /lib64/libssl.so.1.1
[root @ yangwen openssl-1.1.1]#opensslバージョン
OpenSSL 1.1.1 2018年9月11日
4. nginxを再コンパイルしてインストールし
ますセカンダリパラメータのパスに注意してください: --with-openssl = / usr / local / src / openssl-1.1.1
[root @ yangwen〜]#/ usr / sbin / nginx
[root @ yangwen〜]#ps -ef | grep nginx
root 37756 1 0 20: 57?
00:
00 :00 nginx:マスタープロセス/ usr / sbin / nginx nginx 37757 37756 0 20:57?00: 00 : 00 nginx:ワーカープロセスルート37759 2510 0 20:58 pts / 1 00:00:00 grep nginx
[root @ yangwen〜]#netstat -anpt | grep nginx
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 37756 / nginx        
[root @ yangwen〜]#curl -I 127.0.0.1
HTTP / 1.1 200 OK
Server:nginx / 1.15.6
Date:Tue、20 Nov 2018 12 :58:20 GMT
Content-Type:text / html
Content-Length:612
Last-Modified:Tue、20 Nov 2018 12:38:07 GMT
Connection:keep-alive
ETag: "5bf4002f-264"
Accept-Ranges:bytes

[root @ yangwen〜]#nginx -V
nginxバージョン:
gcc 4.4.7で構築されたnginx / 1.15.6 20120313(Red Hat 4.4.7-23)(GCC)
OpenSSL 1.1.1で構築された2018年9月11日
TLS SNIサポートが有効
引数を設定します:--prefix = / usr / local / nginx --sbin-path = / usr / sbin / nginx --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。ロック--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-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module- with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-threads --with-stream --with-openssl = / usr / local / src / openssl-1.1.1 --with- stream_ssl_module --with-http_slice_module --with-mail --with-mail_ssl_module --with-file-aio --with-http_v2_module --with-ipv61 --with-stream_ssl_module --with-http_slice_module --with-mail --with-mail_ssl_module --with-file-aio --with-http_v2_module --with-ipv61 --with-stream_ssl_module --with-http_slice_module --with-mail --with-mail_ssl_module --with-file-aio --with-http_v2_module --with-ipv6
注:opensslの新しいバージョンが統合されているため、ldd / usr / sbin / nginx | grep sslは表示されなくなります

より安全に操作するには、次のコマンドをお勧めします。./configure
xxx
make -j $(nproc)
mv / usr / sbin / nginx /usr/sbin/nginx.old
cp -prd objs / nginx / usr / sbin / nginx
nginx -sリロード

3、証明書のセキュリティテスト

最近、証明書には脆弱性がたくさんありますが、一部は履歴から残っていますが、日常の運用や保守では、強いセキュリティ意識と確かな基礎知識があり、脆弱性を発見して是正することで、未然に防ぐことができます。
いくつかの証明書の脆弱性をまとめましたが、誰もが空席を見つけて空席を埋めるためにブレインストーミングできることを願っています(証明書の脆弱性は360ブラウザーを使用することをお勧めします)。

まず、証明書自体の脆弱性
1.期限切れ
 の証明書を確認する方法は、WebページのURLの左上隅にある小さな緑色の鍵をクリックすることです(赤い×は証明書の脆弱性を示します)->証明書情報をクリックして、ルーチンの有効期間を確認します。有効期間は、本日より前の証明書の有効期限です。

9CJU6_4_I8〜VS21TE0DHKM0.png

2 @ XT''M〜$ F365] QW824OYF1.png

2.サーバー証明書が
   Webサイトと一致しません。つまり、適用された証明書はこのWebサイトには適用されません。たとえば、Webサイトはoos-nm-iam.ctyunapi.cnですが、証明書は* .oos-nm.ctyunapi.cnに発行されます。

Y6K20 {P6D} 962A%[0IK {5E3.png

3.証明書チェーンが不完全です。
   証明書は通常、ルート証明書+中間証明書(中間証明書がない場合もあります)+ WebサイトのSSL証明書で構成されます。
   不完全な証明書チェーンは主にAndroidブラウザーに影響し、Androidフォンにはプロンプトが表示されますが、PCブラウザーは通常は正常であり、それを検出するには2つの方法があります。
A. Linuxコマンドラインツールのopensslチェック、
   たとえば、内モンゴルのリソースプールAPIのURLを表示する
   openssl s_client -connect oos-nm.ctyunapi.cn:443
   は、2つのチェーンがあることを発見しました。

LS4B {VAA)N6〜LFDC_JIK9GF.png

 B.特別なWebサイトクエリを通じて、オンラインWebサイトhttps://myssl.com/をお勧めします。Webサイトアドレスを入力します。証明書チェーンが完全でない場合、テストレポートに反映されます。

1OD] ET} ES1QSIS〜UJMA77LO.png 

KZEFM @ XM_ @ 9X} IRL67WU)A8.png

4.証明書発行機関は合法ではありません。たとえば、GoogleとMozillaは2016年10月21日にウォトンが発行した証明書を信頼しなくなりました。ここでの証明書は、ルート証明書が違法であることを示しています。例として360証明書を取り上げます。

F14PMUE {N1E)7AWF6 $ [@ MKO.png

1:ルート証明書、
これはWotong証明書にはできません2:これはWotong証明書です。これは問題ではありません。これは、認証局ではなく仲介者の
証明書です3:サーバー証明書。

C5%JI〜} IQ [3A]] SE22FV $ HG.png

次に、証明書の暗号化プロトコルと暗号化スイートの
     暗号化プロトコル:
     httpsは、実際にはhttp + SSL / TLSの2つの部分で構成されます。これは、httpで暗号化された情報の処理モジュールのレイヤーを追加することです。サーバーとクライアントの両方での情報の送信はTLSによって暗号化されるため、送信されるデータは暗号化されたデータです。
     現在、sslv3およびsslv2プロトコルはクラックされており、推奨されなくなったため、より安全なTLSプロトコル(通常はtlsv1.2)を使用することをお勧めします。
     暗号化スイート:
     ブラウザーのアドレスバーにhttpsで始まるURLを入力すると、ブラウザーとサーバーの間で数百ミリ秒以内に大量の通信が発生します。これらの複雑なステップの最初のステップは、ブラウザとサーバー間の後続の通信で使用されるキーアルゴリズムをネゴシエートすることです。プロセスは次のとおりです。
ブラウザ
は、サポートする一連のCipher Suite(キーアルゴリズムスイート、以下Cipherと呼びます)[C1、C2、C3、…] サーバーに送信します。サーバーはすべてのブラウザの暗号を受信ますCipherの後に、サポートしているスイートと比較します。両方でサポートされているCipherを見つけたら、ブラウザに通知します。
ブラウザとサーバーは、以降の通信で一致するCipherを使用します。サーバーが一致するアルゴリズムを見つけられない場合、ブラウザー(Firefox 30を例にとると、以降の例で使用されるブラウザーはすべてこのバージョンのFirefoxです)はエラーメッセージを表示します。

     RC4、DHなどは、現在サポートされている暗号化スイートではサポートされていないため、これらのプロトコルは通常、暗号化スイートから削除されています。
     現在、さまざまなWebサーバーで構成されている暗号化プロトコルとスイートは異なります。haproxyで構成されている暗号化プロトコルとスイートは次のとおりです。

KBLAMFKNWDBB] GH} 0NG){MS.png

ssl-default-bind-options sslプロトコルを設定して、
sslv3 no-sslv3による
tlsv1.2 force-tlsv12の使用一般的に禁止し
ますssl-default-bind- ciphers 暗号スイート

ECDHE-RSA-AES128-GCM-SHA256に設定します:ECDHE:ECDH :AES:HIGH :! NULL :! ANULL :! MD5 :! ADH :! RC4 :! DH :! DHE 

おすすめ

転載: blog.51cto.com/yw666/2486637