証明書の確認方法 †1つのサーバに、2つVirtualHost?/1つIPがあり、各ドメイン別のSSLを設定する方法 †一つのファイルに NameVirtualHost *:443 <VirtualHost *:443> hogehoge </VirtualHost> <VirtualHost *:443> hogehoge2 </VirtualHost> とするとよい ↑これはうそ。出来なかった… 1つのサーバに、2つVirtualHost?/2つIPがあり、各ドメイン別のSSLを設定する方法 †用意するのは4つの設定ファイル
a.domain.com †#NameVirtualHost * <VirtualHost *> ServerAdmin webmaster@localhost <= 変える所 ServerName a.domain.com <= 変える所 DocumentRoot /var/www/projectA <= 変える所 <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/www/projectA/> <= 変える所 Options FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory> ErrorLog /var/log/apache2/error.a.log <= 変える所 LogLevel warn CustomLog /var/log/apache2/access.a.log combined <= 変える所 ServerSignature Off </VirtualHost> b.domain.com †#NameVirtualHost * <VirtualHost *> ServerAdmin webmaster@localhost <= 変える所 ServerName b.domain.com <= 変える所 DocumentRoot /var/www/projectB <= 変える所 <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/www/projectB/> <= 変える所 Options FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory> ErrorLog /var/log/apache2/error.b.log <= 変える所 LogLevel warn CustomLog /var/log/apache2/access.b.log combined <= 変える所 ServerSignature Off </VirtualHost> ssl.a.domain.com †Listen XXX.XXX.XXX.XX1:443 <= 変える所 AddType application/x-x509-ca-cert .crt AddType application/x-pkcs7-crl .crl SSLPassPhraseDialog builtin SSLSessionCache shmcb:/var/run/apache2/ssl_scache(512000) SSLSessionCacheTimeout 300 SSLMutex file:/var/run/apache2/ssl_mutex <VirtualHost XXX.XXX.XXX.XX1:443> <= 変える所 DocumentRoot "/var/www/projectA" <= 変える所 ServerName a.domain.com:443 <= 変える所 ServerAdmin webmaster@localhost <= 変える所 ErrorLog /var/log/apache2/error.a.ssl.log <= 変える所 TransferLog /var/log/apache2/access.a.ssl.log <= 変える所 SSLEngine on SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL SSLCertificateFile /etc/apache2/ssl/a.domain.com/2009.crt <= 変える所 SSLCertificateKeyFile /etc/apache2/ssl/a.domain.com/20091.key <= 変える所 <FilesMatch "\.(cgi|shtml|phtml|php)$"> SSLOptions +StdEnvVars </FilesMatch> <Directory "/usr/lib/cgi-bin"> SSLOptions +StdEnvVars </Directory> BrowserMatch ".*MSIE.*" \ nokeepalive ssl-unclean-shutdown \ downgrade-1.0 force-response-1.0 CustomLog /var/log/apache2/ssl_request_log \ "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b" </VirtualHost> ssl.b.domain.com †Listen XXX.XXX.XXX.XX2:443 <= 変える所 AddType application/x-x509-ca-cert .crt AddType application/x-pkcs7-crl .crl SSLPassPhraseDialog builtin SSLSessionCache shmcb:/var/run/apache2/ssl_scache(512000) SSLSessionCacheTimeout 300 SSLMutex file:/var/run/apache2/ssl_mutex <VirtualHost XXX.XXX.XXX.XX2:443> <= 変える所 DocumentRoot "/var/www/projectB" <= 変える所 ServerName b.domain.com:443 <= 変える所 ServerAdmin webmaster@localhost <= 変える所 ErrorLog /var/log/apache2/error.b.ssl.log <= 変える所 TransferLog /var/log/apache2/access.b.ssl.log <= 変える所 SSLEngine on SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL SSLCertificateFile /etc/apache2/ssl/b.domain.com/2009.crt <= 変える所 SSLCertificateKeyFile /etc/apache2/ssl/b.domain.com/20091.key <= 変える所 <FilesMatch "\.(cgi|shtml|phtml|php)$"> SSLOptions +StdEnvVars </FilesMatch> <Directory "/usr/lib/cgi-bin"> SSLOptions +StdEnvVars </Directory> BrowserMatch ".*MSIE.*" \ nokeepalive ssl-unclean-shutdown \ downgrade-1.0 force-response-1.0 CustomLog /var/log/apache2/ssl_request_log \ "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b" </VirtualHost> 自前局認証での手順 †SSL作成 †/usr/lib/ssl/misc/以下にフォルダーを作っておく openssl req -new -text -out server.req Generating a 1024 bit RSA private key ...++++++ .....++++++ writing new private key to 'privkey.pem' Enter PEM pass phrase: Verifying - Enter PEM pass phrase: ----- 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]:Shibuya Organization Name (eg, company) [My Company Ltd]: 会社名 Organizational Unit Name (eg, section) []: 部署名 Common Name (eg, your name or your server's hostname) []: ドメイン名(FQDN) Email Address []: Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []: いれない An optional company name []: いれない
その他 †証明書の確認方法 †秘密鍵: $ openssl rsa -text -noout -in 秘密鍵ファイル 証明書: $ openssl x509 -text -noout -in 証明書ファイル ここで出力されるmodulesとexponentが一致していたらよい。 証明書の切り替えのタイミング †通常はSSLの更新は1ヶ月前ぐらいから受け付けている場合が多く、新規SSLは既存SSLの切れる前に切り替える事で継続的に続いている状況を維持出来る。 |