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が利用できます。
Profile
- 山崎 太郎 (Taro Yamazaki)
- プラムシステムズ株式会社所属。 主にVPN(OpenVPN)やセキュリティ関連技術、Webアプリケーションを手がけています。
Page Views
Popular Posts
© yamata::memo 2013 . Powered by Bootstrap , WebLyb