Apache の SSLPolicy ディレクティブが動かなかった話(2017/11/5)

Linux
Linux
スポンサーリンク

Apache httpd の SSLPolicy ディレクティブは、SSL/TLS設定を簡単にするための仕組みです。もはや職人芸ともいえる Apache の SSL/TLS設定を、だれでも簡単にできるようになるのはありがたいことです。さっそく SSLPolicy を試してみたのですが、うまく動作しませんでした、、、せっかくなので記録としてやったことをメモしておきます。

SSLPolicy ディレクティブについて

SSLPolicy ディレクティブの仕組みは「<SSLPolicy ポリシー名>〜</SSLPolic>」ブロックで定義した SSL/TLS関連の設定を「SSLPolicy ポリシー名」で呼び出せるといったものです。

下の例では、OCSPステープリング関連の設定を「safe-stapling」ポリシーとして定義して、バーチャルホストブロックの「SSLPolicy safe-stapling」で呼び出しています。

<SSLPolicy safe-stapling>
SSLUseStapling on
SSLStaplingResponderTimeout 2
SSLStaplingReturnResponderErrors off
SSLStaplingFakeTryLater off
SSLStaplingStandardCacheTimeout 86400
</SSLPolicy>

...
<VirtualHost...>
SSLPolicy safe-stapling
...

https://httpd.apache.org/docs/trunk/mod/mod_ssl.html#sslpolicysection より引用

これだけだと、やはり自前で SSL/TLSの設定をしなければなりませんが、注目なのは Mozilla が定義した次の3つの SSLPolicy が付属していることです、Apache の設定ファイルに「SSLPolicy modern」と書くだけでいい具合に SSL/TLSの設定をしてくれそうですね。

  • modern: recommended when your server is accessible on the open Internet. Works with all modern browsers, but old devices might be unable to connect.
  • intermediate: the fallback if you need to support old (but not very old) clients.
  • old: when you need to give Windows XP/Internet Explorer 6 access. The last resort.

https://httpd.apache.org/docs/trunk/mod/mod_ssl.html#sslpolicy より引用

それぞれのポリシーの定義は Mozilla の Wiki で確認できます。
https://wiki.mozilla.org/Security/Server_Side_TLS#Recommended_configurations

Apache 2.4.29 で SSLPolicy が動作しない

SSLPolicy は、Apache httpd 2.4.28 以降でサポートされているようなので、手元の Apache 2.4.29 の サーバーに SSLPolicy ディレクティブを追加して Apache を再起動してみました。

SSLPolicy modern

しかし下のようなエラーが表示され Apache が起動しません、、mod_ssl は有効になっているのですが SSLPolicy をディレクティブとして認識していないようです。

AH00526: Syntax error on line 311 of /usr/local/apache2/conf/httpd.conf:
Invalid command 'SSLPolicy', perhaps misspelled or defined by a module not included in the server configuration

また「httpd -t -D DUMP_SSL_POLICIES」コマンドで定義済みのポリシーを確認できます。標準で定義されている modern、intermediate、old が表示されるはずなのですが、上のエラーが表示されるだけでポリシーは表示されませんでした。

Apache 2.5(開発版)で SSLPolicy の動作を確認

Apache httpd の開発版(バージョン 2.5 とよばれています)に付属している SSL/TLSの設定ファイルには次のような記述がありました、「SSLPolicy を設定する場合は SSLCipherSuite, SSLProxyCipherSuite, SSLHonorCipherOrder,SSLProtocol, SSLProxyProtocol は設定しないでね」と書いてあります。

# SSL Policy:
# Choose from a pre-defined setting of SSL* configurations, based on
# the Mozilla recommendations from:
# https://wiki.mozilla.org/Security/Server_Side_TLS
# These policies will be updated over time in new releases to keep
# settings compatible and secure with "modern" browser, or if you
# need to support legacy installtions, "intermediate" might be your
# choice.
# If you run the following command on your installation, the exact
# contents of the defined SSL policies will be listed:
#
# > httpd -t -D DUMP_SSL_POLICIES
#
# Worth noting, a SSLPolicy defines the ground rules. What ever is
# configured beside it, is added "on top". If a configuration has
# a SSLPolicy *and* a SSLCipherSuite, any cipher suite in the policy
# will be overwritten in this context.
#
# If your OpenSSL library does not support TLSv1.2 (OpenSSL 1.0.2
# and later), "modern" will not be available.
# If you enable one of the policies below, we recommend that you
# refrain from configuring any of the following, unless you are
# certain that you want to override:
# SSLCipherSuite, SSLProxyCipherSuite, SSLHonorCipherOrder,
# SSLProtocol, SSLProxyProtocol
#SSLPolicy intermediate
#SSLPolicy modern

Apache httpd 2.5 の httpd-ssl.conf より引用

Apache httpd 2.5 の「httpd -t -D DUMP_SSL_POLICIES」コマンドで確認してみると、intermediate と old ポリシーの定義は確認できます。(なぜか modern ポリシーは表示されません)

# /usr/local/apache2/bin/httpd -t -D DUMP_SSL_POLICIES
 
for OpenSSL
SSLPolicies: {
"intermediate": {
"SSLCompression": "off",
"SSLProtocol": "+TLSv1.2 +TLSv1.1 +TLSv1.0",
"SSLCipherSuite": "ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS",
"SSLSessionTickets": "off",
"SSLProxyProtocol": "+TLSv1.2 +TLSv1.1 +TLSv1.0",
"SSLProxyCipherSuite": "ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS",
"SSLProxyVerify": "require"
},
"old": {
"SSLCompression": "off",
"SSLProtocol": "all",
"SSLCipherSuite": "ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:ECDHE-RSA-DES-CBC3-SHA:ECDHE-ECDSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:DES-CBC3-SHA:HIGH:SEED:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!RSAPSK:!aDH:!aECDH:!EDH-DSS-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA:!SRP",
"SSLSessionTickets": "off",
"SSLProxyProtocol": "all",
"SSLProxyCipherSuite": "ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:ECDHE-RSA-DES-CBC3-SHA:ECDHE-ECDSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:DES-CBC3-SHA:HIGH:SEED:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!RSAPSK:!aDH:!aECDH:!EDH-DSS-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA:!SRP",
"SSLProxyVerify": "none"
}
}
Syntax OK

「SSLPolicy modern」のコメントをはずし、設定ファイルの注意書きにあるように SSLCipherSuite, SSLProxyCipherSuite, SSLHonorCipherOrder,SSLProtocol, SSLProxyProtocol をコメントアウトして Apache httpd 2.5 を起動するとエラーなく SSLPolicy が動作します。

おわりに

おそらくですが SSLPolicy ディレクティブはまだ開発中なのだと思います。いきいそぎました(^^;) Apache httpd 2.4 にリリースされるといいですね。

この記事をシェアする
あぱーブログをフォローする
スポンサーリンク
スポンサーリンク

コメント

',b.captions&&s){var u=J("figcaption");u.id="baguetteBox-figcaption-"+t,u.innerHTML=s,l.appendChild(u)}e.appendChild(l);var c=J("img");c.onload=function(){var e=document.querySelector("#baguette-img-"+t+" .baguetteBox-spinner");l.removeChild(e),!b.async&&n&&n()},c.setAttribute("src",r),c.alt=a&&a.alt||"",b.titleTag&&s&&(c.title=s),l.appendChild(c),b.async&&n&&n()}}function X(){return M(o+1)}function D(){return M(o-1)}function M(e,t){return!n&&0<=e&&e=k.length?(b.animation&&O("right"),!1):(q(o=e,function(){z(o),V(o)}),R(),b.onChange&&b.onChange(o,k.length),!0)}function O(e){l.className="bounce-from-"+e,setTimeout(function(){l.className=""},400)}function R(){var e=100*-o+"%";"fadeIn"===b.animation?(l.style.opacity=0,setTimeout(function(){m.transforms?l.style.transform=l.style.webkitTransform="translate3d("+e+",0,0)":l.style.left=e,l.style.opacity=1},400)):m.transforms?l.style.transform=l.style.webkitTransform="translate3d("+e+",0,0)":l.style.left=e}function z(e){e-o>=b.preload||q(e+1,function(){z(e+1)})}function V(e){o-e>=b.preload||q(e-1,function(){V(e-1)})}function U(e,t,n,o){e.addEventListener?e.addEventListener(t,n,o):e.attachEvent("on"+t,function(e){(e=e||window.event).target=e.target||e.srcElement,n(e)})}function W(e,t,n,o){e.removeEventListener?e.removeEventListener(t,n,o):e.detachEvent("on"+t,n)}function G(e){return document.getElementById(e)}function J(e){return document.createElement(e)}return[].forEach||(Array.prototype.forEach=function(e,t){for(var n=0;n","http://www.w3.org/2000/svg"===(e.firstChild&&e.firstChild.namespaceURI)}(),m.passiveEvents=function i(){var e=!1;try{var t=Object.defineProperty({},"passive",{get:function(){e=!0}});window.addEventListener("test",null,t)}catch(n){}return e}(),function a(){if(r=G("baguetteBox-overlay"))return l=G("baguetteBox-slider"),u=G("previous-button"),c=G("next-button"),void(d=G("close-button"));(r=J("div")).setAttribute("role","dialog"),r.id="baguetteBox-overlay",document.getElementsByTagName("body")[0].appendChild(r),(l=J("div")).id="baguetteBox-slider",r.appendChild(l),(u=J("button")).setAttribute("type","button"),u.id="previous-button",u.setAttribute("aria-label","Previous"),u.innerHTML=m.svg?f:"<",r.appendChild(u),(c=J("button")).setAttribute("type","button"),c.id="next-button",c.setAttribute("aria-label","Next"),c.innerHTML=m.svg?g:">",r.appendChild(c),(d=J("button")).setAttribute("type","button"),d.id="close-button",d.setAttribute("aria-label","Close"),d.innerHTML=m.svg?p:"×",r.appendChild(d),u.className=c.className=d.className="baguetteBox-button",function n(){var e=m.passiveEvents?{passive:!1}:null,t=m.passiveEvents?{passive:!0}:null;U(r,"click",x),U(u,"click",E),U(c,"click",C),U(d,"click",B),U(l,"contextmenu",A),U(r,"touchstart",T,t),U(r,"touchmove",N,e),U(r,"touchend",L),U(document,"focus",P,!0)}()}(),S(e),function s(e,a){var t=document.querySelectorAll(e),n={galleries:[],nodeList:t};return w[e]=n,[].forEach.call(t,function(e){a&&a.filter&&(y=a.filter);var t=[];if(t="A"===e.tagName?[e]:e.getElementsByTagName("a"),0!==(t=[].filter.call(t,function(e){if(-1===e.className.indexOf(a&&a.ignoreClass))return y.test(e.href)})).length){var i=[];[].forEach.call(t,function(e,t){var n=function(e){e.preventDefault?e.preventDefault():e.returnValue=!1,H(i,a),I(t)},o={eventHandler:n,imageElement:e};U(e,"click",n),i.push(o)}),n.galleries.push(i)}}),n.galleries}(e,t)},show:M,showNext:X,showPrevious:D,hide:j,destroy:function e(){!function n(){var e=m.passiveEvents?{passive:!1}:null,t=m.passiveEvents?{passive:!0}:null;W(r,"click",x),W(u,"click",E),W(c,"click",C),W(d,"click",B),W(l,"contextmenu",A),W(r,"touchstart",T,t),W(r,"touchmove",N,e),W(r,"touchend",L),W(document,"focus",P,!0)}(),function t(){for(var e in w)w.hasOwnProperty(e)&&S(e)}(),W(document,"keydown",F),document.getElementsByTagName("body")[0].removeChild(document.getElementById("baguetteBox-overlay")),w={},h=[],o=0}}})
タイトルとURLをコピーしました