サーバ証明書の作成。

せっかく認証局を構築したからサーバ証明書を発行してftpやらhttp、メールの通信を暗号化してみる。
作業の流れは・・・。

  1. 秘密鍵の作成
    OpenSSLの機能を使って秘密鍵を作成する。
  2. CSRの作成
    CAへサーバ証明書を発行するためのリクエストを作成する。
  3. 署名
    2.で作成したCSRを元に事前に構築したCAで証明書に署名する。

って感じかな?
今回は、PacketiXで利用するVPNサーバの証明書を作成する。

# openssl genrsa -des3 -out /etc/pki/CA/private/vpn.key 1024
Generating RSA private key, 1024 bit long modulus
..........++++++
..++++++
e is 65537 (0x10001)
Enter pass phrase for /etc/pki/CA/private/vpn.key:  <---秘密鍵のパスフレーズを入力
Verifying - Enter pass phrase for /etc/pki/CA/private/vpn.key:  <---秘密鍵のパスフレーズを入力


これで秘密鍵が作成された。

# ls -la /etc/pki/CA/private/vpn.key
-rw-r--r-- 1 root root 963  2月 19 10:00 /etc/pki/CA/private/vpn.key


次に、この秘密鍵を使うときに毎回パスワードを聞かれると自動起動ができないなど、いろいろと不便なので、秘密鍵からパスワードを削除する。

# openssl rsa -in /etc/pki/CA/private/vpn.key -out /etc/pki/CA/private/vpn.key.tmp
Enter pass phrase for /etc/pki/CA/private/vpn.key:  <---秘密鍵のパスフレーズを入力
writing RSA key
# mv /etc/pki/CA/private/vpn.key.tmp /etc/pki/CA/private/vpn.key
mv: `/etc/pki/CA/private/vpn.key' を上書きしてもよろしいですか(yes/no)? yes

作成された秘密鍵からCSRを作成する。

# openssl req -new -days 365 -key /etc/pki/CA/private/vpn.key -out /etc/pki/CA/csr/vpn.csr
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) [GB]:JP
State or Province Name (full name) [Berkshire]:Tokyo
Locality Name (eg, city) [Newbury]:Chiyoda
Organization Name (eg, company) [My Company Ltd]:Cecily.JP
Organizational Unit Name (eg, section) []:VPN Server
Common Name (eg, your name or your server's hostname) []:vpn.cecily.jp
Email Address []:[email protected]

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:  <—空白でEnter
An optional company name []:  <—空白でEnter

サーバ証明書を作成するためにOpenSSLのコンフィグを作成する。

# cp /etc/pki/tls/openssl.cnf /etc/pki/tls/openssl.cnf.server
[ usr_cert ]の項の下記の部分を変更する
- # nsCertType                      = server
+ nsCertType                      = server

上で作成したコンフィグファイルを指定し、前に構築したCAを利用して証明書に署名する。

# openssl ca -config /etc/pki/tls/openssl.cnf.server -in /etc/pki/CA/csr/vpn.csr -keyfile /etc/pki/CA/private/ca.key -cert /etc/pki/CA/certs/ca.crt -out /etc/pki/CA/certs/vpn.crt
Using configuration from /etc/pki/tls/openssl.cnf.server
Enter pass phrase for /etc/pki/CA/private/ca.key:  <---CAの秘密鍵を入力
Check that the request matches the signature
Signature ok
Certificate Details:
        Serial Number: 1 (0x1)
        Validity
            Not Before: May  3 07:08:34 2008 GMT
            Not After : May  3 07:08:34 2009 GMT
        Subject:
            countryName               = JP
            stateOrProvinceName       = Tokyo
            organizationName          = Cecily.JP
            organizationalUnitName    = VPN Server
            commonName                = vpn.cecily.jp
            emailAddress              = [email protected]
        X509v3 extensions:
            X509v3 Basic Constraints:
                CA:TRUE
            Netscape Cert Type:
                SSL Server
            Netscape Comment:
                OpenSSL Generated Certificate
            X509v3 Subject Key Identifier:
                38:24:DA:6C:9D:E1:BF:31:6D:0C:0A:DE:29:47:A5:15:2F:73:77:6E
            X509v3 Authority Key Identifier:
                keyid:08:67:DF:6C:1D:6D:B1:A4:CB:C2:55:DB:3B:B0:00:59:D4:2F:28:15

Certificate is to be certified until May  3 07:08:34 2009 GMT (365 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

これで/etc/pki/tls/certsにvpn.crtというファイル名で証明書が作成された。

関連記事

  1. NO IMAGE
  2. NO IMAGE

    2008.02.13

    メモリ購入。
  3. NO IMAGE
  4. NO IMAGE
  5. NO IMAGE

コメントをお待ちしております

CALENDAR

2024年3月
 12
3456789
10111213141516
17181920212223
24252627282930
31  

ARCHIVES

CATEGORIES