前回の続き
大まかに次の手順でサーバー証明書をインストールする、最終回。
1.認証局の証明書を作る。
2.サーバーの秘密鍵、公開鍵を作る。
3.サーバーの証明書署名要求(CSR)を作る。
4.認証局によってCSRに署名して、サーバー証明書とする。
5.サーバー証明書と、サーバーの秘密鍵、公開鍵を、Apacheに設定する。
今回は上の4番と5番の部分。
4.認証局によってCSRに署名して、サーバー証明書とする。
認証局の作業は、opensslコマンドとコンフィグファイルopenssl.cnfを使用する。前回、証明書署名要求(CSR)を作った時のopenssl.cnfをまた編集して使う。
(前略)
[ CA_default ]
dir = ./demoCA # Where everything is kept
certs = $dir/certs # Where the issued certs are kept
crl_dir = $dir/crl # Where the issued crl are kept
database = $dir/index.txt # database index file.
#unique_subject = no # Set to 'no' to allow creation of
# several ctificates with same subject.
new_certs_dir = $dir/newcerts # default place for new certs.
#certificate = $dir/cacert.pem # The CA certificate
certificate = /etc/ssl/certs/ssl-cert-snakeoil.pem
# 作成済みのsnakeoilを認証局の証明書に指定
serial = $dir/serial # The current serial number
crlnumber = $dir/crlnumber # the current crl number
# must be commented out to leave a V1 CRL
crl = $dir/crl.pem # The current CRL
#private_key = $dir/private/cakey.pem# The private key
private_key = /etc/ssl/private/ssl-cert-snakeoil.key
# snakeoilとともに作成済みの秘密鍵を指定
RANDFILE = $dir/private/.rand # private random number file
x509_extensions = usr_cert # The extentions to add to the cert
# Comment out the following two lines for the "traditional"
# (and highly broken) format.
name_opt = ca_default # Subject Name options
cert_opt = ca_default # Certificate field options
# Extension copying option: use with caution.
# copy_extensions = copy
# Extensions to add to a CRL. Note: Netscape communicator chokes on V2 CRLs
# so this is commented out by default to leave a V1 CRL.
# crlnumber must also be commented out to leave a V1 CRL.
# crl_extensions = crl_ext
#default_days = 365 # how long to certify for
default_days= 3650
# 作成する証明書の有効期限を延ばす
default_crl_days= 30 # how long before next CRL
default_md = sha1 # which md to use.
preserve = no # keep passed DN ordering
# A few difference way of specifying how similar the request should look
# For type CA, the listed attributes must be the same, and the optional
# and supplied fields are just that :-)
#policy = policy_match
policy = policy_anything
# サーバー証明書に必須の項目を減らす
# For the CA policy
(後略)
|
次に作業用のディレクトリとその他必要なファイルを作成する。
$ cd ~
$ mkdir demoCA
$ cd demoCA
$ touch index.txt
$ echo 01 >serial
$ mkdir private
$ cp $HOME/.rnd private/.rand
$ mkdir newcerts
|
次に、先ほど上で変更したopenssl.cnfと、また前回作ったサーバー証明書要求webdav.csrをホームデイレクトリに置いて、次のコマンドを実行する。
$ cd ~
$ sudo openssl ca -config openssl.cnf -out webdav.pem -in webdav.csr
|
下のように確認の質問をしてくるので"y"で答える。
Using configuration from openssl.cnf
Check that the request matches the signature
Signature ok
Certificate Details:
Serial Number: 1 (0x1)
Validity
Not Before: Mar 1 12:34:56 2012 GMT
Not After : Feb 27 12:34:56 2022 GMT
Subject:
commonName = MY_SERVER_URL.jp
X509v3 extensions:
X509v3 Basic Constraints:
CA:FALSE
Netscape Comment:
OpenSSL Generated Certificate
X509v3 Subject Key Identifier:
01:23:45:67:89:AB:CD:EF:01:23:45:67:89:AB:CD:EF:01:23:45:67
X509v3 Authority Key Identifier:
DirName:/CN=ubuntu
serial:01:23:45:67:89:AB:CD:EF
Certificate is to be certified until Feb 27 12:34:56 2022 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
$
|
$ openssl req -new -config openssl.cnf -key webdav.key -out webdav.csr
|
5.サーバー証明書と、サーバーの秘密鍵、公開鍵を、Apacheに設定する。
上記でホームディレクトリにサーバ証明書webdav.pemができる。
これとサーバー用の秘密鍵をApacheから使うために次のように移動する。
$ sudo mv webdav.key /etc/ssl/private/
$ sudo chown root:ssl-cert /etc/ssl/private/webdav.key
$ sudo chmod 0640 /etc/ssl/private/webdav.key
$ sudo mv webdav.pem /etc/apache2/ssl/
$ sudo chown root:root /etc/apache2/ssl/webdav.pem
$ sudo chmod 0644 /etc/apache2/ssl/webdav.pem
|
Apacheの側の設定ファイル /etc/apache2/sites-available/default-ssl も変える。
(前略)
#SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
#SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
SSLCertificateFile /etc/apache2/ssl/webdav.pem
SSLCertificateKeyFile /etc/ssl/private/webdav.key
(後略)
|
ふう、やっと直した証明書をインストールできた。
« UbuntuでWebDAVサーバーその12(自己署名証明書6) |
トップページ
| WebDAVサーバー、Unicode正規化(NFC,NFD)の統一 »
« UbuntuでWebDAVサーバーその12(自己署名証明書6) |
トップページ
| WebDAVサーバー、Unicode正規化(NFC,NFD)の統一 »
コメント