Upgrade to Pro — share decks privately, control downloads, hide ads and more …

HTTPSを正しく設定しよう

 HTTPSを正しく設定しよう

IIJ Technical NIGHT vol.5 ~HTTPSと暗号 : Webエンジニアにこそ知って欲しい、アドレスバーの鍵マークの意味~

Kazuki Hamasaki

June 28, 2018
Tweet

More Decks by Kazuki Hamasaki

Other Decks in Technology

Transcript

  1. ⅓㟒 Ұथ • ৽ଔೖࣾ6೥໨ • ॴଐ: Ϋϥ΢υຊ෦ Ϋϥ΢υαʔϏε1෦ 
 ύϒϦοΫϦιʔε1՝

    • ͓͠͝ͱ • IIJ GIOΠϯϑϥετϥΫνϟʔP2 • IIJ GIOϗεςΟϯάύοέʔδαʔϏε • ओʹύϒϦοΫΫϥ΢υͷϑϩϯτΤϯυ։ൃɾ ӡ༻
  2. SSL/TLSͷ࢓૊Έ 1. ઀ଓཁٻ 2. αʔόূ໌ॻΛૹ෇ 4. ڞ௨伴ૹ৴ ҉߸Խ͞Εͨڞ௨伴 ڞ௨伴 ڞ௨伴

    ҉߸Խ͞Εͨڞ௨伴 ൿີ伴 ূ໌ॻ 3. ڞ௨伴Λੜ੒ 5. ൿີ伴Ͱڞ௨伴ΛऔΓग़͢ ূ໌ॻ ૹΒΕ͖ͯͨެ։伴ͱ௨৴ઌ͕Ұக͢Δ͔ ిࢠॺ໊Ͱݕূ 6. ҆શʹަ׵ͨ͠ڞ௨伴Ͱ҉߸௨৴Λߦ͏ αʔόʔ ΫϥΠΞϯτ
  3. ೝূہ͸ԿΛ֬ೝ͍ͯ͠Δͷ͔ ൿີ伴 ࣋ͪओΛݕূ ެ։伴Λॺ໊ ূ໌ॻ αʔόʔ ެ։伴 CSR(Certificate Signing Request)

    ެ։伴 DN ೝূہ CA: Certification Authority DV: Domain Validation υϝΠϯͷར༻ݖ OV: Organization Validation DV+૊৫ͷ࣮ࡏੑ EV: Extended Validation OV+υϝΠϯ໊ͱӡӦ૊৫ͱͷؔ܎
  4. OpenSSLίϚϯυͰ࡞੒ $ openssl genrsa -des3 -out private.key 2048 Generating RSA

    private key, 2048 bit long modulus ............................+++ e is 65537 (0x10001) Enter pass phrase for private.key: $ openssl req -new -key private.key -out server.csr Country Name (2 letter code) [XX]:JP State or Province Name (full name) []:Tokyo Locality Name (eg, city) [Default City]:Chiyoda-ku Organization Name (eg, company) [Default Company Ltd]:Internet Initiative Japan Inc. Organizational Unit Name (eg, section) []:Cloud Division Common Name (eg, your name or your server's hostname) []:example.com ൿີ伴Λ࡞Δ CSRΛ࡞Δ DistinguishedNameΛฉ͔ΕΔͷͰೖྗ͢Δ
  5. CFSSL: Cloudflare's PKI and TLS toolkit • jsonͰઃఆ஋Λ؅ཧɻࣗಈԽ΋Ͱ͖Δɻ { "CN":

    "example.net", "hosts": ["example.net",ɹ"www.example.net"], "key": {"algo": "ecdsa", "size": 256}, "names": [{"C": "US", "ST": "CA", "L": “San…”}] } $ cfssl genkey csr.json ൿີ伴ͱCSRΛੜ੒
  6. Apache HTTPD Server <VirtualHost *:443> ... SSLEngine on SSLCertificateFile /path/to/signed_cert_plus_intermediates

    SSLCertificateKeyFile /path/to/private/key ... </VirtualHost> SSLProtocol all -SSLv2 SSLCipherSuite DEFAULT:!EXP:!SSLv2:!DES:!IDEA:!SEED:+3DES SSLHonorCipherOrder on SSLCompression off SSLSessionTickets off …
  7. OpenSSLͰݟͯΈΔ $ openssl s_client -CAfile /etc/ssl/certs/ca-bundle.crt -verify 10 - connect

    example.com:443 verify depth is 10 CONNECTED(00000003) depth=2 O = Digital Signature Trust Co., CN = DST Root CA X3 Verify return code: 0 (ok) Verify return code: 21 (unable to verify the first certificate) ͩΊͳͱ͖
  8. HTTP Strict Transport Security • αʔό͕ϒϥ΢βʹରͯ͠HTTPSΛ࢖͏Α͏ʹ఻͑ Δ࢓૊Έ • ϒϥ΢β͕֮͑ͯ࣍ճҎ߱ڧ੍తʹHTTPSͰ
 ΞΫηε͢Δ

    • վ͟Μ͞ΕͨαΠτ΁ͷ༠ಋΛ๷ࢭ • Strict-Transport-Security ϔομΛ௥Ճ • securityheaders.com ͰϔομͷνΣοΫ͕Ͱ͖Δ
  9. ϢʔβΛ஌Δ SSLOptions +StdEnvVars CustomLog logs/ssl_cipher.log "%t %h %{SSL_PROTOCOL}e %{SSL_CIPHER} e

    %{SSL_SESSION_ID}e %{SSL_SESSION_RESUMED}e" Nginx log_format ssl "$time_local $remote_addr $ssl_protocol $ssl_cipher $ssl_session_id $ssl_session_reused”; Apache2.4 nginx
  10. PCI DSS Payment Card Industry Data Security Standard • Χʔυ৘ใηΩϡϦςΟͷࠃࡍ౷Ұج४

    • Χʔυ৘ใΛ؅ཧɺॲཧɺ఻ૹ͢Δ͢΂ͯͷ ૊৫͕ର৅ • v3.2 • 2018/06/30·ͰʹSSLͱTLS1.0ͱ1.1ͷҰ෦ ͷ࣮૷͸ഇࢭ
  11. ·ͱΊ • ࣗࣾαΠτΛνΣοΫ͠·͠ΐ͏ • σϑΥϧτͷઃఆ͸ऑ͍͜ͱ͕͋Γ·͢ • ͓͢͢ΊઃఆΛࢀߟʹ͠·͠ΐ͏ • ূ໌ॻ؂ࢹΛઃఆ͠Α͏ •

    ؂ࢹαʔϏεͰઃఆͯ͠ΈΑ͏ • ূ໌ॻΛ؅ཧ͢ΔαʔϏε΍ࣗಈԽπʔϧͰ؅ ཧͷෛ୲ΛݮΒָͯ͠ʹ҆શͳঢ়ଶΛ
 ҡ࣋͠Α͏