現象と原因
OpenVPNのバージョンが2.4になってからcrl.pemの有効期限を読み込むようになったようです。このため、crl.pemを作成してから30日(デフォルトのCRL有効期限)経過するとerror=CRL has expiredとなり、全ての接続を受け付けなくなります。
CRL有効期限経過時のOpenVPNサーバーのログは下記のようになります。
Mon Oct 23 21:27:31 2017 TLS: Initial packet from [AF_INET]xxx.xxx.xxx.xxx:xxxx, sid=xxxxxxxx xxxxxxxx
Mon Oct 23 21:27:31 2017 VERIFY ERROR: depth=0, error=CRL has expired: C=XX, ST=XXXXXXXX, L=XXXXXXXX, O=XXXXXXXX, OU=XXXXXXXX, CN=XXXXXXXX, name=XXXXXXXX, emailAddress=XXXXXXXX
Mon Oct 23 21:27:31 2017 OpenSSL: error:xxxxxxxx:SSL routines:SSL3_GET_CLIENT_CERTIFICATE:no certificate returned
Mon Oct 23 21:27:31 2017 TLS_ERROR: BIO read tls_read_plaintext error
Mon Oct 23 21:27:31 2017 TLS Error: TLS object -> incoming plaintext read error
Mon Oct 23 21:27:31 2017 TLS Error: TLS handshake failed
Mon Oct 23 21:27:31 2017 SIGUSR1[soft,tls-error] received, process restarting
Mon Oct 23 21:27:31 2017 Restart pause, 300 second(s)
バージョン2.4からcrl.pemを扱うライブラリopensslに変更された(2.3までは独自のライブラリ)ためとのことです。
対処方法
CRLの有効期限を10年(任意の期間でよい)にしてcrl.pemを再生成することで対処することができます。この後、30日経過しても問題なく接続できれば成功です。
/etc/openvpn/easy-rsa/openssl-1.0.0.cnf
easyrsa3では環境変数でCRL有効期限を設定可能ですが、easyrsa2には存在しないためopenssl設定ファイルを編集します(easyrsa2内に存在するopensslの設定ファイルは複数存在しますが、インストールされているOpenSSLのバージョンと同じ設定ファイルを編集します)。
[root@centos ~]# vim /etc/openvpn/easy-rsa/openssl-1.0.0.cnf #default_crl_days= 30 default_crl_days= 3650
crl.pemの再生成
crl.pemを生成するため、ダミーの証明書を作成してそれを失効させます。そして生成されたcrl.pemを/etc/openvpnにコピーしてOpenVPNを再起動することで解消されます。
[root@centos ~]# /etc/openvpn/easy-rsa/build-key dummy [root@centos ~]# /etc/openvpn/easy-rsa/revoke-full dummy [root@centos ~]# cp /etc/openvpn/easy-rsa/key/crl.pem /etc/openvpn [root@centos ~]# service openvpn restart
参考情報
- https://www.agilegroup.co.jp/technote/openvpn-regenerate-crl.html
- https://hacknote.jp/archives/28042/
OpenVPNのCRL有効期限が切れて接続不可となる場合の対処