0
0

More than 1 year has passed since last update.

CentOS 6.4 TLS1.2 対応

Posted at

IEのサポート期間も終了に近づき、TLS1.1 のWebページは参照できなくなるので、
CentOS6.4 で稼働するWebサービスをTLS1.2化する。

1.下調べ
  TLS1.2対応のライブラリ調査(いろいろググって)
  ・openssl 1.0.1e 以降
  ・nss 3.19.1-6以降

2.ライブラリアップデートの方法
  ソースコードからビルドする方法で考えていたが、依存するライブラリの適切なバージョンのソースコードが揃わなかったので、yum でインストールすることにした。

3.作業手順
  (1) yumリポジトリ変更
  (2) openssl および、nss のインストール
  (3) 各証明書の作成
  (4) apache コンフィグ修正と再起動
  (5) クライアントPCからの接続確認

4.作業内容
  (1) yumリポジトリ変更

/etc/yum.repos.d/CentOS-Base.repo
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
baseurl=http://ftp.iij.ad.jp/pub/linux/centos-vault/6.8/os/$basearch/

    [base],[updates],[extras],[centosplus],[contrib] 同じURLにする。

/etc/yum.repos.d/CentOS-CR.repo
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
baseurl=http://ftp.iij.ad.jp/pub/linux/centos-vault/6.8/os/$basearch/
/etc/yum.repos.d/epel.repo
#baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch
#mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch
baseurl=http://archives.fedoraproject.org/pub/archive/epel/6/SRPMS```

   [epel],[epel-debuginfo],[epel-source] 同じURLにする。

  (2) openssl および、nss のインストール
     まずは、 openssl のインストール

[root@localhost ~]# yum update openssl.x86_64
Loaded plugins: downloadonly, fastestmirror
Loading mirror speeds from cached hostfile
Setting up Update Process
:
snip
:
Updated:
  openssl.x86_64 0:1.0.1e-48.el6

Dependency Updated:
  openssl-devel.x86_64 0:1.0.1e-48.el6

Complete!
[root@localhost ~]# 

   openssl がバージョンアップできました。
   続けて nss インストール

[root@localhost ~]# yum update nss.x86_64
Loaded plugins: downloadonly, fastestmirror
Loading mirror speeds from cached hostfile
Setting up Update Process
:
snip
:
Updated:
  nss.x86_64 0:3.21.0-8.el6

Dependency Updated:
  nspr.x86_64 0:4.11.0-1.el6                        nss-softokn.x86_64 0:3.14.3-23.el6_7       nss-softokn-freebl.i686 0:3.14.3-23.el6_7
  nss-softokn-freebl.x86_64 0:3.14.3-23.el6_7       nss-sysinit.x86_64 0:3.21.0-8.el6          nss-tools.x86_64 0:3.21.0-8.el6
  nss-util.x86_64 0:3.21.0-2.el6

Complete!
[root@localhost ~]# 

   nss も無事インストール完了。
   適切なバージョンのリポジトリにしたので問題なしでしょう。

  (3) 各証明書の作成
    ① 秘密鍵の作成(hogehoge_sv.key)

[root@localhost ~]# cd /usr/local/certs/server
[root@localhost server]# openssl genrsa -des3 -out hogehoge_sv.key 2048
Generating RSA private key, 2048 bit long modulus
...............................................................................................................+++
......................................+++
e is 65537 (0x10001)
Enter pass phrase for hogehoge_sv.key:
Verifying - Enter pass phrase for hogehoge_sv.key:
[root@localhost server]#

    ② 証明書発行要求ファイル作成(hogehoge_sv.csr)

[root@localhost ~]# cd /usr/local/certs/server
[root@localhost server]# openssl req -new -key hogehoge_sv.key -out hogehoge_sv.csr
Enter pass phrase for hogehoge_sv.key:
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [XX]:JP
State or Province Name (full name) []:Hokkaido
Locality Name (eg, city) [Default City]:Oshamanbe
Organization Name (eg, company) [Default Company Ltd]:ManbeSystem's Co., Ltd.
Organizational Unit Name (eg, section) []:hoge
Common Name (eg, your name or your server's hostname) []:hoge
Email Address []:sample@oms.com

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
[root@localhost server]# 

    ③ SAN(Subject Alternative Name)ファイル作成(san.txt)
     SANを設定した自己署名証明書にするため、san.txtにアドレス指定したファイルを作成する。

[root@localhost ~]# cd /usr/local/certs/server
[root@localhost server]# cat san.txt
subjectAltName=IP:xxx.xxx.xxx.xxx
[root@localhost server]#

    ④ サーバ証明書の作成(hogehoge_sv.crt)

[root@localhost ~]# cd /usr/local/certs/server
[root@localhost server]# openssl x509 -days 365 -in hogehoge_sv.csr -out hogehoge_sv.crt -req -signkey hogehoge_sv.key -extfile san.txt
Signature ok
subject=/C=JP/ST=Hokkaido/L=Oshamanbe/O=ManbeSystem's Co., Ltd./OU=hoge/CN=hoge/emailAddress=sample@oms.com
Getting Private key
Enter pass phrase for hogehoge_sv.key:
[root@localhost server]# 

    ⑤ クライアント証明書の作成(hogehoge_sv.p12/hogehoge_sv.cer)

[root@localhost ~]# cd /usr/local/certs/server
[root@localhost server]# openssl pkcs12 -export -inkey hogehoge_sv.key -in hogehoge_sv.crt -out hogehoge_sv.p12 -name "hoge_hoge"
Enter pass phrase for hogehoge_sv.key:
Enter Export Password:
Verifying - Enter Export Password:
[root@localhost server]# 
[root@localhost server]# openssl pkcs12 -in hogehoge_sv.p12 -out hogehoge_sv.cer -clcerts
Enter Import Password:
MAC verified OK
Enter PEM pass phrase:
Verifying - Enter PEM pass phrase:
[root@localhost server]# 

  (4) apache コンフィグ修正と再起動
    ① コンフィグ修正

/etc/httpd/conf.d/ssl.conf
#SSLCertificateFile /usr/local/certs/server/server.crt
SSLCertificateFile /usr/local/certs/server/hogehoge_sv.crt
#SSLCertificateKeyFile /usr/local/certs/server/server.key
SSLCertificateKeyFile /usr/local/certs/server/hogehoge_sv.key

    作成したファイルに変更

/etc/httpd/conf.d/ssl.conf
SSLProtocol all -SSLv2

    SSLProtocol も all 指定ですべて有効に変更

    ② httpd 再起動

[root@localhost ~]# service httpd stop
Stopping httpd: [  OK  ]
[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# service httpd start
Starting httpd: Apache/2.2.15 mod_ssl/2.2.15 (Pass Phrase Dialog)
Some of your private key files are encrypted for security reasons.
In order to read them you have to provide the pass phrases.

Server hoge:443 (RSA)
Enter pass phrase:

OK: Pass Phrase Dialog successful.
[  OK  ]
[root@localhost ~]# 

  (5) クライアントPCからの接続確認
    作成した hogehoge_sv.cer をクライアントPCにインストール
    Edge, Chrome で TLS1.2 で接続できエラーなく表示(https-get)されたことを確認。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0