diff options
author | Raimo Niskanen <[email protected]> | 2016-07-25 14:41:07 +0200 |
---|---|---|
committer | Raimo Niskanen <[email protected]> | 2016-07-25 14:41:07 +0200 |
commit | 9c97ca598a1858d7b43799dee03a5c129b81220a (patch) | |
tree | 141e26c74869a335e90d539861aa6f3130925c13 /lib/ssl/src/ssl_handshake.erl | |
parent | 8d4560198239256587ccc55895eb8fe2b214e971 (diff) | |
parent | 825145898d7bf69147c1e6a6ad66c3454e7ec8f1 (diff) | |
download | otp-9c97ca598a1858d7b43799dee03a5c129b81220a.tar.gz otp-9c97ca598a1858d7b43799dee03a5c129b81220a.tar.bz2 otp-9c97ca598a1858d7b43799dee03a5c129b81220a.zip |
Merge branch 'maint'
Diffstat (limited to 'lib/ssl/src/ssl_handshake.erl')
-rw-r--r-- | lib/ssl/src/ssl_handshake.erl | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/lib/ssl/src/ssl_handshake.erl b/lib/ssl/src/ssl_handshake.erl index bca341c8bc..47af1f861c 100644 --- a/lib/ssl/src/ssl_handshake.erl +++ b/lib/ssl/src/ssl_handshake.erl @@ -1305,8 +1305,40 @@ handle_server_hello_extensions(RecordCB, Random, CipherSuite, Compression, end. select_version(RecordCB, ClientVersion, Versions) -> - ServerVersion = RecordCB:highest_protocol_version(Versions), - RecordCB:lowest_protocol_version(ClientVersion, ServerVersion). + do_select_version(RecordCB, ClientVersion, Versions). + +do_select_version(_, ClientVersion, []) -> + ClientVersion; +do_select_version(RecordCB, ClientVersion, [Version | Versions]) -> + case RecordCB:is_higher(Version, ClientVersion) of + true -> + %% Version too high for client - keep looking + do_select_version(RecordCB, ClientVersion, Versions); + false -> + %% Version ok for client - look for a higher + do_select_version(RecordCB, ClientVersion, Versions, Version) + end. +%% +do_select_version(_, _, [], GoodVersion) -> + GoodVersion; +do_select_version( + RecordCB, ClientVersion, [Version | Versions], GoodVersion) -> + BetterVersion = + case RecordCB:is_higher(Version, ClientVersion) of + true -> + %% Version too high for client + GoodVersion; + false -> + %% Version ok for client + case RecordCB:is_higher(Version, GoodVersion) of + true -> + %% Use higher version + Version; + false -> + GoodVersion + end + end, + do_select_version(RecordCB, ClientVersion, Versions, BetterVersion). renegotiation_info(_, client, _, false) -> #renegotiation_info{renegotiated_connection = undefined}; |