- 追加された行はこの色です。
- 削除された行はこの色です。
CONTENTS
#contents
----
Lastmodified &lastmod;
----
*証明書の更新ができなくなったった!Σ(゚д゚lll) [#p9565117]
CACertから「サーバ証明書の期限がきれるお」っちうメールがきたので、いつものようにCACertへアクセスして、
更新にチェックして実行する・・・も、
以下の証明書を更新しています:
Processing request 514883:
The keys that you use are very small and therefore insecure. Please generate stronger keys.
More information about this issue can be found in the wiki
と怒られた。で、Wikiを見ると
https://wiki.cacert.org/WeakKeys#SmallKey
Cause: Small Key Size
If the key is too small:
The keys that you use are very small and therefore insecure. Please generate stronger keys.
Currently 2048 bit key size with an exponent of at least 65537 is recommended (see <NIST>)
More information about this issue can be found in How to prevent Small Key size and Suggest Key Sizes
という、お達し。手元のキーが作ったキーが、1024 bit だったのが駄目らしい。
ということで、作り直し!( ̄^ ̄)ゞ
**新しいserver.key(2048bit)を作る [#faf5dc41]
コマンドは、こう。前は、1024 54002 とか指定してたのを、2048だけにしてみる。
/usr/bin/openssl genrsa -rand /var/log/messages -des3 -out /usr/local/etc/apache22/server.key 2048 semi-random bytes loaded
実際には、こんな風。
root@mail:/usr/local/etc/apache22 # /usr/bin/openssl genrsa -rand /var/log/messages -des3 -out /usr/local/etc/apache22/server.key 2048 semi-random bytes loaded 43223 semi-random bytes loaded
Generating RSA private key, 2048 bit long modulus
......................+++
..........................................................................................................................................+++
e is 65537 (0x10001)
Enter pass phrase for /usr/local/etc/apache22/server.key: パスフレーズを打ちます
Verifying - Enter pass phrase for /usr/local/etc/apache22/server.key: も一回パスフレーズを打つ、ヨロシ
すると、server.key 出来るアル。
root@mail:/usr/local/etc/apache22 # ll
total 92
drwxr-xr-x 2 root wheel 512 Nov 12 17:19 Includes/
drwxr-xr-x 2 root wheel 512 Nov 12 17:19 envvars.d/
drwxr-xr-x 2 root wheel 512 Nov 12 17:19 extra/
-rw-r--r-- 1 root wheel 17056 Jul 26 11:26 httpd.conf
-rw-r--r-- 1 root wheel 12958 Nov 12 17:19 magic
-rw-r--r-- 1 root wheel 53011 Nov 12 17:19 mime.types
-rw-r--r-- 1 root wheel 1743 Nov 30 16:15 server.key
**CACert 提出用 server.scr を作るアル [#h6232dde]
root@mail:/usr/local/etc/apache22 # /usr/bin/openssl req -new -key /usr/local/etc/apache22/server.key -out /usr/local/etc/apache22/server.csr
Enter pass phrase for /usr/local/etc/apache22/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) [AU]:JP ←日本なのでJP
State or Province Name (full name) [Some-State]:EHIME ←取り敢えず
Locality Name (eg, city) []:MATSUYAMA ←取り敢えず
Organization Name (eg, company) [Internet Widgits Pty Ltd]:SMB_Films ←取り敢えず
Organizational Unit Name (eg, section) []:
Common Name (e.g. server FQDN or YOUR name) []:mail.kuji-clinic.net ←取り敢えず
Email Address []:********@smb.net ←取り敢えず連絡先
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
root@mail:/usr/local/etc/apache22 #
で、出来上がった server.csr を https://www.cacert.org/ へ持ってって server.cert を貰ってくる。
更新できるかどうか、試して観たらOKだった。
----
k222 のserver.crtを更新したら、apacheが落ちた。再起動不可能になった。古いのにもどしたら、なおった
May 31 06:00:00 k222 newsyslog[75667]: logfile turned over
[Tue May 31 06:15:02 2011] [warn] RSA server certificate CommonName (CN) `kuji- clinic.net' does NOT match server name!?
[Tue May 31 06:15:02 2011] [error] Unable to configure RSA server private key
[Tue May 31 06:15:02 2011] [error] SSL Library Error: 185073780 error:0B080074:x509 certificate routines:X509_check_private_key:key values mismatch
----
pianoでapachectl restart したら、
[Sat Aug 21 03:58:54 2010] [warn] RSA server certificate CommonName (CN) `piano.smb.net' does NOT match server name!?
[Sat Aug 21 03:58:54 2010] [error] Unable to configure RSA server private key
[Sat Aug 21 03:58:54 2010] [error] SSL Library Error: 185073780 error:0B080074:x509 certificate routines:X509_check_private_key:key values mismatch
と言われ、Apacheが起動できなくなった。ググると「鍵と証明書のmodulusが不一致」なのだそうだ。modulusを見るには
181 5:24 openssl rsa -noout -text -in server.key -modulus
182 5:24 openssl x509 -noout -text -in server.crt -modulus
で、久々にキーを生成
----
*SSL を設置するメモ [#cdeccb71]
**秘密鍵生成[/usr/local/etc/apache22/ssl.key/www.smb.net.key] [#ua4fb3d0]
# cd /usr/local/etc/apache22/ssl.key/
# /usr/bin/openssl genrsa -rand /var/log/messages -des3 \
-out /usr/local/etc/apache22/ssl.key/server.key 1024 54002 \
semi-random bytes loaded
Generating RSA private key, 1024 bit long modulus
....++++++
.............++++++
e is 65537 (0x10001)
Enter pass phrase for
/usr/local/etc/apache22/ssl.key/www.smb.net.key:*********
Verifying - Enter pass phrase for
/usr/local/etc/apache22/ssl.key/www.smb.net.key:*********
# chmod 600 server.*
**CSR(証明書申請データ)生成[/usr/local/etc/apache22/ssl.key/server.csr] [#a84ed725]
# /usr/bin/openssl req -new -key \
/usr/local/etc/apache22/server.key \
-out /usr/local/etc/apache22/ssl.key/server.csr
Enter pass phrase for \
/usr/local/etc/apache22/ssl.key/www.smb.net.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) [AU]:JP
State or Province Name (full name) [Some-State]:EHIME
Locality Name (eg, city) []:MATSUYAMA
Organization Name (eg, company)
[Internet Widgits Pty Ltd]:CAcert Inc.
Organizational Unit Name (eg, section) []:
Common Name (eg, YOUR name) []:ここは、ドメインやマシン名がわかる名前の方がよい piano.smb.net
Email Address []:
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
CSRは、認証局(CA)に渡す
ものなので、これを cat で表示させて、その内容を範囲コピーしておきます。
**CAcert.orgのサーバー証明書に登録 [#i7d6218f]
http://www.cacert.org/index.php?id=0&lang=ja_JP
まずはhttp://www.cacert.org/へアクセス。右のメニューのTransrations で日本語を :)
ドメインの指定は、上記のCSRを作成する時に指定した
Common Name (eg, YOUR name)
の部分に相当しますので、自動で登録されることになります。
サーバ証明書の新規作成をクリックします。
下にCSRをペーストしてください。
と書かれている部分に、CSRの内容をそのままコピーします。
私は、CAcertの保証制度には協力していないので、詳細な情報は出ませんが、そもそもそんな情報を欲するようなユーザが利用する用途では用いていないので無視して大丈夫。
送信を選択すると、SSLにするFQDNが表示され、その先に進めると、キーができあがってきました
左のような部分をコピーし、
/usr/local/etc/apache2/ssl.key/にserver.crt
として、保存します。
(eeでもviでもいいので、これを新規で作成します)
それが完了したら、同ディレクトリにあるものを
# chmod 600 server.*
してキーの生成は完了です。
これだけですと、Apacheの開始時に毎回パスフレーズを求められるようになってしまいますので、これをあらかじめ解消して使うことにしています。
# cd /usr/local/etc/apache22/ssl.key/
# mv server.key server.key.orig
# openssl rsa -in server.key.orig -out server.key
Enter pass phrase for www.smb.net.key.orig:*********
writing RSA key
# chmod 600 server.*
これで必要な鍵はそろいました。
**[ ssl.confの設定 ] [#v2cbf05c]
設定ファイルの待避
# cd /usr/local/etc/apache22/extra
# cp httpd-ssl.conf httpd-ssl.conf-dist
/usr/local/etc/apache22/extra/httpd-ssl.conf の最低限?の設定
Listen 443
AddType application/x-x509-ca-cert .crt
AddType application/x-pkcs7-crl .crl
SSLPassPhraseDialog builtin
SSLSessionCache "shmcb:/var/run/ssl_scache(512000)"
SSLSessionCacheTimeout 300
SSLMutex "file:/var/run/ssl_mutex"
## SSL Virtual Host Context
<VirtualHost _default_:443>
# General setup for the virtual host
DocumentRoot "/usr/local/www/apache22/data"
ServerName www.smb.net:443
ServerAdmin webmaster@smb.net
ErrorLog "/var/log/httpd-error.log"
TransferLog "/var/log/httpd-access.log"
SSLEngine on
SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
SSLCertificateFile /usr/local/etc/apache22/ssl.crt/www.smb.net.server.crt
SSLCertificateKeyFile /usr/local/etc/apache22/ssl.key/www.smb.net.key
SSLCertificateKeyFile "/usr/local/etc/apache22/ssl.key/www.smb.net.key"
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory "/usr/local/www/apache22/cgi-bin">
SSLOptions +StdEnvVars
</Directory>
BrowserMatch ".*MSIE.*" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
CustomLog "/var/log/httpd-ssl_request.log" \
"%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
</VirtualHost>
のように指定します。
/etc/rc.confには
apache22_enable="YES"
apache22ssl_enable="YES"
を入れておきましょう。
ページを参照して、確認すると128bitのSSLで接続されていることが確認できたと思います。
**Tips [#vd104a6e]
***CSRのCNとアクセス先のFQDNを合わせ [#v6bd5f18]
ておかないと、「証明書のエラー アドレスが一致しません」と言われます
ちなみに証明書と鍵の確認方法、証明書の内容を見る方法は
openssl x509 -noout -text -in filename.crt
秘密鍵の内容を見る方法は
openssl rsa -noout -text -in filename.key
----
http://freebsd.fkimura.com/cacert-a0.html
----
#counter([total|today|yesterday]);
&lastmod;
----
Total access &counter(total);:本日 &counter(today);:昨日 &counter(yesterday);
#counter([total|today|yesterday]);