VMWareä¸ã®Linuxã§ï¼Apacheã«èªå·±ç½²åã®SSLéä¿¡ããããããã®æé ãï¼ãªã¬ãªã¬è¨¼ææ¸ã§ï¼ä»®æ³ãã·ã³ä¸ã®Webãµã¼ãã«HTTPSæ¥ç¶ï¼
Apache Webãµã¼ãã¨ã®éã§ï¼SSLã«ãããæå·åãããéä¿¡ããè¡ãªãã
ãµã¼ãã«ã¢ã¯ã»ã¹ããéã®URLã¯ï¼https://ãããã«ãªãã
ãã®ããã®ç°å¢æ§ç¯ã®æ¹æ³ãã¡ã¢ããæé æ¸ã
æå·åã®ããã®ãµã¼ã証ææ¸ã¯ï¼èªåã§çæãããï¼ï¼ãªã¬ãªã¬è¨¼ææ¸ï¼
ã¾ãï¼éä¿¡ã®å
容ãæå·åããã¦ããæ§åãï¼ãã±ãããã£ããã£ã«ãã£ã¦ç´ã«ç®ã§è¦ã¦ï¼å®å
¨æ§ã確èªããã
- ï¼ï¼ï¼ä»®æ³ãã·ã³ã®Linuxä¸ã«Apacheãå°å ¥
- ï¼ï¼ï¼æå·åããã¦ããªãHTTPéä¿¡ããçè´ãå¯è½ã§ãããã¨ã®ç¢ºèª
- ï¼ï¼ï¼SSLããã±ã¼ã¸ã®æºå
- ï¼ï¼ï¼ç§å¯éµãçæ
- ï¼ï¼ï¼èªå·±ç½²åã«ãããµã¼ã証ææ¸ã®ä½æ
- ï¼ï¼ï¼Apacheã«HTTPSéä¿¡ã®è¨å®ãå®æ½
- ï¼ï¼ï¼æå·åããã¦ããHTTPSéä¿¡ããçè´ãä¸å¯è½ã§ãããã¨ã®ç¢ºèª
ããã§ï¼Apacheã¯Linuxï¼CentOSï¼ä¸ã§åä½ãã¦ããï¼Linuxã¯VMWare Serverä¸ã®ä»®æ³ãã·ã³ã§ããã¨ããã
ãã¹ãå´ã®ãã·ã³ã®ãã©ã¦ã¶ããï¼ä»®æ³ãã·ã³ä¸ã®Webãµã¼ãã«ã¢ã¯ã»ã¹ããã
Webãµã¼ãã«ã¯ãã¡ã¤ã³åãè¨å®ãã¦ãããï¼IPã¢ãã¬ã¹ã ãã使ãã
ï¼ï¼ï¼ä»®æ³ãã·ã³ã®Linuxä¸ã«Apacheãå°å ¥
Linuxä¸ã¸ã®Apacheã®å°å ¥æé ã¯ï¼ä¸è¨ãã¼ã¸ãåç §ã
CentOS 5.6ä¸ã§ Apacheï¼Passengerï¼Ruby on Rails 1.2 ãåä½ãããæé ï¼ä»®æ³ãã·ã³ä¸ã«ï¼ã¬ã¬ã·ã¼Railsã®å®éç¨ç°å¢ãæ§ç¯ï¼
http://language-and-engineering.hatenablog.jp/entry/20110814/p1
- ï¼ï¼ï¼Apacheã®ã¤ã³ã¹ãã¼ã«
- ï¼ï¼ï¼Apacheã®åä½ç¢ºèª
ï¼ï¼ï¼æå·åããã¦ããªãHTTPéä¿¡ããçè´ãå¯è½ã§ãããã¨ã®ç¢ºèª
HTTPãããã³ã«ã§éä¿¡ãã¦ããï¼ã¨ããäºã¯ï¼æå·åããã¦ããªãã®ã§ï¼å 容ã誰ã§ãçã¿è¦ããã¨ãå¯è½ã¨ããäºã ã
ãã®ç¢ºèªãããã
ã¾ãï¼Apacheã®å ¬éãã£ã¬ã¯ã㪠/var/www/html ä¸ã«ï¼ä¸è¨ã®HTMLãè¨ç½®ã
hoge.html
This is secret information.
次ã«ï¼ãã¹ãå´ã®ãã©ã¦ã¶ããï¼ä¸è¨ã®URLã«ã¢ã¯ã»ã¹ã
- http://Linuxã®IPã¢ãã¬ã¹/hoge.html
HTMLã®å 容ãã¡ããã¨è¡¨ç¤ºã§ãããã¨ã確èªããã
â»æ³¨ï¼"information" ã¯åºæ¬çã«ä¸å¯ç®åè©ã
è±èªã®è¬16
http://www.h4.dion.ne.jp/~maimai66/co...
- ãæ¡å æãåä»ãã¨ããå¯ç®åè©ã®æå³ãªãã°informationsã®ããã«ï½ãã¤ãã¦ãåé¡ãªã
次ã«ï¼Linuxä¸ã§ä¸è¨ã®ã³ãã³ããå®è¡ããã
# tcpdump -s0 -i eth0 -X port 80 tcpdump: verbose output suppressed, use -v or -vv for full protocol decode listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes
ã³ã³ã½ã¼ã«ãå¾ ã¡ç¶æ ã«ãªãã
ãªãtcpdumpã¯ï¼ãã±ãããã£ããã£ã®ã³ãã³ãã§ãããï¼Windowsä¸ã®ãã¼ã«ã ã¨Wireshark/Etherealãããï¼
ä¸ã®ã³ãã³ããªãã·ã§ã³ã§ã¯ï¼
- s0ã§ãã£ããã£ãµã¤ãºã«ä¸éãè¨ããªãäºã«ãã¦ããã
- ç£è¦å¯¾è±¡ã®ãããã¯ã¼ã¯ã¢ããã¿ãeth0ã«ãã¦ãããï¼ä»®æ³ç°å¢ã§ãã¹ãã»ã¯ã©ã¤ã¢ã³ãéãã¤ãªãã§ããã¢ããã¿ãé¸ã¶ãã¨ï¼
- HTTPéä¿¡ï¼ã¤ã¾ã80çªã®TCPãã¼ããçµç±ããéä¿¡ã ããç£è¦ããããã«ãã£ã«ã¿ãªã³ã°ãã¦ãããï¼ãããããªãã¨ï¼SSHéä¿¡ãªã©ä»ã®å ¨ãã¼ãã®éä¿¡å 容ããã¡ãã¾ãã«ãªã£ã¦ãã¾ãï¼
tcpdumpã使ã£ã¦ã¿ããï¼
http://linux-biyori.sakura.ne.jp/sett...
ãã®ç¶æ
ã§ï¼ãã©ã¦ã¶ä¸ã§CTRL+F5ãæ¼ä¸ã
ãã©ã¦ã¶ä¸ã§ãã¼ã¸ãå表示ãããã
ããã¦ï¼ã³ã³ã½ã¼ã«ä¸ã§ï¼éä¿¡ããéã®ãã±ããã®å 容ãã¾ããã¨è¡¨ç¤ºãããã
ãã£ãï¼ãã¼ã¸è¡¨ç¤ºããã ãã§ãï¼HTTPéä¿¡ã®ããåãã¯æ°åè¡ããã¦ããã
ãã®ä¸ã«ã¯ï¼ãThis is secret information.ãã¨ãããã¼ã¸ã®é²è¦§å 容ãå«ã¾ãã¦ããã
â»ä¸è¨ã§ã¯ï¼â å°ãä»ãã¦ããç®æã
00:11:16.507676 IP 192.168.19.1.4624 > 192.168.19.128.http: S 2119691136:2119691136(0) win 65535 <mss 1460,nop,nop,sackOK> 0x0000: 4500 0030 2717 4000 8006 2bdf c0a8 1301 E..0'.@...+..... 0x0010: c0a8 1380 1210 0050 7e57 eb80 0000 0000 .......P~W...... 0x0020: 7002 ffff 5f15 0000 0204 05b4 0101 0402 p..._........... 00:11:16.856116 IP 192.168.19.128.http > 192.168.19.1.4624: S 2738300351:2738300351(0) ack 2119691137 win 5840 <mss 1460,nop,nop,sackOK> 0x0000: 4500 0030 0000 4000 4006 92f6 c0a8 1380 E..0..@.@....... 0x0010: c0a8 1301 0050 1210 a337 25bf 7e57 eb81 .....P...7%.~W.. 0x0020: 7012 16d0 7f3d 0000 0204 05b4 0101 0402 p....=.......... 00:11:16.856214 IP 192.168.19.1.4624 > 192.168.19.128.http: . ack 1 win 65535 0x0000: 4500 0028 2718 4000 8006 2be6 c0a8 1301 E..('.@...+..... 0x0010: c0a8 1380 1210 0050 7e57 eb81 a337 25c0 .......P~W...7%. 0x0020: 5010 ffff c2d1 0000 0000 0000 0000 P............. 00:11:16.512547 IP 192.168.19.1.4624 > 192.168.19.128.http: P 1:343(342) ack 1 win 65535 0x0000: 4500 017e 271a 4000 8006 2a8e c0a8 1301 E..~'.@...*..... 0x0010: c0a8 1380 1210 0050 7e57 eb81 a337 25c0 .......P~W...7%. 0x0020: 5018 ffff 57de 0000 4745 5420 2f68 6f67 P...W...GET./hog 0x0030: 652e 6874 6d6c 2048 5454 502f 312e 310d e.html.HTTP/1.1. 0x0040: 0a48 6f73 743a 2031 3932 2e31 3638 2e31 .Host:.192.168.1 0x0050: 392e 3132 380d 0a55 7365 722d 4167 656e 9.128..User-Agen 0x0060: 743a 204d 6f7a 696c 6c61 2f35 2e30 2028 t:.Mozilla/5.0.( 0x0070: 5769 6e64 6f77 7320 4e54 2035 2e31 3b20 Windows.NT.5.1;. 0x0080: 7276 3a31 322e 3029 2047 6563 6b6f 2f32 rv:12.0).Gecko/2 0x0090: 3031 3030 3130 3120 4669 7265 666f 782f 0100101.Firefox/ 0x00a0: 3132 2e30 0d0a 4163 6365 7074 3a20 7465 12.0..Accept:.te 0x00b0: 7874 2f68 746d 6c2c 6170 706c 6963 6174 xt/html,applicat 0x00c0: 696f 6e2f 7868 746d 6c2b 786d 6c2c 6170 ion/xhtml+xml,ap 0x00d0: 706c 6963 6174 696f 6e2f 786d 6c3b 713d plication/xml;q= 0x00e0: 302e 392c 2a2f 2a3b 713d 302e 380d 0a41 0.9,*/*;q=0.8..A 0x00f0: 6363 6570 742d 4c61 6e67 7561 6765 3a20 ccept-Language:. 0x0100: 6a61 2c65 6e2d 7573 3b71 3d30 2e37 2c65 ja,en-us;q=0.7,e 0x0110: 6e3b 713d 302e 330d 0a41 6363 6570 742d n;q=0.3..Accept- 0x0120: 456e 636f 6469 6e67 3a20 677a 6970 2c20 Encoding:.gzip,. 0x0130: 6465 666c 6174 650d 0a43 6f6e 6e65 6374 deflate..Connect 0x0140: 696f 6e3a 206b 6565 702d 616c 6976 650d ion:.keep-alive. 0x0150: 0a50 7261 676d 613a 206e 6f2d 6361 6368 .Pragma:.no-cach 0x0160: 650d 0a43 6163 6865 2d43 6f6e 7472 6f6c e..Cache-Control 0x0170: 3a20 6e6f 2d63 6163 6865 0d0a 0d0a :.no-cache.... 00:11:16.512674 IP 192.168.19.128.http > 192.168.19.1.4624: . ack 343 win 6432 0x0000: 4500 0028 accb 4000 4006 e632 c0a8 1380 E..(..@[email protected].... 0x0010: c0a8 1301 0050 1210 a337 25c0 7e57 ecd7 .....P...7%.~W.. 0x0020: 5010 1920 a85b 0000 P....[.. 00:11:16.513938 IP 192.168.19.128.http > 192.168.19.1.4624: P 1:290(289) ack 343 win 6432 0x0000: 4500 0149 accc 4000 4006 e510 c0a8 1380 E..I..@.@....... 0x0010: c0a8 1301 0050 1210 a337 25c0 7e57 ecd7 .....P...7%.~W.. 0x0020: 5018 1920 3ad8 0000 4854 5450 2f31 2e31 P...:...HTTP/1.1 0x0030: 2032 3030 204f 4b0d 0a44 6174 653a 2057 .200.OK..Date:.W 0x0040: 6564 2c20 3237 204a 756e 2032 3031 3220 ed,.27.Jun.2012. 0x0050: 3135 3a31 313a 3136 2047 4d54 0d0a 5365 15:11:16.GMT..Se 0x0060: 7276 6572 3a20 4170 6163 6865 2f32 2e32 rver:.Apache/2.2 0x0070: 2e33 2028 4365 6e74 4f53 290d 0a4c 6173 .3.(CentOS)..Las 0x0080: 742d 4d6f 6469 6669 6564 3a20 5765 642c t-Modified:.Wed, 0x0090: 2032 3720 4a75 6e20 3230 3132 2030 363a .27.Jun.2012.06: 0x00a0: 3131 3a31 3320 474d 540d 0a45 5461 673a 11:13.GMT..ETag: 0x00b0: 2022 3163 3932 3331 2d31 622d 3135 3030 ."1c9231-1b-1500 0x00c0: 3432 3430 220d 0a41 6363 6570 742d 5261 4240"..Accept-Ra 0x00d0: 6e67 6573 3a20 6279 7465 730d 0a43 6f6e nges:.bytes..Con 0x00e0: 7465 6e74 2d4c 656e 6774 683a 2032 370d tent-Length:.27. 0x00f0: 0a43 6f6e 6e65 6374 696f 6e3a 2063 6c6f .Connection:.clo 0x0100: 7365 0d0a 436f 6e74 656e 742d 5479 7065 se..Content-Type 0x0110: 3a20 7465 7874 2f68 746d 6c3b 2063 6861 :.text/html;.cha 0x0120: 7273 6574 3d55 5446 2d38 0d0a 0d0a 5468 rset=UTF-8....Thãâ 0x0130: 6973 2069 7320 7365 6372 6574 2069 6e66 is.is.secret.inf 0x0140: 6f72 6d61 7469 6f6e 2e ormation. 00:11:16.563991 IP 192.168.19.1.4624 > 192.168.19.128.http: F 343:343(0) ack 290 win 65246 0x0000: 4500 0028 271c 4000 8006 2be2 c0a8 1301 E..('.@...+..... 0x0010: c0a8 1380 1210 0050 7e57 ecd7 a337 26e1 .......P~W...7&. 0x0020: 5011 fede c17a 0000 0000 0000 0000 P....z........ 00:11:16.564352 IP 192.168.19.128.http > 192.168.19.1.4624: F 290:290(0) ack 344 win 6432 0x0000: 4500 0028 accd 4000 4006 e630 c0a8 1380 E..(..@[email protected].... 0x0010: c0a8 1301 0050 1210 a337 26e1 7e57 ecd8 .....P...7&.~W.. 0x0020: 5011 1920 a738 0000 P....8.. 00:11:16.565348 IP 192.168.19.1.4624 > 192.168.19.128.http: . ack 291 win 65246 0x0000: 4500 0028 271e 4000 8006 2be0 c0a8 1301 E..('.@...+..... 0x0010: c0a8 1380 1210 0050 7e57 ecd8 a337 26e2 .......P~W...7&. 0x0020: 5010 fede c179 0000 0000 0000 0000 P....y........
ãã®ããã«ï¼ãã©ã¦ã¶ã¨Webãµã¼ãã®éã§ã®éä¿¡å 容ã¯ï¼æå·åããã¦ããªãã®ã§ï¼éã«åå¨ããNWæ©å¨ã«ããã¦å 容ã丸ãã¨èªã¿åãå¯è½ã§ããã
ãã©ã¦ã¶ã®ã¦ã¼ã¶ã¨ã¼ã¸ã§ã³ãæ å ±ãªã©ããã±ããå ã®HTTPãªã¯ã¨ã¹ããããä¸ã«å«ã¾ãã¦ããã®ã§ï¼ä¸è¨ã§å ¨é¨è¦ãã¦ããã
ããï¼ãã©ã¦ã¶å´ãããã¯ã¬ã¸ããã«ã¼ãã®çªå·ããªã©ã®æ©å¯æ å ±ãWebãµã¼ãã«å¯¾ãã¦POSTãªãããããï¼ãã®æ å ±ã丸ãã¨ï¼éä¸ã®çµè·¯ã§ãã£ããã£ãããã®ã§ããã
ãã®äºãç解ã§ãããï¼ã³ã³ã½ã¼ã«ä¸ã§CTRL+Cãæ¼ä¸ãã¦tcpdumpãåæ¢ããã
â»ãªãï¼ãã£ããã£æ å ±ä¸ã§ãackãã¨æ¸ããã¦ããã®ã¯ï¼TCP/IPéä¿¡ã«ããã¦æ¥ç¶ã確ç«ãããããã®ãµã¤ã³ã ã
éä¿¡ã®ããã¿ï¼TCP/IPï¼
http://www.nina.jp/server/basic/tcpip...
ï¼ï¼ï¼SSLããã±ã¼ã¸ã®æºå
SSLé¢é£ã®ããã±ã¼ã¸ãå ¥ã£ã¦ããã確èªã
# rpm -qa ssl
OpenSSLãmod_sslãã¤ã³ã¹ãã¼ã«ããã¦ããªããã°ï¼ä¸è¨ã®æé ã§ã¤ã³ã¹ãã¼ã«ãå®è¡ããã
# yum install mod_ssl # yum install openssl # openssl version OpenSSL 0.9.8e-fips-rhel5 01 Jul 2008
åèï¼
apache+mod_sslã«ããSSLè¨å®
http://www.server-memo.net/server-set...
ï¼ï¼ï¼ç§å¯éµãçæ
ç§å¯éµã®ç½®ãå ´ãä½ã£ã¦ããï¼ç§å¯éµãçæããã
# mkdir -p /etc/httpd/conf/ssl.key # cd /etc/httpd/conf/ssl.key/ # openssl genrsa -des3 -out server.key 1024
ããããã¨ï¼ãEnter pass phrase for server.key:ãã¨ãã¦ï¼ç§å¯éµã«è¨å®ããããã¹ã¯ã¼ããèãããã
ï¼åãã¹ã¯ã¼ããå ¥åãï¼ãã¹ã¯ã¼ãã¯å³éã«ç®¡çããã
ã«ã¬ã³ããã£ã¬ã¯ããªå ã«ï¼ãserver.keyãã¨ãããã¡ã¤ã«ãä½æããããã¨ã確èªã
ãã®æ¡å¼µå.keyã®ãã¡ã¤ã«ãï¼ç§å¯éµã§ããã大äºã«ä¿ç®¡ãã¹ãã
ç§å¯éµãçã¾ããã¨ï¼æå·åãããéä¿¡ã§ãä¸èº«ãèªã¿åãäºãã§ãã¦ãã¾ãããã
Wiresharkã§SSL復å·ã§ãããã§ãâ
https://www.softbanktech.jp/yko/2010/...
- ãã±ãããã£ããã£ã½ããã«å¯¾ãã¦ç§å¯éµã渡ãäºã«ããï¼æå·åããããã±ããã®å 容ãèªãã¦ãã¾ã
ããã§ï¼ãã¹ã¯ã¼ãä»ãã®ç§å¯éµãéç¨ããã®ãé¢åãªå ´åã¯ï¼ãã¹ã¯ã¼ããªãã®ç§å¯éµãä½ãç´ããã¨ãã§ããã
ãã¹ã¯ã¼ãæãã ã¨ï¼ãµã¼ãã®èµ·åã®ãã³ã«ãã¹ã¯ã¼ãã®å ¥åãå¿ è¦ã«ãªãã®ã§ï¼èªåèµ·åãã§ããªãã®ã ã
ãã ããã¹ã¯ã¼ãããªãå ´åã¯çé£ã»æµåºæã®èª¤ç¨ãªã¹ã¯ãé«ã¾ãã®ã§ï¼ãã®ç¹ã¯æ³¨æãããã¨ã
ãã¹ã¯ã¼ããªãã«ä½ãç´ãæé ï¼
# mv server.key server.key_org # openssl rsa -in server.key_org -out server.key (ãã¹ã¯ã¼ããå ¥å) writing RSA key
ããã§OKã
å®å ¨ã®ããï¼ä»äººããèªã¾ããªãããã«ããã
# chmod 400 server.key
ï¼ï¼ï¼èªå·±ç½²åã«ãããµã¼ã証ææ¸ã®ä½æ
ã¾ãï¼ç½²åè¦è«æ¸ï¼CSRãã¡ã¤ã«ï¼Certificate Signing Requestï¼ãä½ãã
次ã«ï¼ãã®CSRãã¡ã¤ã«ãåºã«èªå·±ç½²åãè¡ãªãï¼ãµã¼ã証ææ¸ï¼CRTãã¡ã¤ã«ï¼ç½²åä»ãå ¬ééµï¼ãä½ãã
äºåã«ï¼æ¡å¼µåããã¡ã¤ã«ã®ç¨®é¡ã«ã¤ãã¦ç解ãã¦ãããæ¹ããããããããªãã
SSLé¢ä¿ã®æ¡å¼µåã¯ãããããã©ããªæå³ãããã®ã
http://q.hatena.ne.jp/1188202204
- å½¹å²ã®éãï¼keyï¼ç§å¯éµï¼csrï¼è¨¼ææ¸çºè¡è¦æ±ï¼crtï¼è¨¼ææ¸
- å½¢å¼ã®éãï¼DER(Distinguished Encoding Rules)å½¢å¼ / PEM(Privacy Enhanced Mail)å½¢å¼ãPEMå½¢å¼ã¯ãDERå½¢å¼ï¼ãã¤ããªï¼ãBASE64ã§å¯è¦åãããã®
PEMå½¢å¼ã®CSRã®ãµãã¼ãçµäºã«ã¤ãã¦
https://www.verisign.co.jp/ssl/about/...
- PEMå½¢å¼ã®CSRï¼-----BEGIN PRIVACY-ENHANCED MESSAGE-----ã§å§ã¾ã
- PKCS#10å½¢å¼ã®CSRï¼-----BEGIN CERTIFICATE REQUEST-----ã§å§ã¾ã
å ¬ééµè¨¼ææ¸
http://lab.moyo.biz/recipes/java/secu...
- å ¬ééµè¨¼ææ¸ï¼å ¬ééµã®ãã¤ããªãæ£ãããã¨ããã¸ã¿ã«ç½²åã§ä¿éããé»å証ææ¸ãå ¬ééµã¯ãã®å ¬ééµè¨¼ææ¸ã¨ä¸ç·ã«é å¸ããã
- èªå·±ç½²å証ææ¸ï¼èº«å æ å ±ãªã©ã好ããªããã«ä»ãããããããéµã証ææ¸ã®ããæ¿ããæ¤ç¥ã§ããï¼çè«çã«ã¯ä¸æ£ä¸ç¶ãå¯è½ã«ãªããã
CSRãã¡ã¤ã«ãä½æããéã«ã¯ï¼ãããã質åããããä¸ã¤ä¸ã¤åçãã¦ããã
# 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) [GB]:JP State or Province Name (full name) [Berkshire]:é½éåºçåãå ¥å Locality Name (eg, city) [Newbury]:å¸çºæãå ¥å Organization Name (eg, company) [My Company Ltd]:çµç¹åãå ¥å Organizational Unit Name (eg, section) []:é¨ç½²åãå ¥å Common Name (eg, your name or your server's hostname) []:192.168.19.128ï¼ããã¯ä¸ä¾ï¼ Email Address []:ï¼ä½ãå ¥åããªãï¼ Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []:ï¼ä½ãå ¥åããªãï¼ An optional company name []:ï¼ä½ãå ¥åããªãï¼
ä¸è¨ã®Common Name (CN)ã«ã¯ï¼ãã©ã¦ã¶ããã¢ã¯ã»ã¹ããéã®ãµã¼ãåãå ¥åããã
DNSãhostsãä¸å使ããï¼IPã¢ãã¬ã¹ã§ã¢ã¯ã»ã¹ãããªãã°ï¼IPã¢ãã¬ã¹ãå ¥åããã°ããã
ãã ãï¼ããã§å ¥åããCommon Nameã¯ï¼ãã¨ã§Apacheã®è¨å®ãã¡ã¤ã«ã«åãå¤ãå ¥åããå¿ è¦ãçããã®ã§ï¼æå ã«æ§ãã¦ãããã¨ã
ããã§server.csrã¨ããç½²åè¦è«ãã¡ã¤ã«ãçæãããã
ã§ï¼ãã®CSRãã¡ã¤ã«ãå ã«ï¼èª°ãã«ç½²åãè¦è«ããããã ãï¼
ãµã¤ãã«å ¬çãªèªè¨¼å±(CAï¼Certificate Authority)ã«ç½²åãè¦è«ããã¨ï¼ï¼å¹´éã§10ä¸åãæ°åä¸åãªã©ã®äºç®ãå¿ è¦ã ã
VeriSign 製åä¾¡æ ¼ä¸è¦§
https://www.verisign.co.jp/ssl/chart....
- SSLãµã¼ã証ææ¸é¢é£
ããã§ï¼è²»ç¨ããããã®ãé¿ãã¦ï¼èªåã§ç½²åãè¡ãªã£ã¦ãã¾ãã®ããèªå·±ç½²åãã
èªå·±ç½²åã®çµæã§çæããããµã¼ã証ææ¸ãããªã¬ãªã¬è¨¼ææ¸ãã
èªåã§ç½²åè¦è«ãåºãã¦ããã¦ï¼èªåèªèº«ã§ç½²åãã¦ãã¾ãã®ã ã
â»ããã¯å人ç¨ã®ãµã¼ãã®ããã®æ段ã§ãã£ã¦ï¼wwwä¸ã«å ¬éããæ¬çªç°å¢ã®ãµã¼ãã«å¯¾ãã¦ã¯ããããäºã¯ããªãã
ãã£ããèªå·±ç½²åãè¡ãªãã
# mkdir -p /etc/httpd/conf/ssl.crt # openssl x509 -in server.csr -out ../ssl.crt/server.crt -req -signkey server.key -days 3650
ããã§ï¼ãªã¬ãªã¬è¨¼ææ¸ï¼CRTãã¡ã¤ã«ï¼ãçæãããã
ï¼ï¼ï¼Apacheã«HTTPSéä¿¡ã®è¨å®ãå®æ½
ç½²åã®æ段ã¯ã©ãã§ããï¼ã¨ã«ãããµã¼ã証ææ¸ãæã«å ¥ã£ãã®ã§ï¼ããããµã¼ãã«è¨ç½®ããã
Apacheãï¼CRTãã¡ã¤ã«ãèªèã§ããããã«ããã°ããã
SSLã«é¢ããè¨å®ãã¡ã¤ã« /etc/httpd/conf.d/ssl.conf ãåå¾ãã¦ï¼å 容ãç·¨éããã
#<VirtualHost _default_:443> <VirtualHost 192.168.19.128:443> ServerName 192.168.19.128 #SSLCertificateFile /etc/pki/tls/certs/localhost.crt SSLCertificateFile /etc/httpd/conf/ssl.crt/server.crt #SSLCertificateKeyFile /etc/pki/tls/private/localhost.key SSLCertificateKeyFile /etc/httpd/conf/ssl.key/server.key
VirtualHostã¨ServerNameã®é ã«ã¯ï¼å ã»ã©è¨¼ææ¸ãçæããéã«å ¥åãããCommon Nameããè¨è¿°ããã
è¨å ¥ãã¹ããªãããã«æ³¨æã
ã¾ãï¼ç·¨éã®éã«ã¯ï¼æ¹è¡ã³ã¼ããLFã§ããããã«æ³¨æã
åèï¼
Apache+mod_ssl+Opensslã®ç°å¢è¨å®ã«ã¤ãã¦
http://www.apache.jp/pipermail/apache...
SSL ã«ããã CommonName(CN) 㯠HTTP ãã¹ãåã«å®å ¨ã«ä¸è´ãã¦ããª
ããã°ãªãã¾ãããã¤ã¾ã CN=spare ã¨ãã証ææ¸ãä½ã£ãå ´å
https://spare/ ã§ã¢ã¯ã»ã¹ããªããã°ãªãã¾ããã
ServerNameã®è¨å®ãã¹ã«ããSSLã¨ã©ã¼
http://www.uetyi.mydns.jp/wordpress/l...
- mod_sslã§ã¯ãVirtualHostã«CNã¨åãServerNameãã¤ãã¦ããªãã¨è¦åã¡ãã»ã¼ã¸ããã°ã«åºå
- ã¨ã©ã¼ãã°ã®åºåå 容ï¼[warn] RSA server certificate CommonName (CN) `ãã' does NOT match server name!?
è¨å®ãã¡ã¤ã«ã®ç·¨éã¨æ´æ°ãå®äºãããï¼ãµã¼ããåèµ·åã
# /etc/init.d/httpd restart
ãã®ã¾ã¾ã ã¨SSLç¨ã®ãã¼ãããããã¯ããã¦ãã¦ã¤ãªãããªãã®ã§ï¼443çªãã¼ããéããã
/etc/init.d/iptables stop
â»ãã®ã³ãã³ãã¯iptablesèªä½ãæ¢ãã¦ãããã»ãã¥ãªãã£ç¢ºä¿ã®ããã«ã¯ï¼æ¬æ¥ã¯iptablesãæ¢ãã¦ã¯ãªããªãã
åèï¼
linux sslãç¹ãããªãããã¼ãéæ¾
http://labs.21ma.net/?p=128
- netstat -aãã¦ãããã£ããhttpsã[listen]ãã¦ããã¨æã£ããã443ãã¼ããããã¦ã¾ããã§ãã
â»Windows XPä¸ããï¼Linuxã®ç¹å®ã®ãã¼ããéæ¾ããã¦ãããã©ããã調ã¹ãããã«ã¯ï¼ä¸è¨ã®ãããªã³ãã³ããã³ãã³ãããã³ããããå®è¡ããã
>netsh diag connect iphost 192.168.19.128 80 IPHost (192.168.19.128) IPHost = 192.168.19.128 Port = 80 ãµã¼ãã¼ã¯æ¬¡ã®ãã¼ãã§å®è¡ä¸ã¨æããã¾ã [80] >netsh diag connect iphost 192.168.19.128 443 IPHost (192.168.19.128) IPHost = 192.168.19.128 Port = 443 ãµã¼ãã¼ã¯æ¬¡ã®ãã¼ãã§å®è¡ä¸ã¨æããã¾ã [ãªã]
ããã§ï¼SSLéä¿¡ã®æºåãã§ããã
ï¼ï¼ï¼æå·åããã¦ããHTTPSéä¿¡ããçè´ãä¸å¯è½ã§ãããã¨ã®ç¢ºèª
ãã©ã¦ã¶ã§ï¼ä¸è¨ã®URLã«ã¢ã¯ã»ã¹ããããã³ã«ãhttpã§ã¯ãªãï¼httpsã§ããç¹ã«æ³¨æã
- https://Linuxã®IPã¢ãã¬ã¹/hoge.html
èªå·±ç½²åã®ãµã¼ã証ææ¸ãªã®ã§ï¼ãã»ãã¥ãªãã£ä¾å¤ã®æ¿èªãçã®æä½ãå¿ è¦ã
ã ãï¼ãããçµããã°ï¼ãµã¤ãã«Webãã¼ã¸ã表示ãããã
ãã¦ï¼ããã§éè¦ãªã®ã¯
- ä¸è¨ã§ããµã¤ãã«ã表示ãããWebãã¼ã¸ãï¼ã»ãã¥ã¢ãªï¼çè´ã§ããªãï¼éä¿¡ã®ãã¨ã§è¡¨ç¤ºããã¦ããã
ã¨ããç¹ã ã
ããã確èªããã
SSLéä¿¡ãªã®ã§ï¼80çªãã¼ãã§ã¯ä½ãèµ·ãã£ã¦ããªãã443çªãã¼ããç£è¦ãã¦ã¿ãã
ã³ã³ã½ã¼ã«ããï¼ãã±ãããã£ããã£ãéå§ï¼
# tcpdump -s0 -i eth0 -X port 443 tcpdump: verbose output suppressed, use -v or -vv for full protocol decode listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes
ãã®ç¶æ
ã§ï¼ãã©ã¦ã¶ã®ç»é¢ããªãã¼ãã
ã³ã³ã½ã¼ã«ã«ã¯ï¼ä¸è¨ã®ãããªSSLéä¿¡ã®éç¨ããã³ããããã
08:46:39.026965 IP 192.168.19.1.www-dev > 192.168.19.128.https: S 2430010324:2430010324(0) win 65535 <mss 1460,nop,nop,sackOK> 0x0000: 4500 0030 ac79 4000 8006 a67c c0a8 1301 E..0.y@....|.... 0x0010: c0a8 1380 0ae0 01bb 90d7 03d4 0000 0000 ................ 0x0020: 7002 ffff 3a07 0000 0204 05b4 0101 0402 p...:........... 08:46:39.131319 IP 192.168.19.128.https > 192.168.19.1.www-dev: S 3571341630:3571341630(0) ack 2430010325 win 5840 <mss 1460,nop,nop,sackOK> 0x0000: 4500 0030 0000 4000 4006 92f6 c0a8 1380 E..0..@.@....... 0x0010: c0a8 1301 01bb 0ae0 d4de 593e 90d7 03d5 ..........Y>.... 0x0020: 7012 16d0 f508 0000 0204 05b4 0101 0402 p............... 08:46:39.133220 IP 192.168.19.1.www-dev > 192.168.19.128.https: . ack 1 win 65535 0x0000: 4500 0028 ac7a 4000 8006 a683 c0a8 1301 E..(.z@......... 0x0010: c0a8 1380 0ae0 01bb 90d7 03d5 d4de 593f ..............Y? 0x0020: 5010 ffff 389d 0000 0000 0000 0000 P...8......... 08:46:39.028975 IP 192.168.19.1.www-dev > 192.168.19.128.https: P 1:177(176) ack 1 win 65535 0x0000: 4500 00d8 ac7b 4000 8006 a5d2 c0a8 1301 E....{@......... 0x0010: c0a8 1380 0ae0 01bb 90d7 03d5 d4de 593f ..............Y? 0x0020: 5018 ffff 303b 0000 1603 0100 ab01 0000 P...0;.......... 0x0030: a703 014f eb1c eb53 4a6e 4277 ab86 9957 ...O...SJnBw...W 0x0040: 4c7b bb8d 00e1 7161 cfb3 b6a9 43c3 7d33 L{....qa....C.}3 0x0050: c4ee 2120 3d21 ec19 42ef 95bd f572 c886 ..!.=!..B....r.. 0x0060: de08 63d6 a927 58ab 0008 4e66 8434 53a0 ..c..'X...Nf.4S. 0x0070: f443 2742 0048 00ff c00a c014 0088 0087 .C'B.H.......... 0x0080: 0039 0038 c00f c005 0084 0035 c007 c009 .9.8.......5.... 0x0090: c011 c013 0045 0044 0033 0032 c00c c00e .....E.D.3.2.... 0x00a0: c002 c004 0096 0041 0004 0005 002f c008 .......A...../.. 0x00b0: c012 0016 0013 c00d c003 feff 000a 0100 ................ 0x00c0: 0016 000a 0008 0006 0017 0018 0019 000b ................ 0x00d0: 0002 0100 0023 0000 .....#.. 08:46:39.029142 IP 192.168.19.128.https > 192.168.19.1.www-dev: . ack 177 win 6432 0x0000: 4500 0028 6daf 4000 4006 254f c0a8 1380 E..(m.@.@.%O.... 0x0010: c0a8 1301 01bb 0ae0 d4de 593f 90d7 0485 ..........Y?.... 0x0020: 5010 1920 1ecd 0000 P....... 08:46:39.031623 IP 192.168.19.128.https > 192.168.19.1.www-dev: P 1:146(145) ack 177 win 6432 0x0000: 4500 00b9 6db0 4000 4006 24bd c0a8 1380 E...m.@.@.$..... 0x0010: c0a8 1301 01bb 0ae0 d4de 593f 90d7 0485 ..........Y?.... 0x0020: 5018 1920 39bc 0000 1603 0100 5102 0000 P...9.......Q... 0x0030: 4d03 014f eb9b 5f4b 2550 760c 6725 8b82 M..O.._K%Pv.g%.. 0x0040: cf5d d92a e5a6 1105 0435 8446 115a 3036 .].*.....5.F.Z06 0x0050: 204d cd20 3d21 ec19 42ef 95bd f572 c886 .M..=!..B....r.. 0x0060: de08 63d6 a927 58ab 0008 4e66 8434 53a0 ..c..'X...Nf.4S. 0x0070: f443 2742 0039 0000 05ff 0100 0100 1403 .C'B.9.......... 0x0080: 0100 0101 1603 0100 3081 f716 4f18 e674 ........0...O..t 0x0090: 0d48 e167 a8a6 785d 1bdc 6957 4fd6 bb85 .H.g..x]..iWO... 0x00a0: 949a 66a2 0551 97d7 55e4 fa81 8172 a593 ..f..Q..U....r.. 0x00b0: f276 de85 03c5 36ec 6b .v....6.k 08:46:39.033217 IP 192.168.19.1.www-dev > 192.168.19.128.https: P 177:646(469) ack 146 win 65390 0x0000: 4500 01fd ac7c 4000 8006 a4ac c0a8 1301 E....|@......... 0x0010: c0a8 1380 0ae0 01bb 90d7 0485 d4de 59d0 ..............Y. 0x0020: 5018 ff6e 7b92 0000 1403 0100 0101 1603 P..n{........... 0x0030: 0100 306b dae2 f4b9 54f1 04ae 7445 6087 ..0k....T...tE`. 0x0040: cddb 811e 77eb 7c32 152a a651 caae b502 ....w.|2.*.Q.... 0x0050: d87b 06e2 d584 5885 be71 b6f8 2aee 6141 .{....X..q..*.aA 0x0060: fa90 7517 0301 0020 f7de 7989 f054 217e ..u.......y..T!~ 0x0070: 9243 e521 7f14 b80f c894 f845 408e 7636 [email protected] 0x0080: 0dea 62c2 92e7 b7ce 1703 0101 70b0 ea0f ..b.........p... 0x0090: 01ed b311 29ab b97d c20c be3c db1d 4b65 ....)..}...<..Ke 0x00a0: 924f 4092 41cd 7b85 a42b 2426 0ce3 35ca [email protected].{..+$&..5. 0x00b0: d9de 642d 92bd 0a05 130c c0e8 e6b6 a8d3 ..d-............ 0x00c0: 8f9e 92f7 3569 61d0 77cd a507 aa97 3d95 ....5ia.w.....=. 0x00d0: c366 a607 8623 02be cb8b 5685 fca5 75ce .f...#....V...u. 0x00e0: 165d 198e 7177 f9c3 6b02 4714 22cd 9ca4 .]..qw..k.G."... 0x00f0: 16a9 4093 aaa4 babb 80e5 d4f7 3355 29aa [email protected]). 0x0100: 55db d7b6 7bd9 6237 909b ed79 6e07 4c1a U...{.b7...yn.L. 0x0110: dd9d 9d88 a26a b245 c632 50b8 4229 84e1 .....j.E.2P.B).. 0x0120: 74bd 71ea 8b1a 97ec c736 fd9e a184 b3ce t.q......6...... 0x0130: da41 e3f4 7c28 b23a 0c69 f9ff 815a bba8 .A..|(.:.i...Z.. 0x0140: a2b1 7271 9189 7d65 2a74 9de7 e61b 192a ..rq..}e*t.....* 0x0150: c92d a157 6894 1196 d0a6 f3c5 fea8 6242 .-.Wh.........bB 0x0160: 60d6 de61 06b8 13c1 8f6b 1089 0eb6 7c38 `..a.....k....|8 0x0170: 7f1f af97 bad3 eb25 1b87 b1b2 6255 8bfa .......%....bU.. 0x0180: 0798 e318 a331 45b8 66c4 3f1d a9f2 ccb5 .....1E.f.?..... 0x0190: a9a9 51a7 a6df 4bd3 77f9 1c43 09a0 f7ca ..Q...K.w..C.... 0x01a0: 3a33 f9b1 7050 2ce2 7bee 097d bd91 af2f :3..pP,.{..}.../ 0x01b0: 249d f6f2 1043 60b3 f74e ddb7 0774 b23c $....C`..N...t.< 0x01c0: 3fa8 0b39 3db3 1c75 679d 4af7 48e7 66f8 ?..9=..ug.J.H.f. 0x01d0: d4ab f729 b2c3 21cd d74e 3a23 37da d74f ...)..!..N:#7..O 0x01e0: edb7 b4f4 63c6 e650 1718 d437 7e69 4854 ....c..P...7~iHT 0x01f0: 8e4b 2c68 ae90 e077 5d73 c039 3c .K,h...w]s.9< 08:46:39.034315 IP 192.168.19.128.https > 192.168.19.1.www-dev: P 146:492(346) ack 646 win 7504 0x0000: 4500 0182 6db1 4000 4006 23f3 c0a8 1380 E...m.@.@.#..... 0x0010: c0a8 1301 01bb 0ae0 d4de 59d0 90d7 065a ..........Y....Z 0x0020: 5018 1d50 8a2b 0000 1703 0101 20b8 a90c P..P.+.......... 0x0030: 377a 7a56 4700 fa9c c641 ca3c 673a 26d9 7zzVG....A.<g:&. 0x0040: dcb0 0af5 8d27 0f00 f361 efc3 cdcb a5b2 .....'...a...... 0x0050: bcb7 4ef3 a8d4 f743 d14f 1183 495a 42b3 ..N....C.O..IZB. 0x0060: 88b2 24d7 81ed 3095 2532 d94a e428 2161 ..$...0.%2.J.(!a 0x0070: 688e ee31 b26b 18a8 2925 ca5d 499b 41e5 h..1.k..)%.]I.A. 0x0080: 3133 cc60 ce70 0589 0d5a e961 3047 7d06 13.`.p...Z.a0G}. 0x0090: 4093 a22e 9869 edaf 823e 5764 22fa 37e9 @....i...>Wd".7. 0x00a0: 49fc 4676 93d7 1c3f cac1 7c31 784d 9f0e I.Fv...?..|1xM.. 0x00b0: 240a 8073 e8d2 7cb7 9046 fd25 41cb 08b7 $..s..|..F.%A... 0x00c0: 12de fbf2 afe8 8825 ac86 1ab8 58af 2a01 .......%....X.*. 0x00d0: 2d7c bde2 c6f9 3e94 88dd ead7 6234 94d1 -|....>.....b4.. 0x00e0: 1525 c9eb 65e7 1e95 7228 5474 d795 91de .%..e...r(Tt.... 0x00f0: f60e 1096 3d8d 28e6 584a f9f0 3b3a edbc ....=.(.XJ..;:.. 0x0100: 3353 2721 6b29 dbf0 8b16 bc36 c386 9c24 3S'!k).....6...$ 0x0110: 0cc1 c2d8 55b3 a5b4 402c 5703 c23d 631a ....U...@,W..=c. 0x0120: 0384 fdb3 0fca e7f2 3d04 b8d3 fb6d 1e42 ........=....m.B 0x0130: 6021 86b0 b308 ed5e ef70 3051 01fe 54f7 `!.....^.p0Q..T. 0x0140: a975 be38 34e1 35eb 62b6 3763 f217 0301 .u.84.5.b.7c.... 0x0150: 0030 b552 8610 308c 3fd9 3e0e e5e8 a385 .0.R..0.?.>..... 0x0160: 0fe2 803e 99b2 adc0 8063 21c8 7eb7 9e32 ...>.....c!.~..2 0x0170: b9d1 23fd fb16 0e31 a196 ec4c 263c e5cb ..#....1...L&<.. 0x0180: df68 .h 08:46:39.034625 IP 192.168.19.128.https > 192.168.19.1.www-dev: P 492:529(37) ack 646 win 7504 0x0000: 4500 004d 6db2 4000 4006 2527 c0a8 1380 E..Mm.@.@.%'.... 0x0010: c0a8 1301 01bb 0ae0 d4de 5b2a 90d7 065a ..........[*...Z 0x0020: 5018 1d50 73da 0000 1503 0100 20b8 cc22 P..Ps.........." 0x0030: 514e f925 a22a 3f74 7df4 61fc 8a50 0660 QN.%.*?t}.a..P.` 0x0040: 8b20 0d2f 7d1b 3e66 15da 3997 60 .../}.>f..9.` 08:46:39.079964 IP 192.168.19.1.www-dev > 192.168.19.128.https: . ack 529 win 65007 0x0000: 4500 0028 ac7d 4000 8006 a680 c0a8 1301 E..(.}@......... 0x0010: c0a8 1380 0ae0 01bb 90d7 065a d4de 5b4f ...........Z..[O 0x0020: 5010 fdef 3618 0000 0000 0000 0000 P...6......... 08:46:39.079967 IP 192.168.19.1.www-dev > 192.168.19.128.https: P 646:683(37) ack 529 win 65007 0x0000: 4500 004d ac7f 4000 8006 a659 c0a8 1301 [email protected].... 0x0010: c0a8 1380 0ae0 01bb 90d7 065a d4de 5b4f ...........Z..[O 0x0020: 5018 fdef 1131 0000 1503 0100 200c b035 P....1.........5 0x0030: 3baf ddbf 0d02 f109 55c3 3433 e06f ffda ;.......U.43.o.. 0x0040: e887 1dfb ac2e c116 1215 2edb 08 ............. 08:46:39.079973 IP 192.168.19.1.www-dev > 192.168.19.128.https: R 683:683(0) ack 529 win 0 0x0000: 4500 0028 ac80 4000 8006 a67d c0a8 1301 E..(..@....}.... 0x0010: c0a8 1380 0ae0 01bb 90d7 067f d4de 5b4f ..............[O 0x0020: 5014 0000 33df 0000 0000 0000 0000 P...3......... 08:46:39.080244 IP 192.168.19.128.https > 192.168.19.1.www-dev: R 529:529(0) ack 683 win 7504 0x0000: 4500 0028 6db3 4000 4006 254b c0a8 1380 E..(m.@.@.%K.... 0x0010: c0a8 1301 01bb 0ae0 d4de 5b4f 90d7 067f ..........[O.... 0x0020: 5014 1d50 168f 0000 P..P....
HTTPã®æã®ãã£ããã£çµæã¨ã¯ç°ãªãï¼ã¨ããç¹ããããã ãããï¼
ãã±ããã®å 容ãè¦ã¦ãï¼ãã©ã¦ã¶ã®ã¦ã¼ã¶ã¨ã¼ã¸ã§ã³ãæ å ±ã¯ãã¡ããï¼Webãã¼ã¸ã®ãThis is secret information.ãã¨ããæè¨ãèªããªãã
éä¸ã®çµè·¯ã§ã¯æ å ±ãæå·åããã¦ããã®ã§ï¼éä¿¡ãçã¿è¦ã¦ãä¸èº«ãåãããªãã®ã ã
æ å ±ãæ¼ããªãã®ã§ï¼çã¿è¦ãäºã«ãªããªãã
ãããï¼HTTPSï¼SSLï¼éä¿¡ã®å¼·ãã§ããã
çµã³
å®éã«ãã±ããã®ä¸å³ãè¦ããã¨ã«ãã£ã¦
- æå·åããã¦ããªãéä¿¡ãã©ãã»ã©å±éºã
- æå·åãããéä¿¡ãã©ãã»ã©å®å ¨ã
身ããã£ã¦å®æããäºãã§ããã ããã
ä½ãå ´åã«ãï¼ä½¿ãå ´åã«ãï¼
Webå¨ãã®ã·ã¹ãã ã¯ï¼é©åãªã·ã¼ã³ã§æå·åãæ½ããã¦ãããã©ãã確èªããäºã大äºã ã
ã