目的
内部で使用するSSL証明書を作成する。①証明書はワイルドカードで作成し、システム全体で同じ証明書を使用する。②Subject Alternative Names(SANs)を付与して作成する。③easy-rsaを使用して簡略化する。
設定方針
設定方針を参照する。
対象ホスト
内部サーバー
前提条件
マニュアル名:「共通設定」が完了していること。
設定手順
インストール
Easy RSAをインストールする。
[root@centos ~]# yum install easy-rsa
設定ファイル配置
設定ファイルを配置して移動する。ディレクトリのバージョンはその時点の最新に合わせること。
[root@centos ~]# cp -r /usr/share/easy-rsa/3.0.3 /etc/easy-rsa [root@centos ~]# cd /etc/easy-rsa
認証局構築(CA)
認証局を構築する。
[root@centos ~]# ./easyrsa init-pki init-pki complete; you may now create a CA or requests. Your newly created PKI dir is: /etc/easy-rsa/pki [root@centos ~]# ./easyrsa build-ca Generating a 2048 bit RSA private key ...........................................................+++ ........................+++ writing new private key to '/etc/easy-rsa/pki/private/ca.key.ppdw5sVWWj' Enter PEM pass phrase:xxxxxxxx Verifying - Enter PEM pass phrase:xxxxxxxx ----- 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. ----- Common Name (eg: your user, host, or server name) [Easy-RSA CA]:mydomain.com CA CA creation complete and you may now import and sign cert requests. Your new CA certificate file for publishing is at: /etc/easy-rsa/pki/ca.crt
サーバー証明書
サーバー証明書を作成する。Common Nameはワイルドカードで作成し、全てのサービスで利用する。
サーバー署名要求作成(CSR)
[root@centos ~]# ./easyrsa --subject-alt-name='DNS:*.mydomain.com' gen-req server nopass Generating a 2048 bit RSA private key .......................................+++ .....................................................................+++ writing new private key to '/etc/easy-rsa/pki/private/server.key.j3yzBYsfhf' ----- 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. ----- Common Name (eg: your user, host, or server name) [server]:*.mydomain.com Keypair and certificate request completed. Your files are: req: /etc/easy-rsa/pki/reqs/server.req key: /etc/easy-rsa/pki/private/server.key
サーバー証明書作成
[root@centos ~]# ./easyrsa --subject-alt-name='DNS:*.mydomain.com' sign-req server server You are about to sign the following certificate. Please check over the details shown below for accuracy. Note that this request has not been cryptographically verified. Please be sure it came from a trusted source or that you have verified the request checksum with the sender. Request subject, to be signed as a server certificate for 3650 days: subject= commonName = *.mydomain.com Type the word 'yes' to continue, or any other input to abort. Confirm request details: yes Using configuration from ./openssl-1.0.cnf Enter pass phrase for /etc/easy-rsa/pki/private/ca.key:xxxxxxxx Check that the request matches the signature Signature ok The Subject's Distinguished Name is as follows commonName :ASN.1 12:'*.mydomain.com' Certificate is to be certified until Mar 25 12:23:57 2028 GMT (3650 days) Write out database with 1 new entries Data Base Updated Certificate created at: /etc/easy-rsa/pki/issued/server.crt
証明書廃止リスト
証明書廃止リストを作成する。証明書廃止リストの有効期限は他と合わせ10年に変更する。ディレクトリのバージョンはその時点の最新に合わせること。
CRL期限延長
[root@centos ~]# cp /usr/share/doc/easy-rsa-3.0.3/vars.example /etc/easy-rsa/vars [root@centos ~]# vim /etc/easy-rsa/vars #set_var EASYRSA_CRL_DAYS 180 set_var EASYRSA_CRL_DAYS 3650
証明書廃止リスト作成
[root@centos ~]# ./easyrsa build-client-full dummy nopass Generating a 2048 bit RSA private key ............+++ ...................+++ writing new private key to '/etc/easy-rsa/pki/private/dummy.key.oI3LdPrejF' ----- Using configuration from ./openssl-1.0.cnf Enter pass phrase for /etc/easy-rsa/pki/private/ca.key:xxxxxxxx Check that the request matches the signature Signature ok The Subject's Distinguished Name is as follows commonName :ASN.1 12:'dummy' Certificate is to be certified until Apr 5 10:49:38 2028 GMT (3650 days) Write out database with 1 new entries Data Base Updated [root@centos ~]# ./easyrsa revoke dummy Please confirm you wish to revoke the certificate with the following subject: subject= commonName = dummy Type the word 'yes' to continue, or any other input to abort. Continue with revocation: yes Using configuration from ./openssl-1.0.cnf Enter pass phrase for /etc/easy-rsa/pki/private/ca.key:xxxxxxxx Revoking Certificate 9A8B202E7063A9638291787A353BF68D. Data Base Updated IMPORTANT!!! Revocation was successful. You must run gen-crl and upload a CRL to your infrastructure in order to prevent the revoked cert from being accepted. [root@centos ~]# ./easyrsa gen-crl Enter pass phrase for /etc/easy-rsa/pki/private/ca.key:xxxxxxxx An updated CRL has been created. CRL file: /etc/easy-rsa/pki/crl.pem
DHパラメータ
DHパラメータを作成する。
[root@centos ~]# ./easyrsa gen-dh
証明書類配置
内部サーバー自身が参照するための証明書類を配置する。任意の場所で良いが「/var/lib/pki」とした。
[root@centos ~]# mkdir /var/lib/pki [root@centos ~]# cd /etc/easy-rsa/pki [root@centos ~]# cp server.key server.crt /var/lib/pki [root@centos ~]# cd /var/lib/pki [root@centos ~]# chmod 400 server.key server.crt
クライアント証明書
クライアント証明書はOpenVPNの認証に使用する。証明書名にはクライアントのホスト名を使用する。
[root@centos ~]# ./easyrsa build-client-full [hostname] nopass Generating a 2048 bit RSA private key ............................+++ ...........+++ writing new private key to '/etc/easy-rsa/pki/private/[hostname].key.SW6yXdro9C' ----- Using configuration from ./openssl-1.0.cnf Enter pass phrase for /etc/easy-rsa/pki/private/ca.key:xxxxxxxx Check that the request matches the signature Signature ok The Subject's Distinguished Name is as follows commonName :ASN.1 12:'[hostname]' Certificate is to be certified until Mar 29 00:13:37 2028 GMT (3650 days) Write out database with 1 new entries Data Base Updated
CentOS7 SSL証明書