0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

OpenVPN CA入れ替え (EasyRSA 2.0)

Posted at

ことの始まり

2015年に設定して、運用を開始したマイOpenVPNですが、最近、急にiPhone, iPadからアクセスすると、次のエラーがでるようになった。つながらないと、色々面倒なので、なおすことにした。

image.png

CAのhash algorithmが古いと言われてもなぁ、という感じ。

いまの内容を調べてみる

いまのCAの内容がどうなっているか、調べてみる

# openssl x509 -text -noout -in ca.crt

Signature Algorithmに"sha1WithRSAEncryption"と出てきて、どうやらSHA1を利用しているみたい。

Certificate:
    Data:
        Version: 3 (0x2)
        Serial Number:
            xx:xx:xx:xx:xx:xx:xx:xx
        Signature Algorithm: sha1WithRSAEncryption
        Issuer: C = XX, ST = XX, L = XX, O = XX, OU = XX, CN = XX, name = XX, emailAddress = XX
        Validity
            Not Before: Oct  4 XX:XX:XX 2015 GMT
            Not After : Oct  1 XX:XX:XX 2025 GMT
(snip)

これをSHA256とかSHA512に変えればいいのかな?

どうやって変える?

3.0のケースは、ぐぐると色々出てきました。

set_var EASYRSA_DIGEST "sha512"

easyRSA 2.0において、この書式で設定される項目は、なかったので、他の方法を考えることが必要。
build-ca といった、build-xxx から呼ばれているpkitoolを見ていみると引数に、sha1があったので、そこをsha512へ書き換えてみる

easy-rsa/2.0 $ diff pkitool.org pkitool
325c325
< 	$OPENSSL req $BATCH -days $CA_EXPIRE $NODES_REQ -new -newkey rsa:$KEY_SIZE -sha1 \
---
> 	$OPENSSL req $BATCH -days $CA_EXPIRE $NODES_REQ -new -newkey rsa:$KEY_SIZE -sha512 \
359c359
< 	        -in "$FN.csr" $CA_EXT -md sha1 -config "$KEY_CONFIG" ) && \
---
> 	        -in "$FN.csr" $CA_EXT -md sha512 -config "$KEY_CONFIG" ) && \

変えてみた

変えたあと、build-caが動くか確認

easy-rsa/2.0# ./build-ca
Generating a RSA private key
.............+++++
.............................+++++
writing new private key to 'ca.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]:
State or Province Name (full name) [xx]:
Locality Name (eg, city) [xx]:
Organization Name (eg, company) [xx]:
Organizational Unit Name (eg, section) [xx]:
Common Name (eg, your name or your server's hostname) [xx]:
Name [xx]:
Email Address [xx]:

無事に完走して、ca.crt, ca.keyができてました。 中身を確認します。

# openssl x509 -text -noout -in ca.crt 
Certificate:
    Data:
        Version: 3 (0x2)
        Serial Number:
            xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx
        Signature Algorithm: sha512WithRSAEncryption
        Issuer: C = xx, ST = xx, L = xx, O = xx, OU = xx, CN = xx CA, name = xx, emailAddress = xx
        Validity
            Not Before: Dec xx xx:xx:xx 2023 GMT
            Not After : Mar xx xx:xx:xx 2050 GMT

Signature Algorithが、sha512WithRSAEncryptionと変わっていることが確認できた。これで、目的達成。

結果

新しいCAに合わせて、デバイス用のovpnファイルを修正。その後アップロードしたところ、無事に接続。

image.png

よしよし

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?