0

SSLを使用したHTTPサーバーとしてErlang Mochiwebを使用しています。Mochiweb は純粋な Erlang SSL ライブラリを使用します。

Forward Secrecy をサポートするように erlang ssl を設定するには? SSL Forward Secrecy の詳細については、https: //en.wikipedia.org/wiki/Forward_secrecyを参照してください。

4

1 に答える 1

2

私はErlang / OTP 17をopenssl 1.0.2aで使用しています(erlangは暗号にopensslを必要としますが、ハンドシェイクやプロトコルは必要ないため、理論的にはopensslがサポートするすべての暗号をサポートする必要があります)、そのSSLモジュールはデフォルトで完全転送秘密をサポートします。ただし、デフォルトでは、sslv3 や des のような安全でないプロトコルや暗号、または rc4 のような弱い暗号もサポートしています。SSLlabs ssltest は、デフォルト オプションのランク C を提供します。安全でないプロトコルと暗号を無効にすることをお勧めします。

また、erlang ssl モジュールはデフォルトでクライアントの暗号スイート設定を尊重します。これらのバージョンは ECDHE ではなく RSA キー交換を好むため、RSA キー交換を使用する IE を作成します ( https://www.ssllabs.com/ssltest/viewClient.html?name=IE&version=8-10&platform=Win%207を参照)。 )。{honor_cipher_order, true}サーバーの設定を使用する必要があります。また、必要に応じて暗号スイートの優先順位を手動で調整する必要があります。デフォルトの順序は、PFS による完全なランキングではありません。

クライアント (ブラウザーではなく独自のアプリなど) を制御でき、本当に PFS のみが必要な場合は、RSA キー交換を無効にすることができます。

erlang のサンプル escript とオプションは次のとおりです。

mochiweb の場合、これらのオプションを ssl_opts に追加できます。

#!/usr/bin/env escript

% these ciphers will got A- on ssllabs's ssltest.
% Because as mentioned above, some version's IE prefers non-PFS key exchange.
% And got A if {honor_cipher_order, true} is set.
% No manual adjusting needed to get A, because the first ciphersuite is PFS-enabled and supported by IEs.
% So you need to adjust orders to fit whatever you needed.
secure_ciphers() -> secure_ciphers(ssl:cipher_suites()). 


% It includes insecure and weak ciphers, so it should get low rank on ssltest
pfs_ciphers() -> pfs_ciphers(ssl:cipher_suites()). 

% Rank A on ssllabs' ssltest, all modern client is using perfect forward secrecy key-exchange   
% but some client without PFS support will fail to handshake.
pfs_secure_ciphers() ->  
        sets:to_list(sets:intersection(sets:from_list(secure_ciphers()), sets:from_list(pfs_ciphers()))). 

secure_ciphers([]) -> [];
secure_ciphers([{_, rc4_128, _} | T]) -> secure_ciphers(T);
secure_ciphers([{_, des_cbc, _} | T]) -> secure_ciphers(T);
secure_ciphers([{dhe_rsa, _, _} | T]) -> secure_ciphers(T);
secure_ciphers([{_, _, md5} | T]) -> secure_ciphers(T);
secure_ciphers([H | T]) -> [H | secure_ciphers(T)].


pfs_ciphers([]) -> [];
pfs_ciphers([{dhe_dss, _, _} = H | T]) -> [H | pfs_ciphers(T)];
pfs_ciphers([{dhe_rsa, _, _} = H | T]) -> [H | pfs_ciphers(T)];
pfs_ciphers([{ecdhe_ecdsa, _, _} = H | T]) -> [H | pfs_ciphers(T)];
pfs_ciphers([{ecdhe_rsa, _, _} = H | T]) -> [H | pfs_ciphers(T)];
pfs_ciphers([_ | T]) -> pfs_ciphers(T).

accept(S) ->
        {ok, Q} = ssl:transport_accept(S),
        spawn(fun() -> accept(S) end),
        ssl:ssl_accept(Q),
        receive
                Msg ->
                        io:format("~p~n", [Msg]),
                        ssl:send(Q, <<"HTTP/1.0 200 OK\r\n\r\nHello World\r\n">>),
                        ssl:close(Q)
        end.

main(_) ->
        ssl:start(),
        {ok, P} = ssl:listen(443, [{certfile, "./aa.crt"}, {keyfile, "./aa.key"}, {ciphers, pfs_secure_ciphers()}, {versions, [tlsv1, 'tlsv1.1', 'tlsv1.2']}, {dhfile, "./dh4096.pem"}]),
        accept(P),
        receive
                stop ->
                        ok
        end.
于 2015-04-27T09:12:23.427 に答える