【自宅VPN構築】#12 Windows 2019 Server Essentials 搭載 PC にOpenVPN Serverを設置しよう

【自宅VPN構築】#12 Windows 2019 Server Essentials 搭載 PC にOpenVPN Serverを設置しよう

Windows 2019 Server Essentials 搭載 PC にOpenVPN Serverを設置しよう

【自宅VPN構築】#12 Windows 2019 Server Essentials 搭載 PC にOpenVPN Serverを設置しよう
しらかば堂

こんにちは!しらかば堂(@shirakabado)です。

【自宅VPN構築】#11 自宅LANにOpenVPNを導入して外出先の Android スマホから自宅のNAS、Windows 10 搭載PCにアクセスしよう

この記事では外出先から自宅内にあるNASやWindows PCにリモートデスクトップ接続したいとお考えの方に、自宅の Windows 2019 Server Essentials 搭載 PC にOpenVPNサーバと認証局を設置する手順を紹介しています。

この記事を読んで頂くことで、読者の方には自宅の Windows 2019 Server Essentials 搭載 PC にOpenVPNサーバを設置し、認証局、鍵、証明書を作成するするための具体的手順を順を追ってわかりやすく理解することが出来ます。

それでは以下の項目を順に紹介していきます。

  • Windows Server 2019 Essentials の搭載PCにOpenVPN Serverを設置する手順
  • TLS認証鍵を作成する手順
  • 認証局、秘密鍵、証明書を作成する手順
【自宅VPN構築】#12 Windows 2019 Server Essentials 搭載 PC にOpenVPN Serverを設置しよう
しらかば堂

ここではOpenVPNを設置する PC のOSをWindows Server 2019 Essentials としていますが、常時起動さえされていればWindows 10でも共通なので自宅にWindows Server をお持ちでない方もご参考にして頂けると幸いです。

OpenVPN Serverを設置する手順

OpenSSLインストール

OpenSSLは、オープンソースで開発されたセキュリティーライブラリで、OpenVPNで使用される暗号化技術や認証に必要なセキュリティーライブラリを提供します。

OpenVPNは、OpenSSLを使用して、公開鍵暗号共通鍵暗号を使用した暗号化や、X.509証明書による認証を行うため、OpenVPNの実装に先立ち、OpenSSLをインストールする必要があります。

具体的には以下のサイトを参照して管理者権限Windows Server 2019 Essentials の搭載 PCに Win64 OpenSSL v3.0.8 ライトを画面の指示に従ってインストールします。

【自宅VPN構築】#12 Windows 2019 Server Essentials 搭載 PC にOpenVPN Serverを設置しよう
しらかば堂

ちなみにWindows Server 2019 Essentialsのインストール条件は64ビットプロセッサ(1.4 GHz以上)を搭載したPCなので、64ビット版を選択しています。

【自宅VPN構築】#12 Windows 2019 Server Essentials 搭載 PC にOpenVPN Serverを設置しよう
Shining Light Productions サイト(Google翻訳で和訳後)

環境変数 Path への OpenSSL 実行Path 追加

このインストールが終ると

  • C:\Program Files\OpenSSL-Win64\bin

配下に OpenSSL の実行ファイルがインストールされるので

【自宅VPN構築】#12 Windows 2019 Server Essentials 搭載 PC にOpenVPN Serverを設置しよう
OpenSSL の実行環境フォルダ


Windows > Windowsシステムツール >コントロールパネル > 環境変数を編集

から 環境変数(N)... をクリックし

【自宅VPN構築】#12 Windows 2019 Server Essentials 搭載 PC にOpenVPN Serverを設置しよう
システムのプロパティ画面


環境変数 Path に先ほどのパス名を設定し、OK ボタンを押します。

【自宅VPN構築】#12 Windows 2019 Server Essentials 搭載 PC にOpenVPN Serverを設置しよう
環境変数設定画面


すると、管理者権限で開いたコマンドプロンプト画面で、以下のように”openssl version“コマンドが使用可能になります。

C:\Windows\system32>openssl version
OpenSSL 3.0.8 7 Feb 2023 (Library: OpenSSL 3.0.8 7 Feb 2023)

C:\Windows\system32>


また “openssl help” でこのコマンドの有効なコマンドパラメータ、デジタル署名方式、暗号化方式が確認できます。

C:\Windows\system32>openssl help
help:

Standard commands
asn1parse         ca                ciphers           cmp
cms               crl               crl2pkcs7         dgst
dhparam           dsa               dsaparam          ec
ecparam           enc               engine            errstr
fipsinstall       gendsa            genpkey           genrsa
help              info              kdf               list
mac               nseq              ocsp              passwd
pkcs12            pkcs7             pkcs8             pkey
pkeyparam         pkeyutl           prime             rand
rehash            req               rsa               rsautl
s_client          s_server          s_time            sess_id
smime             speed             spkac             srp
storeutl          ts                verify            version
x509

Message Digest commands (see the `dgst' command for more details)
blake2b512        blake2s256        md4               md5
mdc2              rmd160            sha1              sha224
sha256            sha3-224          sha3-256          sha3-384
sha3-512          sha384            sha512            sha512-224
sha512-256        shake128          shake256          sm3

Cipher commands (see the `enc' command for more details)
aes-128-cbc       aes-128-ecb       aes-192-cbc       aes-192-ecb
aes-256-cbc       aes-256-ecb       aria-128-cbc      aria-128-cfb
aria-128-cfb1     aria-128-cfb8     aria-128-ctr      aria-128-ecb
aria-128-ofb      aria-192-cbc      aria-192-cfb      aria-192-cfb1
aria-192-cfb8     aria-192-ctr      aria-192-ecb      aria-192-ofb
aria-256-cbc      aria-256-cfb      aria-256-cfb1     aria-256-cfb8
aria-256-ctr      aria-256-ecb      aria-256-ofb      base64
bf                bf-cbc            bf-cfb            bf-ecb
bf-ofb            camellia-128-cbc  camellia-128-ecb  camellia-192-cbc
camellia-192-ecb  camellia-256-cbc  camellia-256-ecb  cast
cast-cbc          cast5-cbc         cast5-cfb         cast5-ecb
cast5-ofb         des               des-cbc           des-cfb
des-ecb           des-ede           des-ede-cbc       des-ede-cfb
des-ede-ofb       des-ede3          des-ede3-cbc      des-ede3-cfb
des-ede3-ofb      des-ofb           des3              desx
idea              idea-cbc          idea-cfb          idea-ecb
idea-ofb          rc2               rc2-40-cbc        rc2-64-cbc
rc2-cbc           rc2-cfb           rc2-ecb           rc2-ofb
rc4               rc4-40            seed              seed-cbc
seed-cfb          seed-ecb          seed-ofb          sm4-cbc
sm4-cfb           sm4-ctr           sm4-ecb           sm4-ofb


C:\Windows\system32>

openssl dgst‘は、OpenSSLコマンドが利用可能なデジタル署名を生成、検証、および表示するために使用されるコマンドです。

具体的には、SHA(Secure Hash Algorithm)ファミリーのハッシュ関数を使用して、メッセージダイジェストを計算するために使用されます。

このメッセージダイジェストは、任意の長さのデータを固定長の値に変換するプロセスであり、ハッシュ値とも呼ばれます。これにより、データの完全性を検証したり、一意性を確認したりすることができます。

‘openssl cipher‘は、暗号化アルゴリズムを表示するために使用されるコマンドです。

OpenSSLコマンドが利用可能な暗号化アルゴリズムにはさまざまなものがありますが、このコマンドを使用すると、以下のようにOpenSSLがサポートする全ての暗号化アルゴリズムのリストを表示することができます。

例えば、以下のように使用することができます。

openssl ciphers -v

これは、OpenSSLがサポートするすべての暗号化アルゴリズムを表示します。各暗号化アルゴリズムには、名前、鍵長、ブロックサイズ、および使用可能なパディング方法などの詳細が含まれます。

C:\Windows\system32>openssl ciphers -v
TLS_AES_256_GCM_SHA384         TLSv1.3 Kx=any      Au=any   Enc=AESGCM(256)            Mac=AEAD
TLS_CHACHA20_POLY1305_SHA256   TLSv1.3 Kx=any      Au=any   Enc=CHACHA20/POLY1305(256) Mac=AEAD
TLS_AES_128_GCM_SHA256         TLSv1.3 Kx=any      Au=any   Enc=AESGCM(128)            Mac=AEAD
ECDHE-ECDSA-AES256-GCM-SHA384  TLSv1.2 Kx=ECDH     Au=ECDSA Enc=AESGCM(256)            Mac=AEAD
ECDHE-RSA-AES256-GCM-SHA384    TLSv1.2 Kx=ECDH     Au=RSA   Enc=AESGCM(256)            Mac=AEAD
DHE-RSA-AES256-GCM-SHA384      TLSv1.2 Kx=DH       Au=RSA   Enc=AESGCM(256)            Mac=AEAD
ECDHE-ECDSA-CHACHA20-POLY1305  TLSv1.2 Kx=ECDH     Au=ECDSA Enc=CHACHA20/POLY1305(256) Mac=AEAD
ECDHE-RSA-CHACHA20-POLY1305    TLSv1.2 Kx=ECDH     Au=RSA   Enc=CHACHA20/POLY1305(256) Mac=AEAD
DHE-RSA-CHACHA20-POLY1305      TLSv1.2 Kx=DH       Au=RSA   Enc=CHACHA20/POLY1305(256) Mac=AEAD
ECDHE-ECDSA-AES128-GCM-SHA256  TLSv1.2 Kx=ECDH     Au=ECDSA Enc=AESGCM(128)            Mac=AEAD
ECDHE-RSA-AES128-GCM-SHA256    TLSv1.2 Kx=ECDH     Au=RSA   Enc=AESGCM(128)            Mac=AEAD
DHE-RSA-AES128-GCM-SHA256      TLSv1.2 Kx=DH       Au=RSA   Enc=AESGCM(128)            Mac=AEAD
ECDHE-ECDSA-AES256-SHA384      TLSv1.2 Kx=ECDH     Au=ECDSA Enc=AES(256)               Mac=SHA384
ECDHE-RSA-AES256-SHA384        TLSv1.2 Kx=ECDH     Au=RSA   Enc=AES(256)               Mac=SHA384
DHE-RSA-AES256-SHA256          TLSv1.2 Kx=DH       Au=RSA   Enc=AES(256)               Mac=SHA256
ECDHE-ECDSA-AES128-SHA256      TLSv1.2 Kx=ECDH     Au=ECDSA Enc=AES(128)               Mac=SHA256
ECDHE-RSA-AES128-SHA256        TLSv1.2 Kx=ECDH     Au=RSA   Enc=AES(128)               Mac=SHA256
DHE-RSA-AES128-SHA256          TLSv1.2 Kx=DH       Au=RSA   Enc=AES(128)               Mac=SHA256
ECDHE-ECDSA-AES256-SHA         TLSv1   Kx=ECDH     Au=ECDSA Enc=AES(256)               Mac=SHA1
ECDHE-RSA-AES256-SHA           TLSv1   Kx=ECDH     Au=RSA   Enc=AES(256)               Mac=SHA1
DHE-RSA-AES256-SHA             SSLv3   Kx=DH       Au=RSA   Enc=AES(256)               Mac=SHA1
ECDHE-ECDSA-AES128-SHA         TLSv1   Kx=ECDH     Au=ECDSA Enc=AES(128)               Mac=SHA1
ECDHE-RSA-AES128-SHA           TLSv1   Kx=ECDH     Au=RSA   Enc=AES(128)               Mac=SHA1
DHE-RSA-AES128-SHA             SSLv3   Kx=DH       Au=RSA   Enc=AES(128)               Mac=SHA1
RSA-PSK-AES256-GCM-SHA384      TLSv1.2 Kx=RSAPSK   Au=RSA   Enc=AESGCM(256)            Mac=AEAD
DHE-PSK-AES256-GCM-SHA384      TLSv1.2 Kx=DHEPSK   Au=PSK   Enc=AESGCM(256)            Mac=AEAD
RSA-PSK-CHACHA20-POLY1305      TLSv1.2 Kx=RSAPSK   Au=RSA   Enc=CHACHA20/POLY1305(256) Mac=AEAD
DHE-PSK-CHACHA20-POLY1305      TLSv1.2 Kx=DHEPSK   Au=PSK   Enc=CHACHA20/POLY1305(256) Mac=AEAD
ECDHE-PSK-CHACHA20-POLY1305    TLSv1.2 Kx=ECDHEPSK Au=PSK   Enc=CHACHA20/POLY1305(256) Mac=AEAD
AES256-GCM-SHA384              TLSv1.2 Kx=RSA      Au=RSA   Enc=AESGCM(256)            Mac=AEAD
PSK-AES256-GCM-SHA384          TLSv1.2 Kx=PSK      Au=PSK   Enc=AESGCM(256)            Mac=AEAD
PSK-CHACHA20-POLY1305          TLSv1.2 Kx=PSK      Au=PSK   Enc=CHACHA20/POLY1305(256) Mac=AEAD
RSA-PSK-AES128-GCM-SHA256      TLSv1.2 Kx=RSAPSK   Au=RSA   Enc=AESGCM(128)            Mac=AEAD
DHE-PSK-AES128-GCM-SHA256      TLSv1.2 Kx=DHEPSK   Au=PSK   Enc=AESGCM(128)            Mac=AEAD
AES128-GCM-SHA256              TLSv1.2 Kx=RSA      Au=RSA   Enc=AESGCM(128)            Mac=AEAD
PSK-AES128-GCM-SHA256          TLSv1.2 Kx=PSK      Au=PSK   Enc=AESGCM(128)            Mac=AEAD
AES256-SHA256                  TLSv1.2 Kx=RSA      Au=RSA   Enc=AES(256)               Mac=SHA256
AES128-SHA256                  TLSv1.2 Kx=RSA      Au=RSA   Enc=AES(128)               Mac=SHA256
ECDHE-PSK-AES256-CBC-SHA384    TLSv1   Kx=ECDHEPSK Au=PSK   Enc=AES(256)               Mac=SHA384
ECDHE-PSK-AES256-CBC-SHA       TLSv1   Kx=ECDHEPSK Au=PSK   Enc=AES(256)               Mac=SHA1
SRP-RSA-AES-256-CBC-SHA        SSLv3   Kx=SRP      Au=RSA   Enc=AES(256)               Mac=SHA1
SRP-AES-256-CBC-SHA            SSLv3   Kx=SRP      Au=SRP   Enc=AES(256)               Mac=SHA1
RSA-PSK-AES256-CBC-SHA384      TLSv1   Kx=RSAPSK   Au=RSA   Enc=AES(256)               Mac=SHA384
DHE-PSK-AES256-CBC-SHA384      TLSv1   Kx=DHEPSK   Au=PSK   Enc=AES(256)               Mac=SHA384
RSA-PSK-AES256-CBC-SHA         SSLv3   Kx=RSAPSK   Au=RSA   Enc=AES(256)               Mac=SHA1
DHE-PSK-AES256-CBC-SHA         SSLv3   Kx=DHEPSK   Au=PSK   Enc=AES(256)               Mac=SHA1
AES256-SHA                     SSLv3   Kx=RSA      Au=RSA   Enc=AES(256)               Mac=SHA1
PSK-AES256-CBC-SHA384          TLSv1   Kx=PSK      Au=PSK   Enc=AES(256)               Mac=SHA384
PSK-AES256-CBC-SHA             SSLv3   Kx=PSK      Au=PSK   Enc=AES(256)               Mac=SHA1
ECDHE-PSK-AES128-CBC-SHA256    TLSv1   Kx=ECDHEPSK Au=PSK   Enc=AES(128)               Mac=SHA256
ECDHE-PSK-AES128-CBC-SHA       TLSv1   Kx=ECDHEPSK Au=PSK   Enc=AES(128)               Mac=SHA1
SRP-RSA-AES-128-CBC-SHA        SSLv3   Kx=SRP      Au=RSA   Enc=AES(128)               Mac=SHA1
SRP-AES-128-CBC-SHA            SSLv3   Kx=SRP      Au=SRP   Enc=AES(128)               Mac=SHA1
RSA-PSK-AES128-CBC-SHA256      TLSv1   Kx=RSAPSK   Au=RSA   Enc=AES(128)               Mac=SHA256
DHE-PSK-AES128-CBC-SHA256      TLSv1   Kx=DHEPSK   Au=PSK   Enc=AES(128)               Mac=SHA256
RSA-PSK-AES128-CBC-SHA         SSLv3   Kx=RSAPSK   Au=RSA   Enc=AES(128)               Mac=SHA1
DHE-PSK-AES128-CBC-SHA         SSLv3   Kx=DHEPSK   Au=PSK   Enc=AES(128)               Mac=SHA1
AES128-SHA                     SSLv3   Kx=RSA      Au=RSA   Enc=AES(128)               Mac=SHA1
PSK-AES128-CBC-SHA256          TLSv1   Kx=PSK      Au=PSK   Enc=AES(128)               Mac=SHA256
PSK-AES128-CBC-SHA             SSLv3   Kx=PSK      Au=PSK   Enc=AES(128)               Mac=SHA1

C:\Windows\system32>
【自宅VPN構築】#12 Windows 2019 Server Essentials 搭載 PC にOpenVPN Serverを設置しよう
しらかば堂

この記事は主に以下の参考図書を参考にして記載しています。
洋書ですが今は ChatGPT などで気軽に翻訳、関連情報が検索できるので、以外に簡単に読めますよ。OpenVPNを極めたい方にはお勧めの一冊です。

OpenVPNインストール

OpenVPNは、オープンソースで開発された、安全なリモートアクセスおよびサイト間VPN接続を提供するソフトウェアで、TCPまたはUDPプロトコル上のTLS(Transport Layer Security)プロトコルを使用して暗号化されたトンネルを作成し、リモートアクセスやサイト間の安全な通信を提供します。

OpenVPNは、クロスプラットフォームで動作し、Linux、Windows、macOS、Android、iOSなどのさまざまなオペレーティングシステムで利用することができます。また、多くのセキュリティ機能を備えており、認証、暗号化、アクセス制御などの機能を提供します。

ここでは Windows Server 2019 Essentials 上にこのOpenVPN をインストールし、サーバとして動作させます。

具体的にはOpenVPN.JPが提供する

を参照してOpenVPNをインストールします。

環境変数 Path への OpenVPN 実行Path 追加

このインストールが終ると

C:\Program Files\OpenVPN\bin

配下に OpenVPN の実行ファイルがインストールされるので同様に

Windows > Windowsシステムツール >コントロールパネル > 環境変数を編集

から 環境変数の編集 画面を起動し、こちらもインストールパスを環境変数 Path に追加します。

具体的には先ほど同様 環境変数の Path をマウスで選択し、編集ボタンをクリックして

【自宅VPN構築】#12 Windows 2019 Server Essentials 搭載 PC にOpenVPN Serverを設置しよう
環境変数編集画面


現れる以下の画面で 新規(N) ボタンをクリックし、”C:\Program Files\OpenVPN\bin” を追加して OK ボタンをクリックすると

【自宅VPN構築】#12 Windows 2019 Server Essentials 搭載 PC にOpenVPN Serverを設置しよう
環境変数 Path の編集画面


環境変数 Path に “C:\Program Files\OpenVPN\bin” 追加されますので OK ボタンをクリックしてこの画面を閉じます。

【自宅VPN構築】#12 Windows 2019 Server Essentials 搭載 PC にOpenVPN Serverを設置しよう
環境変数画面


環境変数 Path への “C:\Program Files\OpenVPN\bin” 追加が終わると管理者権限でのコマンドラインで “openvpn –version” コマンドが使えるようになりました。

C:\Windows\system32>openvpn --version
OpenVPN 2.6.0 [git:v2.6.0/b999466418dddb89] Windows-MSVC [SSL (OpenSSL)] [LZO] [LZ4] [PKCS11] [AEAD] [DCO] built on Jan 25 2023
library versions: OpenSSL 3.0.7 1 Nov 2022, LZO 2.10
Windows version 10.0 (Windows 10 or greater), amd64 executable
Originally developed by James Yonan
Copyright (C) 2002-2023 OpenVPN Inc <sales@openvpn.net>
Compile time defines: N/A

C:\Windows\system32>

 


また “openvpn –help” でこのopenvpnコマンドの有効なコマンドパラメータ、デジタル署名方式、暗号化方式が確認できます。

これらのコマンドパラメータはコマンドラインから直接投入することもできますが、通常は

C:\Program Files\OpenVPN\config

配下に保存されたコンフィグファイルの中で “” なしで指定されます。

【自宅VPN構築】#12 Windows 2019 Server Essentials 搭載 PC にOpenVPN Serverを設置しよう
しらかば堂

逆に言えばこの “openvpn –help” の結果はコンフィグファイルの中でどんなパラメータが使用可能なのかを示しているとも言えます。

C:\Users\Administrator.RVHAD01>openvpn --help
OpenVPN 2.6.0 [git:v2.6.0/b999466418dddb89] Windows-MSVC [SSL (OpenSSL)] [LZO] [LZ4] [PKCS11] [AEAD] [DCO] built on Jan 25 2023

General Options:
--config file   : Read configuration options from file.
--help          : Show options.
--version       : Show copyright and version information.

Tunnel Options:
--local host    : Local host name or ip address. Implies --bind.
--remote host [port] : Remote host name or ip address.
--remote-random : If multiple --remote options specified, choose one randomly.
--remote-random-hostname : Add a random string to remote DNS name.
--mode m        : Major mode, m = 'p2p' (default, point-to-point) or 'server'.
--proto p       : Use protocol p for communicating with peer.
                  p = udp (default), tcp-server, tcp-client
                      udp4, tcp4-server, tcp4-client
                      udp6, tcp6-server, tcp6-client
--proto-force p : only consider protocol p in list of connection profiles.
                  p = udp or tcp
--connect-retry n [m] : For client, number of seconds to wait between
                  connection retries (default=1). On repeated retries
                  the wait time is exponentially increased to a maximum of m
                  (default=300).
--connect-retry-max n : Maximum connection attempt retries, default infinite.
--http-proxy s p [up] [auth] : Connect to remote host
                  through an HTTP proxy at address s and port p.
                  If proxy authentication is required,
                  up is a file containing username/password on 2 lines, or
                  'stdin' to prompt from console.  Add auth='ntlm' if
                  the proxy requires NTLM authentication.
--http-proxy s p 'auto[-nct]' : Like the above directive, but automatically
                  determine auth method and query for username/password
                  if needed.  auto-nct disables weak proxy auth methods.
--http-proxy-option type [parm] : Set extended HTTP proxy options.
                                  Repeat to set multiple options.
                  VERSION version (default=1.0)
                  AGENT user-agent
--socks-proxy s [p] [up] : Connect to remote host through a Socks5 proxy at
                  address s and port p (default port = 1080).
                  If proxy authentication is required,
                  up is a file containing username/password on 2 lines, or
                  'stdin' to prompt for console.
--socks-proxy-retry : Retry indefinitely on Socks proxy errors.
--resolv-retry n: If hostname resolve fails for --remote, retry
                  resolve for n seconds before failing (disabled by default).
                  Set n="infinite" to retry indefinitely.
--float         : Allow remote to change its IP address/port, such as through
                  DHCP (this is the default if --remote is not used).
--ipchange cmd  : Run command cmd on remote ip address initial
                  setting or change -- execute as: cmd ip-address port#
--port port     : TCP/UDP port # for both local and remote.
--lport port    : TCP/UDP port # for local (default=1194). Implies --bind.
--rport port    : TCP/UDP port # for remote (default=1194).
--bind          : Bind to local address and port. (This is the default unless
                  --proto tcp-client or --http-proxy or --socks-proxy is used).
--nobind        : Do not bind to local address and port.
--dev tunX|tapX : tun/tap device (X can be omitted for dynamic device.
--dev-type dt   : Which device type are we using? (dt = tun or tap) Use
                  this option only if the tun/tap device used with --dev
                  does not begin with "tun" or "tap".
--dev-node node : Explicitly set the device node rather than using
                  /dev/net/tun, /dev/tun, /dev/tap, etc.
--disable-dco   : Do not attempt using Data Channel Offload.
--lladdr hw     : Set the link layer address of the tap device.
--topology t    : Set --dev tun topology: 'net30', 'p2p', or 'subnet'.
--ifconfig l rn : TUN: configure device to use IP address l as a local
                  endpoint and rn as a remote endpoint.  l & rn should be
                  swapped on the other peer.  l & rn must be private
                  addresses outside of the subnets used by either peer.
                  TAP: configure device to use IP address l as a local
                  endpoint and rn as a subnet mask.
--ifconfig-ipv6 l r : configure device to use IPv6 address l as local
                      endpoint (as a /64) and r as remote endpoint
--ifconfig-noexec : Don't actually execute ifconfig/netsh command, instead
                    pass --ifconfig parms by environment to scripts.
--ifconfig-nowarn : Don't warn if the --ifconfig option on this side of the
                    connection doesn't match the remote side.
--route network [netmask] [gateway] [metric] :
                  Add route to routing table after connection
                  is established.  Multiple routes can be specified.
                  netmask default: 255.255.255.255
                  gateway default: taken from --route-gateway or --ifconfig
                  Specify default by leaving blank or setting to "default".
--route-ipv6 network/bits [gateway] [metric] :
                  Add IPv6 route to routing table after connection
                  is established.  Multiple routes can be specified.
                  gateway default: taken from --route-ipv6-gateway or 'remote'
                  in --ifconfig-ipv6
--route-gateway gw|'dhcp' : Specify a default gateway for use with --route.
--route-ipv6-gateway gw : Specify a default gateway for use with --route-ipv6.
--route-metric m : Specify a default metric for use with --route.
--route-delay n [w] : Delay n seconds after connection initiation before
                  adding routes (may be 0).  If not specified, routes will
                  be added immediately after tun/tap open.  On Windows, wait
                  up to w seconds for TUN/TAP adapter to come up.
--route-up cmd  : Run command cmd after routes are added.
--route-pre-down cmd : Run command cmd before routes are removed.
--route-noexec  : Don't add routes automatically.  Instead pass routes to
                  --route-up script using environmental variables.
--route-nopull  : When used with --client or --pull, accept options pushed
                  by server EXCEPT for routes, dns, and dhcp options.
--allow-pull-fqdn : Allow client to pull DNS names from server for
                    --ifconfig, --route, and --route-gateway.
--redirect-gateway [flags]: Automatically execute routing
                  commands to redirect all outgoing IP traffic through the
                  VPN.  Add 'local' flag if both OpenVPN servers are directly
                  connected via a common subnet, such as with WiFi.
                  Add 'def1' flag to set default route using using 0.0.0.0/1
                  and 128.0.0.0/1 rather than 0.0.0.0/0.  Add 'bypass-dhcp'
                  flag to add a direct route to DHCP server, bypassing tunnel.
                  Add 'bypass-dns' flag to similarly bypass tunnel for DNS.
--redirect-private [flags]: Like --redirect-gateway, but omit actually changing
                  the default gateway.  Useful when pushing private subnets.
--block-ipv6     : (Client) Instead sending IPv6 to the server generate
                   ICMPv6 host unreachable messages on the client.
                   (Server) Instead of forwarding IPv6 packets send
                   ICMPv6 host unreachable packets to the client.
--client-nat snat|dnat network netmask alias : on client add 1-to-1 NAT rule.
--push-peer-info : (client only) push client info to server.
--setenv name value : Set a custom environmental variable to pass to script.
--setenv FORWARD_COMPATIBLE 1 : Relax config file syntax checking to allow
                  directives for future OpenVPN versions to be ignored.
--ignore-unkown-option opt1 opt2 ...: Relax config file syntax. Allow
                  these options to be ignored when unknown
--script-security level: Where level can be:
                  0 -- strictly no calling of external programs
                  1 -- (default) only call built-ins such as ifconfig
                  2 -- allow calling of built-ins and scripts
                  3 -- allow password to be passed to scripts via env
--shaper n      : Restrict output to peer to n bytes per second.
--keepalive n m : Helper option for setting timeouts in server mode.  Send
                  ping once every n seconds, restart if ping not received
                  for m seconds.
--inactive n [bytes] : Exit after n seconds of activity on tun/tap device
                  produces a combined in/out byte count < bytes.
--session-timeout n: Limit connection time to n seconds.
--ping-exit n   : Exit if n seconds pass without reception of remote ping.
--ping-restart n: Restart if n seconds pass without reception of remote ping.
--ping-timer-rem: Run the --ping-exit/--ping-restart timer only if we have a
                  remote address.
--ping n        : Ping remote once every n seconds over TCP/UDP port.
--fast-io       : (experimental) Optimize TUN/TAP/UDP writes.
--remap-usr1 s  : On SIGUSR1 signals, remap signal (s='SIGHUP' or 'SIGTERM').
--persist-tun   : Keep tun/tap device open across SIGUSR1 or --ping-restart.
--persist-remote-ip : Keep remote IP address across SIGUSR1 or --ping-restart.
--persist-local-ip  : Keep local IP address across SIGUSR1 or --ping-restart.
--persist-key   : Don't re-read key files across SIGUSR1 or --ping-restart.
--passtos       : TOS passthrough (applies to IPv4 only).
--tun-mtu n     : Take the tun/tap device MTU to be n and derive the
                  TCP/UDP MTU from it (default=1500).
--tun-mtu-extra n : Assume that tun/tap device might return as many
                  as n bytes more than the tun-mtu size on read
                  (default TUN=0 TAP=32).
--link-mtu n    : Take the TCP/UDP device MTU to be n and derive the tun MTU
                  from it.
--mtu-disc type : Should we do Path MTU discovery on TCP/UDP channel?
                  'no'    -- Never send DF (Don't Fragment) frames
                  'maybe' -- Use per-route hints
                  'yes'   -- Always DF (Don't Fragment)
--mtu-test      : Empirically measure and report MTU.
--fragment max  : Enable internal datagram fragmentation so that no UDP
                  datagrams are sent which are larger than max bytes.
                  Adds 4 bytes of overhead per datagram.
--mssfix [n]    : Set upper bound on TCP MSS, default = tun-mtu size
                  or --fragment max value, whichever is lower.
--sndbuf size   : Set the TCP/UDP send buffer size.
--rcvbuf size   : Set the TCP/UDP receive buffer size.
--txqueuelen n  : Set the tun/tap TX queue length to n (Linux only).
--mlock         : Disable Paging -- ensures key material and tunnel
                  data will never be written to disk.
--up cmd        : Run command cmd after successful tun device open.
                  Execute as: cmd tun/tap-dev tun-mtu link-mtu \
                              ifconfig-local-ip ifconfig-remote-ip
                  (pre --user or --group UID/GID change)
--up-delay      : Delay tun/tap open and possible --up script execution
                  until after TCP/UDP connection establishment with peer.
--down cmd      : Run command cmd after tun device close.
                  (post --user/--group UID/GID change and/or --chroot)
                  (command parameters are same as --up option)
--down-pre      : Run --down command before TUN/TAP close.
--up-restart    : Run up/down commands for all restarts including those
                  caused by --ping-restart or SIGUSR1
--user user     : Set UID to user after initialization.
--group group   : Set GID to group after initialization.
--chroot dir    : Chroot to this directory after initialization.
--cd dir        : Change to this directory before initialization.
--daemon [name] : Become a daemon after initialization.
                  The optional 'name' parameter will be passed
                  as the program name to the system logger.
--syslog [name] : Output to syslog, but do not become a daemon.
                  See --daemon above for a description of the 'name' parm.
--log file      : Output log to file which is created/truncated on open.
--log-append file : Append log to file, or create file if nonexistent.
--suppress-timestamps : Don't log timestamps to stdout/stderr.
--machine-readable-output : Always log timestamp, message flags to stdout/stderr.
--writepid file : Write main process ID to file.
--nice n        : Change process priority (>0 = lower, <0 = higher).
--echo [parms ...] : Echo parameters to log output.
--verb n        : Set output verbosity to n (default=1):
                  (Level 3 is recommended if you want a good summary
                  of what's happening without being swamped by output).
                : 0 -- no output except fatal errors
                : 1 -- startup info + connection initiated messages +
                       non-fatal encryption & net errors
                : 2,3 -- show TLS negotiations & route info
                : 4 -- show parameters
                : 5 -- show 'RrWw' chars on console for each packet sent
                       and received from TCP/UDP (caps) or tun/tap (lc)
                : 6 to 11 -- debug messages of increasing verbosity
--mute n        : Log at most n consecutive messages in the same category.
--status file [n] : Write operational status to file every n seconds.
--status-version [n] : Choose the status file format version number.
                  Currently, n can be 1, 2, or 3 (default=1).
--disable-occ   : (DEPRECATED) Disable options consistency check between peers.
--compress alg  : Use compression algorithm alg
--allow-compression: Specify whether compression should be allowed
--comp-lzo      : Use LZO compression -- may add up to 1 byte per
                  packet for incompressible data.
--comp-noadapt  : Don't use adaptive compression when --comp-lzo
                  is specified.
--management ip port [pass] : Enable a TCP server on ip:port to handle
                  management functions.  pass is a password file
                  or 'stdin' to prompt from console.
--management-client : Management interface will connect as a TCP client to
                      ip/port rather than listen as a TCP server.
--management-query-passwords : Query management channel for private key
                  and auth-user-pass passwords.
--management-query-proxy : Query management channel for proxy information.
--management-query-remote : Query management channel for --remote directive.
--management-hold : Start OpenVPN in a hibernating state, until a client
                    of the management interface explicitly starts it.
--management-signal : Issue SIGUSR1 when management disconnect event occurs.
--management-forget-disconnect : Forget passwords when management disconnect
                                 event occurs.
--management-up-down : Report tunnel up/down events to management interface.
--management-log-cache n : Cache n lines of log file history for usage
                  by the management channel.
--management-client-auth : gives management interface client the responsibility
                           to authenticate clients after their client certificate
                              has been verified.
--plugin m [str]: Load plug-in module m passing str as an argument
                  to its initialization function.
--vlan-tagging  : Enable 802.1Q-based VLAN tagging.
--vlan-accept tagged|untagged|all : Set VLAN tagging mode. Default is 'all'.
--vlan-pvid v   : Sets the Port VLAN Identifier. Defaults to 1.

Multi-Client Server options (when --mode server is used):
--server network netmask : Helper option to easily configure server mode.
--server-ipv6 network/bits : Configure IPv6 server mode.
--server-bridge [IP netmask pool-start-IP pool-end-IP] : Helper option to
                    easily configure ethernet bridging server mode.
--push "option" : Push a config file option back to the peer for remote
                  execution.  Peer must specify --pull in its config file.
--push-reset    : Don't inherit global push list for specific
                  client instance.
--push-remove opt : Remove options matching 'opt' from the push list for
                  a specific client instance.
--ifconfig-pool start-IP end-IP [netmask] : Set aside a pool of subnets
                  to be dynamically allocated to connecting clients.
--ifconfig-pool-persist file [seconds] : Persist/unpersist ifconfig-pool
                  data to file, at seconds intervals (default=600).
                  If seconds=0, file will be treated as read-only.
--ifconfig-ipv6-pool base-IP/bits : set aside an IPv6 network block
                  to be dynamically allocated to connecting clients.
--ifconfig-push local remote-netmask : Push an ifconfig option to remote,
                  overrides --ifconfig-pool dynamic allocation.
                  Only valid in a client-specific config file.
--ifconfig-ipv6-push local/bits remote : Push an ifconfig-ipv6 option to
                  remote, overrides --ifconfig-ipv6-pool allocation.
                  Only valid in a client-specific config file.
--iroute network [netmask] : Route subnet to client.
--iroute-ipv6 network/bits : Route IPv6 subnet to client.
                  Sets up internal routes only.
                  Only valid in a client-specific config file.
--disable       : Client is disabled.
                  Only valid in a client-specific config file.
--verify-client-cert [none|optional|require] : perform no, optional or
                  mandatory client certificate verification.
                  Default is to require the client to supply a certificate.
--username-as-common-name  : For auth-user-pass authentication, use
                  the authenticated username as the common name,
                  rather than the common name from the client cert.
--auth-user-pass-verify cmd method: Query client for username/password and
                  run command cmd to verify.  If method='via-env', pass
                  user/pass via environment, if method='via-file', pass
                  user/pass via temporary file.
--auth-gen-token  [lifetime] Generate a random authentication token which is pushed
                  to each client, replacing the password.  Useful when
                  OTP based two-factor auth mechanisms are in use and
                  --reneg-* options are enabled. Optionally a lifetime in seconds
                  for generated tokens can be set.
--opt-verify    : (DEPRECATED) Clients that connect with options that are incompatible
                  with those of the server will be disconnected.
--auth-user-pass-optional : Allow connections by clients that don't
                  specify a username/password.
--no-name-remapping : (DEPRECATED) Allow Common Name and X509 Subject to include
                      any printable character.
--client-to-client : Internally route client-to-client traffic.
--duplicate-cn  : Allow multiple clients with the same common name to
                  concurrently connect.
--client-connect cmd : Run command cmd on client connection.
--client-disconnect cmd : Run command cmd on client disconnection.
--client-config-dir dir : Directory for custom client config files.
--ccd-exclusive : Refuse connection unless custom client config is found.
--tmp-dir dir   : Temporary directory, used for --client-connect return file and plugin communication.
--hash-size r v : Set the size of the real address hash table to r and the
                  virtual address table to v.
--bcast-buffers n : Allocate n broadcast buffers.
--tcp-queue-limit n : Maximum number of queued TCP output packets.
--tcp-nodelay   : Macro that sets TCP_NODELAY socket flag on the server
                  as well as pushes it to connecting clients.
--learn-address cmd : Run command cmd to validate client virtual addresses.
--connect-freq n s : Allow a maximum of n new connections per s seconds.
--connect-freq-initial n s : Allow a maximum of n replies for initial connections attempts per s seconds.
--max-clients n : Allow a maximum of n simultaneously connected clients.
--max-routes-per-client n : Allow a maximum of n internal routes per client.
--stale-routes-check n [t] : Remove routes with a last activity timestamp
                             older than n seconds. Run this check every t
                             seconds (defaults to n).
--explicit-exit-notify [n] : In UDP server mode send [RESTART] command on exit/restart to connected
                             clients. n = 1 - reconnect to same server,
                             2 - advance to next server, default=1.

Client options (when connecting to a multi-client server):
--client         : Helper option to easily configure client mode.
--auth-user-pass [up] : Authenticate with server using username/password.
                  up is a file containing the username on the first line,
                  and a password on the second. If either the password or both
                  the username and the password are omitted OpenVPN will prompt
                  for them from console.
--pull           : Accept certain config file options from the peer as if they
                  were part of the local config file.  Must be specified
                  when connecting to a '--mode server' remote host.
--pull-filter accept|ignore|reject t : Filter each option received from the
                  server if it starts with the text t. The action flag accept,
                  ignore or reject causes the option to be allowed, removed or
                  rejected with error. May be specified multiple times, and
                  each filter is applied in the order of appearance.
--dns server <n> <option> <value> [value ...] : Configure option for DNS server #n
                  Valid options are :
                  address <addr[:port]> [addr[:port]] : server address 4/6
                  resolve-domains <domain> [domain ...] : split domains
                  exclude-domains <domain> [domain ...] : domains not to resolve
                  dnssec <yes|no|optional> : option to use DNSSEC
                  type <DoH|DoT> : query server over HTTPS / TLS
                  sni <domain> : DNS server name indication
--dns search-domains <domain> [domain ...]:
                  Add domains to DNS domain search list
--auth-retry t  : How to handle auth failures.  Set t to
                  none (default), interact, or nointeract.
--static-challenge t e : Enable static challenge/response protocol using
                  challenge text t, with e indicating echo flag (0|1)
--connect-timeout n : when polling possible remote servers to connect to
                  in a round-robin fashion, spend no more than n seconds
                  waiting for a response before trying the next server.
--allow-recursive-routing : When this option is set, OpenVPN will not drop
                  incoming tun packets with same destination as host.
--explicit-exit-notify [n] : On exit/restart, send exit signal to
                  server/remote. n = # of retries, default=1.

Data Channel Encryption Options (must be compatible between peers):
(These options are meaningful for both Static Key & TLS-mode)
--secret f [d]  : (DEPRECATED) Enable Static Key encryption mode (non-TLS).
                  Use shared secret file f, generate with --genkey.
                  The optional d parameter controls key directionality.
                  If d is specified, use separate keys for each
                  direction, set d=0 on one side of the connection,
                  and d=1 on the other side.
--auth alg      : Authenticate packets with HMAC using message
                  digest algorithm alg (default=SHA1).
                  (usually adds 16 or 20 bytes per packet)
                  Set alg=none to disable authentication.
--cipher alg    : Encrypt packets with cipher algorithm alg.
                  You should usually use --data-ciphers instead.
                  Set alg=none to disable encryption.
--data-ciphers list : List of ciphers that are allowed to be negotiated.
--engine [name] : Enable OpenSSL hardware crypto engine functionality.
--no-replay     : (DEPRECATED) Disable replay protection.
--mute-replay-warnings : Silence the output of replay warnings to log file.
--replay-window n [t]  : Use a replay protection sliding window of size n
                         and a time window of t seconds.
                         Default n=64 t=15
--replay-persist file : Persist replay-protection state across sessions
                  using file.
--test-crypto   : Run a self-test of crypto features enabled.
                  For debugging only.

TLS Key Negotiation Options:
(These options are meaningful only for TLS-mode)
--tls-server    : Enable TLS and assume server role during TLS handshake.
--tls-client    : Enable TLS and assume client role during TLS handshake.
--key-method m  : (DEPRECATED) Data channel key exchange method.  m should be a method
                  number, such as 1 (default), 2, etc.
--ca file       : Certificate authority file in .pem format containing
                  root certificate.
--capath dir    : A directory of trusted certificates (CAs and CRLs).
--dh file       : File containing Diffie Hellman parameters
                  in .pem format (for --tls-server only).
                  Use "openssl dhparam -out dh1024.pem 1024" to generate.
--cert file     : Local certificate in .pem format -- must be signed
                  by a Certificate Authority in --ca file.
--extra-certs file : one or more PEM certs that complete the cert chain.
--key file      : Local private key in .pem format.
--tls-version-min <version> ['or-highest'] : sets the minimum TLS version we
    will accept from the peer.  If version is unrecognized and 'or-highest'
    is specified, require max TLS version supported by SSL implementation.
--tls-version-max <version> : sets the maximum TLS version we will use.
--pkcs12 file   : PKCS#12 file containing local private key, local certificate
                  and optionally the root CA certificate.
--verify-hash hash [algo] : Specify fingerprint for level-1 certificate.
                            Valid algo flags are SHA1 and SHA256.
--cryptoapicert select-string : Load the certificate and private key from the
                  Windows Certificate System Store.
--tls-cipher l  : A list l of allowable TLS ciphers separated by : (optional).
--tls-ciphersuites l: A list of allowed TLS 1.3 cipher suites seperated by : (optional)
                : Use --show-tls to see a list of supported TLS ciphers (suites).
--tls-cert-profile p : Set the allowed certificate crypto algorithm profile
                  (default=legacy).
--providers l   : A list l of OpenSSL providers to load.
--tls-timeout n : Packet retransmit timeout on TLS control channel
                  if no ACK from remote within n seconds (default=2).
--reneg-bytes n : Renegotiate data chan. key after n bytes sent and recvd.
--reneg-pkts n  : Renegotiate data chan. key after n packets sent and recvd.
--reneg-sec max [min] : Renegotiate data chan. key after at most max (default=3600)
                  and at least min (defaults to 90% of max on servers and equal
                  to max on clients).
--hand-window n : Data channel key exchange must finalize within n seconds
                  of handshake initiation by any peer (default=60).
--tran-window n : Transition window -- old key can live this many seconds
                  after new key renegotiation begins (default=3600).
--single-session: Allow only one session (reset state on restart).
--tls-exit      : Exit on TLS negotiation failure.
--tls-auth f [d]: Add an additional layer of authentication on top of the TLS
                  control channel to protect against attacks on the TLS stack
                  and DoS attacks.
                  f (required) is a shared-secret key file.
                  The optional d parameter controls key directionality,
                  see --secret option for more info.
--tls-crypt key : Add an additional layer of authenticated encryption on top
                  of the TLS control channel to hide the TLS certificate,
                  provide basic post-quantum security and protect against
                  attacks on the TLS stack and DoS attacks.
                  key (required) provides the pre-shared key file.
                  see --secret option for more info.
--tls-crypt-v2 key : For clients: use key as a client-specific tls-crypt key.
                  For servers: use key to decrypt client-specific keys.  For
                  key generation (--genkey tls-crypt-v2-client): use key to
                  encrypt generated client-specific key.  (See --tls-crypt.)
--genkey tls-crypt-v2-client [keyfile] [base64 metadata]: Generate a
                  fresh tls-crypt-v2 client key, and store to
                  keyfile.  If supplied, include metadata in wrapped key.
--genkey tls-crypt-v2-server [keyfile] [base64 metadata]: Generate a
                  fresh tls-crypt-v2 server key, and store to keyfile
--tls-crypt-v2-verify cmd : Run command cmd to verify the metadata of the
                  client-supplied tls-crypt-v2 client key
--askpass [file]: Get PEM password from controlling tty before we daemonize.
--auth-nocache  : Don't cache --askpass or --auth-user-pass passwords.
--crl-verify crl ['dir']: Check peer certificate against a CRL.
--tls-verify cmd: Run command cmd to verify the X509 name of a
                  pending TLS connection that has otherwise passed all other
                  tests of certification.  cmd should return 0 to allow
                  TLS handshake to proceed, or 1 to fail.  (cmd is
                  executed as 'cmd certificate_depth subject')
--tls-export-cert [directory] : Get peer cert in PEM format and store it
                  in an openvpn temporary file in [directory]. Peer cert is
                  stored before tls-verify script execution and deleted after.
--verify-x509-name name: Accept connections only from a host with X509 subject
                  DN name. The remote host must also pass all other tests
                  of verification.
--ns-cert-type t: (DEPRECATED) Require that peer certificate was signed with
                  an explicit nsCertType designation t = 'client' | 'server'.
--x509-track x  : Save peer X509 attribute x in environment for use by
                  plugins and management interface.
--keying-material-exporter label len : Save Exported Keying Material (RFC5705)
                  of len bytes (min. 16 bytes) using label in environment for use by plugins.
--remote-cert-ku v ... : Require that the peer certificate was signed with
                  explicit key usage, you can specify more than one value.
                  value should be given in hex format.
--remote-cert-eku oid : Require that the peer certificate was signed with
                  explicit extended key usage. Extended key usage can be encoded
                  as an object identifier or OpenSSL string representation.
--remote-cert-tls t: Require that peer certificate was signed with explicit
                  key usage and extended key usage based on RFC3280 TLS rules.
                  t = 'client' | 'server'.

PKCS#11 Options:
--pkcs11-providers provider ... : PKCS#11 provider to load.
--pkcs11-protected-authentication [0|1] ... : Use PKCS#11 protected authentication
                              path. Set for each provider.
--pkcs11-private-mode hex ...   : PKCS#11 private key mode mask.
                              0       : Try  to determine automatically (default).
                              1       : Use Sign.
                              2       : Use SignRecover.
                              4       : Use Decrypt.
                              8       : Use Unwrap.
--pkcs11-cert-private [0|1] ... : Set if login should be performed before
                                  certificate can be accessed. Set for each provider.
--pkcs11-pin-cache seconds      : Number of seconds to cache PIN. The default is -1
                                  cache until token is removed.
--pkcs11-id-management          : Acquire identity from management interface.
--pkcs11-id serialized-id 'id'  : Identity to use, get using standalone --show-pkcs11-ids

SSL Library information:
--show-ciphers  : Show cipher algorithms to use with --cipher option.
--show-digests  : Show message digest algorithms to use with --auth option.
--show-engines  : Show hardware crypto accelerator engines (if available).
--show-tls      : Show all TLS ciphers (TLS used only as a control channel).

Windows Specific:
--win-sys path    : Pathname of Windows system directory. Default is the pathname
                    from SystemRoot environment variable.
--ip-win32 method : When using --ifconfig on Windows, set TAP-Windows adapter
                    IP address using method = manual, netsh, ipapi,
                    dynamic, or adaptive (default = adaptive).
                    Dynamic method allows two optional parameters:
                    offset: DHCP server address offset (> -256 and < 256).
                            If 0, use network address, if >0, take nth
                            address forward from network address, if <0,
                            take nth address backward from broadcast
                            address.
                            Default is 0.
                    lease-time: Lease time in seconds.
                                Default is one year.
--route-method    : Which method to use for adding routes on Windows?
                    adaptive (default) -- Try ipapi then fall back to exe.
                    ipapi -- Use IP helper API.
                    exe -- Call the route.exe shell command.
--dhcp-option type [parm] : Set extended TAP-Windows properties, must
                    be used with --ip-win32 dynamic.  For options
                    which allow multiple addresses,
                    --dhcp-option must be repeated.
                    DOMAIN name : Set DNS suffix
                    DOMAIN-SEARCH entry : Add entry to DNS domain search list
                    DNS addr    : Set domain name server address(es) (IPv4 and IPv6)
                    NTP         : Set NTP server address(es)
                    NBDD        : Set NBDD server address(es)
                    WINS addr   : Set WINS server address(es)
                    NBT type    : Set NetBIOS over TCP/IP Node type
                                  1: B, 2: P, 4: M, 8: H
                    NBS id      : Set NetBIOS scope ID
                    DISABLE-NBT : Disable Netbios-over-TCP/IP.
--dhcp-renew       : Ask Windows to renew the TAP adapter lease on startup.
--dhcp-pre-release : Ask Windows to release the previous TAP adapter lease on
                       startup.
--register-dns  : Run ipconfig /flushdns and ipconfig /registerdns
                  on connection initiation.
--tap-sleep n   : Sleep for n seconds after TAP adapter open before
                  attempting to set adapter properties.
--pause-exit         : When run from a console window, pause before exiting.
--service ex [0|1]   : For use when OpenVPN is being instantiated by a
                       service, and should not be used directly by end-users.
                       ex is the name of an event object which, when
                       signaled, will cause OpenVPN to exit.  A second
                       optional parameter controls the initial state of ex.
--show-net-up   : Show OpenVPN's view of routing table and net adapter list
                  after TAP adapter is up and routes have been added.
--windows-driver   : Which tun driver to use?
                     ovpn-dco (default)
                     tap-windows6
                     wintun
--block-outside-dns   : Block DNS on other network adapters to prevent DNS leaks
Windows Standalone Options:

--show-adapters : Show all TAP-Windows adapters.
--show-net      : Show OpenVPN's view of routing table and net adapter list.
--show-valid-subnets : Show valid subnets for --dev tun emulation.
--allow-nonadmin [TAP-adapter] : Allow OpenVPN running without admin privileges
                                 to access TAP adapter.

Generate a new key :
--genkey secret file   : Generate a new random key of type and write to file
                         (for use with --secret, --tls-auth or --tls-crypt).
PKCS#11 standalone options:
--show-pkcs11-ids provider [cert_private] : Show PKCS#11 available ids.
                                            --verb option can be added *BEFORE* this.

General Standalone Options:

C:\Users\Administrator.RVHAD01>

TLS認証鍵の作成

OpenVPN接続でのセキュリティを強化オプションにTLS認証(Transport Layer Security Authentication)というものがあり、OpenVPN のサーバ/クライアント間で tls-auth キーを事前に共有する必要があります。

この tls-auth キー を利用することで中間者攻撃やDoS攻撃から保護する役割を果たします。

この tls-auth キー は管理者権限のコマンドラインを使って

C:\Program Files\OpenVPN\config

配下で

openvpn –genkey secret ta.key

コマンドを投入することで作成します。

C:\Program Files\OpenVPN\config>openvpn --genkey secret ta.key


C:\Program Files\OpenVPN\config>type ta.key
#
# 2048 bit OpenVPN static key
#
-----BEGIN OpenVPN Static key V1-----
a1e9e94612a46f8b2e54e74863c2a051
ee4f639b3d22f812b3e8ca475b816a01
       :
             :
5f203fff5dcbfad6198aac6d025d6c19
e7e13860e8fbd09d5c9f8ed24b5d1460
-----END OpenVPN Static key V1-----

 

これで

C:\Program Files\OpenVPN\config

配下に

  • ta.key(TLS認証鍵)

が作成できました。

OpenVPNでは、TLSを使用して接続の認証、データの暗号化、およびデータの整合性を確保します。tls-authは、このセキュリティ機能を強化するためにOpenVPNによって提供されるオプションの1つであり、中間者攻撃やDoS攻撃から保護する役割を果たします。

認証局、秘密鍵、証明書を作成する手順

vpnux PKI Manager – 証明書管理ツールのインストール

こちらもまずOpenVPN.JPから提供されている

を参照してvpnux PKI Manager をインストールします。

ここでは同サイトからダウンロードしてきた

vpnuxPKIManager.zip

を解凍後 C:\Program Files 配下に配置しています。

【自宅VPN構築】#12 Windows 2019 Server Essentials 搭載 PC にOpenVPN Serverを設置しよう
vpnux PKI Manager 実行環境フォルダ


そしてこのフォルダ内にある

vpnuxPKI.exe

をダブルクリックすることで以下の vpnux PKI Manager – 証明書管理ツール を起動することができます。

【自宅VPN構築】#12 Windows 2019 Server Essentials 搭載 PC にOpenVPN Serverを設置しよう
vpnux PKI Manager 画面

vpnux PKIでできること

先ほどの vpnux PKI Manager – 証明書管理ツール にも記載がありますがこの vpnux PKI Manager を使うことで、個人で認証局を設置、運営することが可能です。

  • 認証局の設置(CA秘密鍵/CA証明書/DHパラメータファイルの作成)
  • サーバー用秘密鍵/証明書の作成/署名処理、失効処理
  • クライアント用秘密鍵/証明書の作成/署名処理、失効処理
  • 発行済み証明書の一覧表示
【自宅VPN構築】#12 Windows 2019 Server Essentials 搭載 PC にOpenVPN Serverを設置しよう
しらかば堂

ただし個人で設置した認証局が信頼できるかどうかは、発行された証明書を受け取る側が判断するため、公的信頼性が担保されている訳ではありません。

公開鍵暗号方式では、暗号化通信において公開された鍵(公開鍵)と秘密に保持される鍵(秘密鍵)を利用して、情報を安全にやり取りします。

この方式では、送信者は暗号化する際に公開鍵を用いてメッセージを暗号化し、暗号文を送信します。受信者は自分の秘密鍵を使用して暗号文を復号化します。

認証局(Certification Authority、CA)は、X.509規格に基づくCA証明書を発行することができる機関のことで、ここではvpnux PKI Manager – 証明書管理ツール を利用する個人を指します。

このCA証明書には、以下の情報が含まれます。

  1. 証明書発行対象の識別情報(名前、組織名、国、メールアドレス等)
  2. 公開鍵情報(アルゴリズム、鍵の長さ、公開鍵そのもの)
  3. 証明書有効期限(発行日時と有効期限)
  4. 証明書署名情報(認証局の名前、署名アルゴリズム、認証局の署名)

DHパラメータファイルは、Diffie-Hellman鍵交換に使用されるパラメータを含むファイルです。Diffie-Hellman鍵交換は、公開鍵暗号方式の一種で、通信相手間で安全な暗号鍵を共有するために使用されます。

認証局の設置

具体的に認証局(CA)を設置(CA秘密鍵/CA証明書/DHパラメータファイルの作成)するには vmnux PKI Manager CAの新規作成 ボタンをクリックします。

【自宅VPN構築】#12 Windows 2019 Server Essentials 搭載 PC にOpenVPN Serverを設置しよう
vpnux PKI Manager 画面


すると以下のような警告ダイアログが表示されるので はい(Y) ボタンをクリックします。

【自宅VPN構築】#12 Windows 2019 Server Essentials 搭載 PC にOpenVPN Serverを設置しよう
新規CA構築 ダイアログ


次に以下の画面から CAを保存するフォルダを指定し OK ボタンをクリックします。

【自宅VPN構築】#12 Windows 2019 Server Essentials 搭載 PC にOpenVPN Serverを設置しよう
CAのフォルダ参照ダイアログ


すると以下のような警告ダイアログが表示されるので はい(Y) ボタンをクリックします。

【自宅VPN構築】#12 Windows 2019 Server Essentials 搭載 PC にOpenVPN Serverを設置しよう
確認 ダイアログ


すると以下のようなCA証明書の作成 画面が表示されるので

  • 国名コード
  • 都道府県
  • 組織名
  • 共通名

等の必須項目を記入後、 CA証明書の作成(G) ボタンをクリックします。

【自宅VPN構築】#12 Windows 2019 Server Essentials 搭載 PC にOpenVPN Serverを設置しよう
CA証明書の作成 画面


するとこのようなダイアログ画面が出ますが

【自宅VPN構築】#12 Windows 2019 Server Essentials 搭載 PC にOpenVPN Serverを設置しよう
OpenSSL 処理中 ダイアログ


しばらくすると次のダイアログ画面が出ますので OK ボタンをクリックして作成終了です。

【自宅VPN構築】#12 Windows 2019 Server Essentials 搭載 PC にOpenVPN Serverを設置しよう
新規CA構築 ダイアログ


これらの処理により指定フォルダ内に以下のようなファイルが作成されました。

【自宅VPN構築】#12 Windows 2019 Server Essentials 搭載 PC にOpenVPN Serverを設置しよう
コンフィグレーション保存フォルダ

この中で

  • ca.crt(CA証明書)
  • ca.key(CA秘密鍵)
  • dh2048.pem(DHパラメータファイル)

OpenVPN Server の有効化に必要なファイルですので、これらを

C:\Program Files\OpenVPN\config

配下にコピーしておきます。


この ca.crt(CA証明書) は次のようなテキストファイルです。

-----BEGIN CERTIFICATE-----
MIID7TCCAtWgAwIBAgIJALVLQRvIQlbpMA0GCSqGSIb3DQEBCwUAMFcxGjAYBgNV
BAMTEVNhbXBsZSBDb21wYW55IENBMRwwGgYDVQQKExNTYW1wbGUgQ29tcGFueSBJ
bmMuMQ4wDAYDVQQHEwVUb2t5bzELMAkGA1UEBhMCSlAwHhcNMjMwMzA0MjE0NzU0
WhcNMzMwMzAxMjE0NzU0WjBXMRowGAYDVQQDExFTYW1wbGUgQ29tcGFueSBDQTEc
                              :
                              :
xBzZoFWOQfyoEPIMYVgPw8mT+45SL2f8egYuFXJYdG8Fyu5sGRzSX+/Fe9E9GqVo
50XfsYLnjSLk/pG9K+Z66KteSllM24O/i+CiQ4EbmKs4bDXrt+XZUq7HRQEHzuV7
sdr178buFbuEQa54zx0SncUuM8jTWEXk6jIKpYbcOubUZ2Z/KJZts0esqp1iFRnp
DVwXLSNpNJ9+sniGCFD9pjClakOZXGt+jSj1RXUV85W9F6fUcAaxNC/RTBgJ4jfl
JQ==
-----END CERTIFICATE-----


次に ca.key(CA秘密鍵) には次のようなテキストファイルです。

-----BEGIN PRIVATE KEY-----
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDHQnF8FJslLcYM
n3DAf8xqG3VjN9xPmkVnhqhXLNBNbBq0ErkhdOrTFhyInvVua0tyudS5E8rBM1LD
/TXW39gbkTFcGV0rHhAHcaa4dfiYSl+URN+w003MMv+nABPwDiBGVxNcjZNZetDc
QeRsW9lSj97WJ9nTUokh8S2wvzDIVrI/OW6QNIJ7swEUa2ZmnDS+jYHZuEArzMXK
                              :
                              :
cow6+iEDKtJKx9v2ZH1eK2g+PXaFLcTp6VTyTGUOOO4xTOkd5Vwi7Cigkrce/nXo
d60HUXtp2ULmEyeUMzFT3zieEY2ULs7ksfGvNRrhAoGBAKxN4LJDxAk6aHqNcsrP
ct+eNpNQlGAzHnLjQJ9s1R8UrBYU0kROxlxEOUQ2nhiJWxYkNNrJDMqNNmU04KBI
bZPi6XYP+dWxZBgVwq5nc/3C2htqM6p1xHQGzKxSi/weYGW/i95ZS/5eU9qrzDYJ
HMcjSkbO9W7ufFcxRknLW+90
-----END PRIVATE KEY-----


最後に dh2048.pem(DHパラメータファイル) は次のようなテキストファイルです。

-----BEGIN DH PARAMETERS-----
MIIBCAKCAQEAllkbn3pH8M3RDHTjbdjPilWsASQE+/ppAvjYviYvH1pDa1UXd8CB
cUuYWtsX12vLKLE8aKrs6nXnNb1vGFUITNdVY9mUJE9uZfbCJWSzon/DShUfiJtH
                              :                              :
k2+q95xoVoE+9YcgvbfuzE/1LrZLKSf1/W1Av3rbUsx8HysPtA/x1GPt7oaVrbXa
WBN978+hBHz6zpyhAiS5mRBv193Q2x5zawIBAg==
-----END DH PARAMETERS-----

サーバー用秘密鍵、証明書の作成

CAの作成が終わると、CAディレクトリ にCA作成の際に選択したフォルダ名が表示されますので、必要に応じて参照ボタンをクリックし、書きこみ可能なフォルダを選択しておきます。 

【自宅VPN構築】#12 Windows 2019 Server Essentials 搭載 PC にOpenVPN Serverを設置しよう
vpnux PKI Manager 画面


サーバー用秘密鍵/証明書の作成するには vpnux PKI Manager 画面で
サーバー用秘密鍵/証明書 ボタンをクリックします。

【自宅VPN構築】#12 Windows 2019 Server Essentials 搭載 PC にOpenVPN Serverを設置しよう
vpnux PKI Manager 画面


すると サーバー証明書の作成 画面が表示されるので 秘密鍵/証明書 に共通に使用される共通名(サーバ名) を記入し 証明書作成(G) ボタンをクリックします。

【自宅VPN構築】#12 Windows 2019 Server Essentials 搭載 PC にOpenVPN Serverを設置しよう
サーバ証明書の作成 画面


しばらくすると次のダイアログ画面が出ますので OK ボタンをクリックして作成終了です。

【自宅VPN構築】#12 Windows 2019 Server Essentials 搭載 PC にOpenVPN Serverを設置しよう
OpenSSL 処理 ダイアログ


すると先ほどのフォルダ中に

  • server_1.crt(サーバ用証明書)
  • server_1.key(サーバ用秘密鍵)

というファイルが作成されます(server1 は指定した共通名(サーバ名)のでこれも同様に

C:\Program Files\OpenVPN\config

配下にコピーしておきます。

この server_1.crt(CA証明書) は次のようなテキストファイルです。

Certificate:
    Data:
        Version: 3 (0x2)
        Serial Number: 2 (0x2)
    Signature Algorithm: sha256WithRSAEncryption
        Issuer: CN=Sample Company CA, O=Sample Company Inc., L=Tokyo, C=JP
        Validity
            Not Before: Mar  5 00:25:54 2023 GMT
            Not After : Mar  2 00:25:54 2033 GMT
        Subject: C=JP, L=Tokyo, O=Sample Company Inc., CN=server_1
        Subject Public Key Info:
            Public Key Algorithm: rsaEncryption
                Public-Key: (2048 bit)
                Modulus:
                    00:ca:77:93:d4:1d:51:7c:b1:9a:c5:91:74:e6:67:
                    a6:7f:d3:e0:6a:78:75:36:c7:2e:95:75:80:86:b9:
                              :
                              :
                    e9:3b:13:08:27:b4:30:b4:1e:46:f0:c3:75:c6:ae:
                    c2:81:7c:26:c0:9d:b9:35:ab:b8:47:bf:61:9e:22:
                    36:fb
                Exponent: 65537 (0x10001)
        X509v3 extensions:
            X509v3 Basic Constraints: 
                CA:FALSE
            Netscape Cert Type: 
                SSL Server
            Netscape Comment: 
                vpnux PKI Manager for OpenVPN (http://www.vpnux.jp/)
            X509v3 Subject Key Identifier: 
                1A:2F:0D:8D:81:27:A6:A3:F3:77:81:2C:AD:04:4F:78:3E:F4:F5:A0
            X509v3 Authority Key Identifier: 
                keyid:51:22:43:57:0A:6A:1E:45:6B:45:5B:84:44:7A:D5:C5:73:2A:FC:03
                DirName:/CN=Sample Company CA/O=Sample Company Inc./L=Tokyo/C=JP
                serial:B5:4B:41:1B:C8:42:56:E9

            X509v3 Extended Key Usage: 
                TLS Web Server Authentication
            X509v3 Key Usage: 
                Digital Signature, Key Encipherment
    Signature Algorithm: sha256WithRSAEncryption
         52:d5:cd:fd:45:c0:90:6e:0f:e6:00:40:09:eb:fc:d2:6f:06:
         24:6b:8b:bd:18:71:01:79:0f:40:0c:25:b7:61:81:72:c1:ae:
                              :
                              :
         39:c5:f5:4b:03:32:e5:35:b6:3b:d5:ef:ca:b4:69:a2:3f:6f:
         4a:ee:13:30:b2:f9:c9:5e:96:50:61:43:02:a2:a9:80:73:66:
         d3:fc:16:7a
-----BEGIN CERTIFICATE-----
MIIEVTCCAz2gAwIBAgIBAjANBgkqhkiG9w0BAQsFADBXMRowGAYDVQQDExFTYW1w
bGUgQ29tcGFueSBDQTEcMBoGA1UEChMTU2FtcGxlIENvbXBhbnkgSW5jLjEOMAwG
                              :
                              :
t0FnDShhJbRdDuWdpFSxSdTuQDgyKK+6taNbA9zX43XP7hNXFjnRoSB98wbj8tIE
5qYdnTb5EkEyZ2PK1fPw/VM5xfVLAzLlNbY71e/KtGmiP29K7hMwsvnJXpZQYUMC
oqmAc2bT/BZ6
-----END CERTIFICATE-----


また server_1.key(サーバ用秘密鍵)は次のようなテキストファイルです。

-----BEGIN PRIVATE KEY-----
MIIEwAIBADANBgkqhkiG9w0BAQEFAASCBKowggSmAgEAAoIBAQDKd5PUHVF8sZrF
kXTmZ6Z/0+BqeHU2xy6VdYCGuSCiyCyWvq3AfK1mvVJZ8j4OLtKigtHo53RH3Ja2
                              :
                              :
XRgLZVZmCWSPa52VuoIOBvTAFpdRX6KEc0RWJuuogTW02afXVAp8mDPFA0LM4lqx
cBvjIqHJja/g2jg2b6qig3hGu2J1kUjHEU4ABEpVMkzbsEPu7KHoYstcvKSwT1JK
y03nMQDH+UAh1KJCiz3L3DjQ6IQ=
-----END PRIVATE KEY-----
-----BEGIN CERTIFICATE REQUEST-----
MIICkzCCAXsCAQAwTjERMA8GA1UEAxQIc2VydmVyXzExHDAaBgNVBAoTE1NhbXBs
ZSBDb21wYW55IEluYy4xDjAMBgNVBAcTBVRva3lvMQswCQYDVQQGEwJKUDCCASIw
                              :
                              :
YqzGHI3L9BLQXCdnoX9htE/rPBDsz9iAovj2pPRhfIzCXN/0xruBAnBTxbUyNzl2
hdP6591aTMDfZX0DcjKOoYS9zivp1PNcsbFj52FAWnsitIoyH7oG
-----END CERTIFICATE REQUEST-----

クライアント用秘密鍵、証明書の作成

同様にクライアント用秘密鍵/証明書の作成するには vpnux PKI Manager 画面で
クライアント用秘密鍵/証明書 ボタンをクリックします。

【自宅VPN構築】#12 Windows 2019 Server Essentials 搭載 PC にOpenVPN Serverを設置しよう
vpnux PKI Manager 画面


すると クライアント証明書の作成 画面が表示されるので 秘密鍵/証明書 に共通に使用される共通名(クライアント名) を記入し 証明書作成(G) ボタンをクリックします。

【自宅VPN構築】#12 Windows 2019 Server Essentials 搭載 PC にOpenVPN Serverを設置しよう
クライアント証明書の作成 画面


しばらくすると次のダイアログ画面が出ますので OK ボタンをクリックして作成終了です。

【自宅VPN構築】#12 Windows 2019 Server Essentials 搭載 PC にOpenVPN Serverを設置しよう
OpenSSL処理 ダイアログ


すると先ほどのフォルダ中に

  • client_1.crt(クライアント用証明書)
  • client_1.key(クライアント用秘密鍵)

というファイルが作成されます(client_1は指定した共通名(クライアント名)ので、これらも

C:\Program Files\OpenVPN\config

配下にコピーしておきます。

この client_1.crt(CA証明書) は次のようなテキストファイルです。

Certificate:
    Data:
        Version: 3 (0x2)
        Serial Number: 3 (0x3)
    Signature Algorithm: sha256WithRSAEncryption
        Issuer: CN=Sample Company CA, O=Sample Company Inc., L=Tokyo, C=JP
        Validity
            Not Before: Mar  5 02:02:12 2023 GMT
            Not After : Mar  2 02:02:12 2033 GMT
        Subject: C=JP, L=Tokyo, O=Sample Company Inc., CN=client_1
        Subject Public Key Info:
            Public Key Algorithm: rsaEncryption
                Public-Key: (2048 bit)
                Modulus:
                    00:ec:92:67:e5:b7:f5:35:be:4b:fe:ef:c9:c2:f2:
                    fd:b5:6f:64:09:08:f0:f1:0a:be:94:e9:00:43:e1:
                              :
                              :
                    48:01:af:d0:30:cc:50:f4:3c:4e:db:0c:b5:24:3c:
                    80:32:86:4c:e5:9c:51:d0:dd:8a:ab:81:96:00:84:
                    4a:15
                Exponent: 65537 (0x10001)
        X509v3 extensions:
            X509v3 Basic Constraints: 
                CA:FALSE
            Netscape Comment: 
                vpnux PKI Manager for OpenVPN (http://www.vpnux.jp/)
            X509v3 Subject Key Identifier: 
                66:CD:F7:FB:16:C1:9F:8E:F2:0B:EF:0C:7F:0F:A5:ED:4F:9E:C0:46
            X509v3 Authority Key Identifier: 
                keyid:51:22:43:57:0A:6A:1E:45:6B:45:5B:84:44:7A:D5:C5:73:2A:FC:03
                DirName:/CN=Sample Company CA/O=Sample Company Inc./L=Tokyo/C=JP
                serial:B5:4B:41:1B:C8:42:56:E9

            X509v3 Extended Key Usage: 
                TLS Web Client Authentication
            X509v3 Key Usage: 
                Digital Signature
    Signature Algorithm: sha256WithRSAEncryption
         2a:4e:de:c8:7f:26:de:02:09:5c:73:d1:96:7f:9e:0f:d0:69:
         f1:79:62:9f:99:35:4d:53:80:88:04:4d:4e:59:a8:9b:32:09:
                              :
                              :
         0e:c0:70:a0:55:df:09:fa:9c:c5:39:75:a1:87:87:3e:3f:1f:
         3a:35:07:0c:f4:b6:63:39:a6:e4:4e:d8:21:2d:15:b2:ea:40:
         1e:7e:4c:ba
-----BEGIN CERTIFICATE-----
MIIEQjCCAyqgAwIBAgIBAzANBgkqhkiG9w0BAQsFADBXMRowGAYDVQQDExFTYW1w
bGUgQ29tcGFueSBDQTEcMBoGA1UEChMTU2FtcGxlIENvbXBhbnkgSW5jLjEOMAwG
                              :
                              :
WIrjMNXNSMnmJR8VlDuuWQh8WXRkMK9scbujGMVgETRdJIsVzM9B3+CoenlAgHkA
mxnI9fPj33C/cQfNRHi0H4xkDfxAnqxkPMX5x875kcWevjjxI5DPFBdUCz77rQ7A
cKBV3wn6nMU5daGHhz4/Hzo1Bwz0tmM5puRO2CEtFbLqQB5+TLo=
-----END CERTIFICATE-----


同様に client_1.key(クライアント用秘密鍵 は次のようなテキストファイルです。

-----BEGIN PRIVATE KEY-----
MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDskmflt/U1vkv+
78nC8v21b2QJCPDxCr6U6QBD4bwUihC1y4ItgDErW0ZS5LrH8VOptJRNdQBXm100
                              :
                              :
eVIKi6LvkdElFdVVQX/LdvnjYiezmKdXTR1rGgtmL2JDW1pRq3g3ct96Z52g9Z7D
bh9ypuW+1sRv0JJ3fMxCibqATMDARFmOBmW25inf/jz4O+UGPHE9TLpymd7pbCQl
aCPUDbEZKkTFdc37KuZoRkDT+A==
-----END PRIVATE KEY-----
-----BEGIN CERTIFICATE REQUEST-----
MIICkzCCAXsCAQAwTjERMA8GA1UEAxQIY2xpZW50XzExHDAaBgNVBAoTE1NhbXBs
ZSBDb21wYW55IEluYy4xDjAMBgNVBAcTBVRva3lvMQswCQYDVQQGEwJKUDCCASIw
                              :
                              :
h/+fio7qif0OGFc40QlUzo0JMi4FqkKFHBzyxM1u3Ik4x2GiFlh0vhbSWGf3Q2zJ
db9oxTZj7XV4z3aChbGC98pHjPOdksX7A7q746OV5z/BL1x8nkhPQhy0ar4h4YHJ
YMr9x3WYhLDaXgYDjHLYjXJKICh0ZaeXjyM1PYrwwjiVJXf9kXXt
-----END CERTIFICATE REQUEST-----
【自宅VPN構築】#12 Windows 2019 Server Essentials 搭載 PC にOpenVPN Serverを設置しよう
しらかば堂

このクライアント用秘密鍵/証明書の作成はクライアントの台数分行います。
例えばこの記事でご紹介している以下の構成の場合クライアントが2台ありますので2台分作成します。

【自宅VPN構築】#12 Windows 2019 Server Essentials 搭載 PC にOpenVPN Serverを設置しよう
自宅LAN におけるOpenVPN サーバ/クライアント導入図

発行済み証明書の確認

既に作成済、あるいは失効したサーバ用秘密鍵/証明書、クライアント用秘密鍵/証明書 を確認するには vpnux PKI Manager 画面で 発行済み証明書リスト ボタンをクリックします。

【自宅VPN構築】#12 Windows 2019 Server Essentials 搭載 PC にOpenVPN Serverを設置しよう
vpnux PKI Manager 画面


すると 証明書一覧 画面が現れ、既に作成済の証明書に対し以下の情報を確認できます。

  • 状態:有効 / 失効済み
  • 有効期限:証明書発行時に設定された有効期限
  • 失効日時:証明書が有効期限切れ、または失効処理により失効した日時
  • シリアル:証明書の作成時に自動的にアサインされるシリアル番号
  • 共通名:秘密鍵/証明書の共通名

 

【自宅VPN構築】#12 Windows 2019 Server Essentials 搭載 PC にOpenVPN Serverを設置しよう
証明書一覧 画面
【自宅VPN構築】#12 Windows 2019 Server Essentials 搭載 PC にOpenVPN Serverを設置しよう
しらかば堂

実は証明書の失効状態を確認するために、server_1 用秘密鍵/証明書に対し以下の手順で一度失効処理を行い再度再作成しています。

発行済み証明書の失効手順

先ほどと同様 vpnux PKI Manager 画面で 発行済み証明書リスト ボタンをクリックします。

【自宅VPN構築】#12 Windows 2019 Server Essentials 搭載 PC にOpenVPN Serverを設置しよう
vpnux PKI Manager 画面


そして失効させたい証明書をクリックして選択し、右マウスボタンを押すと以下のような
証明書の失効 メニューが現れるので、これを選択すると

【自宅VPN構築】#12 Windows 2019 Server Essentials 搭載 PC にOpenVPN Serverを設置しよう
証明書一覧からの証明書の失効起動メニュー


以下の 証明書の失効 ダイアログ画面が現れるので はい(Y) をクリックします。

【自宅VPN構築】#12 Windows 2019 Server Essentials 搭載 PC にOpenVPN Serverを設置しよう
証明書の失効ダイアログ


再度次のダイアログ画面が現れるので再度 はい(Y) をクリックします。

【自宅VPN構築】#12 Windows 2019 Server Essentials 搭載 PC にOpenVPN Serverを設置しよう
証明書の失効ダイアログ


最後に以下のダイアログ画面が現れるので OK をクリックします。

【自宅VPN構築】#12 Windows 2019 Server Essentials 搭載 PC にOpenVPN Serverを設置しよう
証明書の失効ダイアログ


証明書の失効処理が完了すると、

  • crl.pem(証明書失効リストファイル)

が作成、更新されます。このファイルは

C:\Program Files\OpenVPN\config

配下に自動的に作成されますので、コンフィグファイルの中で crl-verify オプションで参照します。

【自宅VPN構築】#12 Windows 2019 Server Essentials 搭載 PC にOpenVPN Serverを設置しよう
しらかば堂

一般的な会社組織において証明書を失効させる理由はいくつかありますが、代表的なのは次のような状況かもしれません。

  • 証明書が漏洩したとき
  • 証明書が利用期限を超えたとき
  • 証明書の保有者が離職、退職等によって会社組織を離れたとき

コンフィグデータ保存フォルダ

ここまでの作業でOpenVPN Serverコンフィグデータ保存フォルダ

C:\Program Files\OpenVPN\config

配下には以下のファイルが格納されているはずです。

  • ta.key(TLS認証鍵)
  • ca.crt(CA証明書)
  • ca.key(CA秘密鍵)
  • dh2048.pem(DHパラメータファイル)
  • server_1.crt(サーバ用証明書)
  • server_1.key(サーバ用秘密鍵)
  • client_1.crt(クライアント用証明書)
  • client_1.key(クライアント用秘密鍵)
  • client_2.crt(クライアント用証明書)
  • client_2.key(クライアント用秘密鍵)
  • crl.pem(証明書失効リストファイル

このフォルダ配下は以下のような状態になっているかと思います。

【自宅VPN構築】#12 Windows 2019 Server Essentials 搭載 PC にOpenVPN Serverを設置しよう
OpenVPN Sverver コンフィグデータ格納フォルダ
【自宅VPN構築】#12 Windows 2019 Server Essentials 搭載 PC にOpenVPN Serverを設置しよう
しらかば堂

OpenVPNのコンフィグファイル statickey_server.ovpn については別の記事の中でご紹介します。

まとめ

この記事では自宅にOpenVPN環境を構築する方法について紹介しました。

具体的には、

  • Windows Server 2019 Essentialsを搭載したPCにOpenVPN Serverを構築する手順
  • TLS認証鍵を作成する手順
  • 認証局、秘密鍵、証明書を作成する手順

について説明しました。

この記事が読者の方に少しでもお役にたてると幸いです。