■ 準備
まずはソフトウェアの入手から行きましょう。
http://www.apache.org/
http://www.openssl.org/
http://sunfreeware.com/
上記のサイトで以下のソフトウェアをダウンロードする。とりあえず/var/tmpディレクトリあたりに置いておきましょう
gcc-3.2.2-sol9-sparc-local.gz
httpd-2.0.47.tar.gz
openssl-0.9.7b.tar.gz
■ GCCのインストール
フリーソフトをコンパイルするときには常識です。既にインストールされている場合(バージョンは不問)は飛ばしてください。パスの設定だけは忘れずに!!
# gunzip gcc-3.2.2-sol9-sparc-local.gz # pkgadd -d gcc-3.2.2-sol9-sparc-local ... ...(デフォルトで/usr/local以下にインストールされます) |
【パスの設定】
# PATH=$PATH:/usr/ccs/bin:/usr/local/bin # export PATH |
■ opensslのインストール
こちらも既にインストールされているかもしれませんが、なければ以下のようにコンパイル&インストールする。
# gunzip openssl-0.9.7b.tar.gz # tar xvf openssl-0.9.7b.tar ... # cd openssl-0.9.7b # ./config ... # make ... # make test ... ... OpenSSL 0.9.7b 10 Apr 2003 built on: Tue Sep 16 16:10:19 JST 2003 platform: solaris-sparcv9-gcc options: bn(64,32) md2(int) rc4(ptr,char) des(idx,cisc,16,long) idea(int) blowfish(ptr) compiler: gcc -DOPENSSL_SYSNAME_ULTRASPARC -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -DOPENSSL_NO_KRB5 -m32 -mcpu=ultrasparc -O3 -fomit-frame-pointer -Wall -DB_ENDIAN -DBN_DIV2W -DMD5_ASM OPENSSLDIR: "/usr/local/ssl" `test' is up to date. # # make install # |
■ apacheのインストール
Solaris標準のapacheとは別のディレクトリ(/usr/local/apache2)にインストールされるので設定ファイルやデータの待避の必要はありません。そのままインストールし、動作確認後、細かな設定やコンテンツの移行を行えばいいでしょう。
# gunzip httpd-2.0.47.tar.gz # tar xvf httpd-2.0.47.tar ... # cd httpd-2.0.47 # ./configure --disable-ipv6 --enable-ssl --with-ssl=/usr/local/ssl ... # make ... # make install ... |
# cd /usr/local/apache2/bin # ./httpd -l Compiled in modules: core.c mod_access.c mod_auth.c mod_include.c mod_log_config.c mod_env.c mod_setenvif.c mod_ssl.c prefork.c http_core.c mod_mime.c mod_status.c mod_autoindex.c mod_asis.c mod_cgi.c mod_negotiation.c mod_dir.c mod_imap.c mod_actions.c mod_userdir.c mod_alias.c mod_so.c |
# pwd /usr/local/ssl/bin # ./openssl md5 * > rand.dat # ls c_rehash openssl rand.dat # cat rand.dat MD5(c_rehash)= eac0ca00fc9a2033152ec6408d489f6b MD5(openssl)= d4e3eed34246d6701d35a551ed04189e |
# ./openssl genrsa -des3 -rand rand.dat -out server.key 1024 95 semi-random bytes loaded Generating RSA private key, 1024 bit long modulus ...........++++++ ...............................++++++ e is 65537 (0x10001) Enter pass phrase for server.key:xxxxxxxxxx Verifying - Enter pass phrase for server.key:xxxxxxxxxx # # cat server.key -----BEGIN RSA PRIVATE KEY----- Proc-Type: 4,ENCRYPTED DEK-Info: DES-EDE3-CBC,E4EC26811DF474CF 7bmZha5l6m+13gcVcWBLpUL72VpcpMdhczps8HmJSs56dfqBF49a8wFMh5dUdVt8 c4m31l7t9UYy6pZnJ2aqXT6hKTb2ErpQKFuPEhr8og8hvGAeBbwxtn9UZH119Cfs t9aH8EZndAut2bB9ks7/I/KXFxOiNQj/5XzddWlgIG0YVRvSyb8Iq10fAFaVTRCF vWlRtb4o5bcfrAwJy2QVWLrvJagLg9nGN5K162nPGpp16g2qgcEvom9yCWHhrk2N gPnUtZZPwnAINUeQgqumT4KZC4HIGUsM2cRFNlNvCltgyECRe3F4p5d/h0x+H880 Orod8YGoAokRJQ/y2PcXe3eZOUcxRCG2EQvJO9jky1uy0b7sPo5tE9qyqAQdt4ER eQzKWfzFBk3ctC3CjibrOgTmtHfCGtbralPjcZvhd7fNUjcpch8N7GVqkupr3Bd4 eXEz93i3B+U5tJgezYQ95IYk5lzCKb0F5WKjzX6FX1NHamE+qmALOh7V00qXr8Nv U6DsEUpFzK6LG8EI8i7if1ODWAOmU5G4EaXhdJ4FWuysh1x2oGJBhhTchRDV/ib8 5qNCsbWnJ0v1CZSgXfJRQ/ZY/xku1kHttqN92ubpmaByoA/GmuhdyoKwuJ3x9eqG sju9vu91q6ACo/sogQWd6BMSz5C2Iwbab+Jta6xYnlVmUJbo0MfkPSIMvGZX+tH4 6aA6RGzIFUbP1cPVoIA3DG/56jsqbkCVG7u2YfuTMVQcSQ+hhf+4J4/RbYxRWFYC s3/D0c0+nYOe9kPQ+1rZp3tMjIqUK4snCZ5rULaT9c2cx5qg8lJS1A== -----END RSA PRIVATE KEY----- # |
# ./openssl req -new -key server.key -out server.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) [AU]:JP State or Province Name (full name) [Some-State]:TOKYO Locality Name (eg, city) []:Shibuya Organization Name (eg, company) [Internet Widgits Pty Ltd]: Organizational Unit Name (eg, section) []: Common Name (eg, YOUR name) []:www.apache-test.com Email Address []:hogehoge@apache-test.com Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []: An optional company name []: # -----CSRの中身--------- # ./openssl req -in server.csr -text Certificate Request: Data: Version: 0 (0x0) Subject: C=JP, ST=TOKYO, L=Shibuya, O=Internet Widgits Pty Ltd, CN=www.apache-test.com/emailAddress=hogehoge@apache-test.com Subject Public Key Info: Public Key Algorithm: rsaEncryption RSA Public Key: (1024 bit) Modulus (1024 bit): 00:c3:3b:f6:ce:1f:41:6f:f4:b4:53:76:f7:43:68 54:a0:09:c3:67:f2:c1:6c:c0:e9:50:ca:d3:7a:81: ab:6d:fe:ce:46:1b:17:3f:cf:8f:3a:87:0e:40:f5: 9b:29:79:6f:38:66:bd:e5:bb:2e:9e:e0:b1:b3:e4: 54:de:53:e1:b6:6d:9b:fa:e0:46:72:2e:33:a1:72: 42:06:57:1b:09:7e:90:ac:12:1e:16:8c:d6:07:87: ea:84:45:0b:00:cf:4a:6b:67:7a:48:81:75:62:56: c6:74:70:75:71:a1:93:4a:39:d2:c5:e4:5f:1a:66: 16:63:20:5b:8a:ef:af:d0:fb Exponent: 65537 (0x10001) Attributes: Signature Algorithm: md5WithRSAEncryption 79:3f:57:c3:fb:5e:74:a4:52:6d:23:18:0a:e3:73:d9:c2:60: 6f:d0:3a:4a:5c:de:6b:15:2d:67:95:5b:51:e3:61:ea:58:1d: b4:52:3e:6a:75:c2:e1:9c:83:e0:1c:62:f8:a4:e8:ec:00:d4: b7:d2:10:1d:3a:fa:60:48:6c:2c:5e:40:7f:54:b2:cc:0e:19: 5c:32:9a:58:84:53:4a:e2:f2:59:bf:d0:59:35:1d:4c:9d:8a: 7c:8d:3b:13:38:0a:86:b4:01:bc:4c:80:66:f7:a7:4f:86:6f: 74:85:a1:9c:79:63:0c:d4:a5:86:e0:f5:bb:33:33:d8:8b:46: 1a:47 -----BEGIN CERTIFICATE REQUEST----- MIIB8TCCAVoCAQAwgYIxCzAJBgNVBAYTAkpQMQ4wDAYDVQQIEwVUT0tZTzEOMAwG A1UEBxMFRnVjaHUxITAfBgNVBAoTGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDEV MBMGA1UEAxMMU2FubWFpIEt1cm91MRkwFwYJKoZIhvcNAQkBFgp0ZXN0QGJsYWRl MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDDO/bOH0Fv9LRTdvdDaFSgCcNn 8sFswOlQytN6gatt/s5GGxc/z486hw5A9ZspeW84Zr3luy6e4LGz5FTeU+G2bZv6 4EZyLjOhckIGVxsJfpCsEh4WjNYHh+qERQsAz0prZ3pIgXViVsZ0cHVxoZNKOdLF 5F8aZhZjIFuK76/Q+wIDAQABoC4wEwYJKoZIhvcNAQkCMQYTBGhvZ2UwFwYJKoZI hvcNAQkHMQoTCGhvZ2Vob2dlMA0GCSqGSIb3DQEBBAUAA4GBAHk/V8P7XnSkUm0j GArjc9nCYG/QOkpc3msVLWeVW1HjYepYHbRSPmp1wuGcg+AcYvik6OwA1LfSEB06 +mBIbCxeQH9UsswOGVwymliEU0ri8lm/0Fk1HUydinyNOxM4Coa0AbxMgGb3p0+G b3SFoZx5YwzUpYbg9bszM9iLRhpH -----END CERTIFICATE REQUEST----- |
■ プライベートCA作成のための準備作業
# cd /usr/local/ssl # cp -r /var/tmp/openssl-0.9.7/apps/demoCA /usr/local/ssl/CA # chmod 700 CA # cd CA # mv cacert.pem cacert.pem.org # cd private/ # mv cakey.pem cakey.pem.org # cp /usr/local/ssl/openssl.cnf /usr/local/ssl/CA/ # cd /usr/local/ssl/CA/ # vi openssl.cnf ... #dir = ./demoCA # Where everything is kept <-- コメントアウト dir = /usr/local/ssl/CA # Where everything is kept <-- 追加 |
# cd /usr/local/ssl/CA # openssl req -new -x509 -key private/cakey.pem -out cacert.pem Enter pass phrase for private/ca.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]:TOKYO Locality Name (eg, city) []:Shibuya Organization Name (eg, company) [Internet Widgits Pty Ltd]: Organizational Unit Name (eg, section) []: Common Name (eg, YOUR name) []:www.apache-test.com Email Address []:hogehoge@apache-test.com |
# mkdir /usr/local/ssl/CA/newcerts # openssl ca -config ./openssl.cnf -policy policy_anything -in /usr/local/ssl/bin/server.csr -out server.crt Using configuration from ./openssl.cnf Enter pass phrase for /usr/local/ssl/CA/private/cakey.pem: Check that the request matches the signature Signature ok Certificate Details: Serial Number: 286 (0x11e) Validity Not Before: Sep 16 09:08:03 2003 GMT Not After : Sep 15 09:08:03 2004 GMT Subject: countryName = JP stateOrProvinceName = TOKYO localityName = Shibuya organizationName = Internet Widgits Pty Ltd commonName = www.apache-test.com emailAddress = hogehoge@apache-test.com X509v3 extensions: X509v3 Basic Constraints: CA:FALSE Netscape Comment: OpenSSL Generated Certificate X509v3 Subject Key Identifier: 89:9D:C3:1F:25:8E:0C:BE:24:78:C7:4F:96:F3:95:27:38:D7:8F:FD X509v3 Authority Key Identifier: keyid:31:D6:FD:C5:60:D8:CC:55:8E:A8:C3:68:54:D1:38:A2:9E:0E:BF:D0 DirName:/C=JP/ST=Tokyo/L=Shibuya/O=Internet Widgits Pty Ltd/CN=www.apache-test.com/emailAddress=hogehoge@apache-test.com serial:00 Certificate is to be certified until Sep 15 09:08:03 2004 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 # |
# cp /usr/local/ssl/bin/server.* /usr/local/apache2/conf # cp /usr/local/ssl/CA/server.crt /usr/local/apache2/conf |
# cat /usr/local/apache2/conf/httpd.conf ... <IfModule mod_ssl.c> Include conf/ssl.conf </IfModule> ... |
# cat /usr/local/apache2/conf/ssl.conf ... ... 以下の太字のあたりを修正 #<VirtualHost _default_:443> <VirtualHost 192.168.1.3:443> # General setup for the virtual host DocumentRoot "/usr/local/apache2/htdocs" ServerName www.apache-test.com ServerAdmin hogehoge@apache-test.com ErrorLog logs/error_log TransferLog logs/access_log ... SSLCertificateFile /usr/local/apache2/conf/server.crt SSLCertificateKeyFile /usr/local/apache2/conf/server.key ... |
# /usr/local/apache2/bin/apachectl startssl ... ...※パスフレーズの入力が必要 正しく起動しているか確認する # tail -f /usr/local/apache2/logs/error_log # ps -ef | grep httpd |
# PATH=$PATH:/usr/local/ssl/bin # export PATH # cd /usr/local/apache2/conf # openssl rsa -in server.key -out server.key Enter pass phrase for server.key: <-- パスフレーズの入力 writing RSA key # ちなみに中身はこんな感じになります。(ていうか公開しちゃまずいかな?) # cat server.key -----BEGIN RSA PRIVATE KEY----- MIICXAIBAAKBgQDDO/bOH0Fv9LRTdvdDaFSgCcNn8sFswOlQytN6gatt/s5GGxc/ z486hw5A9ZspeW84Zr3luy6e4LGz5FTeU+G2bZv64EZyLjOhckIGVxsJfpCsEh4W jNYHh+qERQsAz0prZ3pIgXViVsZ0cHVxoZNKOdLF5F8aZhZjIFuK76/Q+wIDAQAB AoGAe+Y3J/Jv/dPnCL0MCIxSgEoR54sIs7LtnqdJdIqMN78oOxeANq/LbtI8+n6j 3LtDGSEizINw/8ULIWX7cij7qUOBkRRo4n6RM6tSfE1VhrRL7Nx3hVzBXnEYJqyi q+u9+r3wUll4b/WaAKrwXqBmNcgRQE6vsFs+LqdUSEGuXokCQQD9dTrzsm4LwPMG 4YjmrUu9Ih6+qeY8cKhiB6J5Pp0eeGLs6xiivpmM8gaI4RkW71DQrWaBAMIlTgDU jWjRO+blAkEAxTE9nO4vFrlnIhLuUF4OvxuC9uPThFKdmgsKMZ8SUqcqXQ6iY2ov yGIxlyMhVL8t1Sm6aUvGOM1lGYe1Ufx6XwJACM5a5v6rDiN9Dh8l54Xb3M1jrhIv Gqh7YTSMs5O2V8ms/jhI2davdRMvoO/ZNE/KSgXMSu0g0bT9GGV1X9ep9QJAECO7 m0CTchSysENEZieMpW+nBHYZNdddNuJ4bx9J7KHqAbvU5rYmOwxuaqRhcgJDyhKk Q0IEc1m8UJ6e5Jr5mQJBALPsZxEJ7c2hSxT2oKAmZlfqOu+7Ly54lazEtPUX/chp VXQQWJTE7DjtAe24dejVC4a6oiDPpy9UsSlnfknj/WQ= -----END RSA PRIVATE KEY----- |
# vi /usr/local/apache2/conf/httpd.conf ... ...以下コメントアウト #<IfModule mod_ssl.c> # Include conf/ssl.conf #</IfModule> 以下を追加 Listen 443 AddType application/x-x509-ca-cert .crt AddType application/x-pkcs7-crl .crl SSLSessionCache dbm:logs/ssl_scache SSLSessionCacheTimeout 300 SSLMutex file:logs/ssl_mutex SSLRandomSeed startup builtin SSLRandomSeed connect builtin <VirtualHost 192.168.1.3:443> DocumentRoot "/usr/local/apache2/htdocs" ServerName www.apache-test.com ServerAdmin hogehoge@apache-test.com ErrorLog logs/error_log TransferLog logs/access_log SSLEngine on SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2: +EXP:+eNULL SSLCertificateFile /usr/local/apache2/conf/server.crt SSLCertificateKeyFile /usr/local/apache2/conf/server.key <Files ~ "\.(cgi|shtml|phtml|php3?)$"> SSLOptions +StdEnvVars </Files> <Directory "/usr/local/apache2/cgi-bin"> SSLOptions +StdEnvVars </Directory> SetEnvIf User-Agent ".*MSIE.*" \ nokeepalive ssl-unclean-shutdown \ downgrade-1.0 force-response-1.0 CustomLog logs/ssl_request_log \ "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b" </VirtualHost> </IfDefine> ... ... |
デフォルトの起動スクリプトを念のためコピーしておく。 # cp /etc/init.d/apache /etc/init.d/apache.org 以下のように編集すれば/etc/rcS.d、/etc/rc2.d、/etc/rc3.d ...などの起動スクリプトはハードリンクされたままなので編集の必要はない。 元に戻すときもapache.orgをapacheに上書きコピーすればよい。 # cat /etc/init.d/apache #!/sbin/sh APACHE_HOME=/usr/local/apache2 CONF_FILE=/usr/local/apache2/conf/httpd.conf PIDFILE=/usr/local/apache2/logs/httpd.pid if [ ! -f ${CONF_FILE} ]; then exit 0 fi case "$1" in start) /bin/rm -f ${PIDFILE} cmdtext="starting" ;; restart) cmdtext="restarting" ;; stop) cmdtext="stopping" ;; *) echo "Usage: $0 {start|stop|restart}" exit 1 ;; esac echo "httpd $cmdtext." status=`${APACHE_HOME}/bin/apachectl $1 2>&1` if [ $? != 0 ]; then echo "$status" exit 1 fi exit 0 |
Solaris 11.2 システムハンドブック |
Oracle Solaris 11 試験対策本(OCA) |