diff options
author | Raimo Niskanen <[email protected]> | 2016-07-21 10:49:56 +0200 |
---|---|---|
committer | Raimo Niskanen <[email protected]> | 2016-07-21 10:49:56 +0200 |
commit | ebb1f362db55f2ec26a3ed509267e25303feddf4 (patch) | |
tree | f42560b30203cc4423cdac3d31f277bf6166d7b7 /lib/ssl/src/ssl_handshake.erl | |
parent | b490fb8664ec6e5ceaadc1c74350dc666f5406d2 (diff) | |
parent | a138a928849f3b68a2542f2592e95e7362217e3d (diff) | |
download | otp-ebb1f362db55f2ec26a3ed509267e25303feddf4.tar.gz otp-ebb1f362db55f2ec26a3ed509267e25303feddf4.tar.bz2 otp-ebb1f362db55f2ec26a3ed509267e25303feddf4.zip |
Merge branch 'raimo/ssl/version-selection/maint-18/OTP-13753' into raimo/ssl/version-selection/maint-19/OTP-13753
Conflicts:
lib/ssl/vsn.mk
lib/ssl/src/ssl.appup.src
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 9c3fe9d73b..06226d5155 100644 --- a/lib/ssl/src/ssl_handshake.erl +++ b/lib/ssl/src/ssl_handshake.erl @@ -1256,8 +1256,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}; |