OpenVPN&セキュリティ情報
2011-11-05
OpenVPN設定 - 鍵と証明書の作成
OpenVPNでは、サーバー、クライアントともに鍵と証明書を使って認証処理を行います。では、サーバー、クライアントの鍵と証明書の作成方法をご案内しましょう。
※ 以下の手順は必要なときにその都度行えますが、ログインごとにvarsコマンドを実行してから各手順を行なってください。varsコマンドによる環境変数の設定はログアウトでリセットされます。
鍵と証明書の作成
1. OpenVPNサーバー用の鍵と証明書の作成
OpenVPNサーバーの鍵と証明書を作るには build-key-server コマンドを実行します。引数としてこの証明書に使用する共通名(Common Name)を設定します。[root@localhost 2.0]# ./build-key-server server Generating a 1024 bit RSA private key ............................++++++ ............++++++ writing new private key to 'server.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) [JP]: State or Province Name (full name) [Tokyo]: Locality Name (eg, city) [Shinagawa]: Organization Name (eg, company) [Example company]: Organizational Unit Name (eg, section) []: Common Name (eg, your name or your server's hostname) [server]: Name []: Email Address [admin@example.com]:続いてCAによる署名手続きが行われます。
Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []: An optional company name []: Using configuration from /etc/openvpn/easy-rsa/2.0/openssl.cnf Check that the request matches the signature Signature ok The Subject's Distinguished Name is as follows countryName :PRINTABLE:'JP' stateOrProvinceName :PRINTABLE:'Tokyo' localityName :PRINTABLE:'Shinagawa' organizationName :PRINTABLE:'Example company' commonName :PRINTABLE:'server' emailAddress :IA5STRING:'admin@example.com' Certificate is to be certified until Oct 11 16:24:06 2021 GMT (3650 days) Sign the certificate? [y/n]:y証明書に署名しますか?と聞かれるので「y [ENTER]」と入力します。
1 out of 1 certificate requests certified, commit? [y/n]y証明書要求が署名されましたが、コミットしますか?と聞かれるので、「y [ENTER]」と入力します。
Write out database with 1 new entries Data Base UpdatedこれでOpenVPNサーバーの鍵と証明書が作成されました。keys ディレクトリにserver.crt(証明書)、server.csr(証明書要求)、server.key(秘密鍵) の3つのファイルが作成されます。
2. 各OpenVPNクライアント用の鍵と証明書の作成
基本的な手順はOpenVPNサーバーのときと同じで、build-key コマンドを実行します。引数との証明書に使用する共通名(Common Name)を設定します。共通名として、一般的にはユーザー名やPCの名前などを指定します。[root@localhost 2.0]# ./build-key client-1 Generating a 1024 bit RSA private key ...++++++ ....................++++++ writing new private key to 'client-1.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) [JP]: State or Province Name (full name) [Tokyo]: Locality Name (eg, city) [Shinagawa]: Organization Name (eg, company) [Example company]: Organizational Unit Name (eg, section) []: Common Name (eg, your name or your server's hostname) [client-1]: Name []: Email Address [admin@example.com]: Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []: An optional company name []: Using configuration from /etc/openvpn/easy-rsa/2.0/openssl.cnf Check that the request matches the signature Signature ok The Subject's Distinguished Name is as follows countryName :PRINTABLE:'JP' stateOrProvinceName :PRINTABLE:'Tokyo' localityName :PRINTABLE:'Shinagawa' organizationName :PRINTABLE:'Example company' commonName :PRINTABLE:'client-1' emailAddress :IA5STRING:'admin@example.com' Certificate is to be certified until Oct 11 16:24:54 2021 GMT (3650 days) Sign the certificate? [y/n]:y 1 out of 1 certificate requests certified, commit? [y/n]y Write out database with 1 new entries Data Base UpdatedこれでOpenVPNクライアントの鍵と証明書が作成され、keys ディレクトリにclient1.crt(証明書)、client1.csr(証明書要求)、client1.key(秘密鍵) の3つのファイルが作成されます。
このように作成された鍵や証明書をOpenVPNサーバー、クライアントにそれぞれ適切に配置することでOpenVPNが利用できます。
Related Posts
Profile
- 山崎 太郎 (Taro Yamazaki)
- プラムシステムズ株式会社所属。 主にVPN(OpenVPN)やセキュリティ関連技術、Webアプリケーションを手がけています。
Page Views
808,915
Popular Posts
-
「VPNっていろいろあるけど、OpenVPNのメリットって何?」 という疑問は多くの方が持たれますよね。この点は公式サイトなどにもいろいろ書かれているのですが、実際に使ってきたユーザー側としてメリットと思う部分をまとめてみました。
-
現在ダウンロードできるOpenVPNでは、今まで認証局の構築で使用していたeasy-rsaが含まれなくなっています。 OpenVPN.netのダウンロードページ にも Note that easy-rsa is no longer bundled with OpenVPN...
-
Jan Just Keijser氏の記事「 Optimizing performance on gigabit networks 」については こちら でも概要を取り上げましたが、記事全体にいろいろなヒントが含まれていますので、全文の日本語訳を掲載しています。意訳している部分も...
-
OpenVPNでは、接続してきたクライアントのVPNアドレスは動的に割り振られます(その際に割り振られる際のアドレス範囲はOpenVPNサーバー側設定ファイルに基づきます)。特定のVPNクライアントに特定のVPNアドレスを割り振りたい場合、OpenVPNでは以下の2つの方法で設定...
-
では、いよいよiPhone構成ユーティリティでVoDの設定をしてみましょう。あ、 前の記事 での準備はきちんとやっておいてくださいね!
-
現時点においてはマニュアルやHowToにも記載されていない(ChangeLogにちょっとだけ出てきます)あまり知られていない機能なのですが、「設定ファイルで鍵ファイルや証明書ファイルのパスを記載する」という通常の方法とは別に、「鍵ファイルや証明書ファイル内のデータをそのまま設定フ...
-
前回 は2つのワンタイムパスワードの生成方法について取り上げました。今回はいよいよ実際の生成アルゴリズムを取り上げましょう。TOTPをベースに説明します(ただ、前回も解説したように、基本的なロジックはTOTPとHOTPで同じです)。 参考としてpythonのコードも併記してみま...
-
OpenVPNはLinuxをはじめとした幅広いプラットフォームで動作実績があるのが特徴の一つです。 今回は、最近の電子工作ブームでも話題のシングルボードPC 3機種をOpenVPNサーバーとしてセットアップし、OpenVPNのVPNパフォーマンスを測定してみましょう。 ...
-
前回 はワンタイムパスワードの基本的な仕組みについて説明しました。サーバー側とクライアント側で、それぞれ共通のルールに基づいてパスワードを生成させる必要があることを取り上げましたが、今回は OATH が規定しているその生成ルールについて具体的に説明します。 ワンタ...
-
OpenVPNを使用している方ならよくご存知だと思いますが、通常OpenVPNでは証明書認証を使用します。証明書認証はID/パスワード認証に比較すると安全性が高いとされます(もちろん、秘密鍵の管理方法に大きく依存します)が、証明書認証の概念を理解しにくいユーザーが秘密鍵や証明...
© yamata::memo 2013 . Powered by Bootstrap , WebLyb