<div dir="ltr">Hi!<div><br></div><div>While upgrading to OTP 22.1 I've hit an issue with ssl.</div><div><br></div><div>The problem: when connecting to a TLS server with a client certificate,</div><div>  'ssl_handshake:select_hashsign' may fail with '{error,badarg}',</div><div>  causing 'Handshake Failure - malformed_handshake_data'</div><div><br></div><div>This happens because 'SupportedHashSigns = undefined',</div><div>  which comes from 'ssl:handle_options' in 'ssl_connection:init'.</div><div><br></div><div>    signature_algs = handle_option(signature_algs, Opts, undefined, Role, undefined, HighestVersion),<br></div><div><div>    ^^^   this returns 'undefined' because 'tls_v1:default_signature_algs(HighestVersion)' returns 'undefined'</div><div><br></div><div>And the problem here was 'HighestVersion = {3,1}' which seemed wrong.</div><div><br></div><div>When 'versions' option is not passed, HighestVersion is the head of list returned from 'tls_record:supported_protocol_versions()',</div><div>  and that function just maps 'protocol_version' environment parameter.</div><div>If the first version specified in environment is low, the 'HighestVersion' will contain not a highest version.</div><div><br></div><div>So, after setting default ssl protocol versions like this:</div><div>  'application:set_env(ssl, protocol_version, [tlsv1,'tlsv1.1','tlsv1.2']).'</div><div>the client raises an alert while handling '#certificate_request{}' from server.</div><div><br></div><div><br></div><div><br></div><div>OTP 21 and earlier tolerated the version order in 'protocol_version' env, and the code was like this:</div><div>  signature_algs = handle_hashsigns_option(..., tls_version(RecordCb:highest_protocol_version(Versions)))</div><div><br></div><div><br>If the new behaviour is intended, it may be useful to describe it in the man page:</div><div>  <a href="http://erlang.org/doc/man/ssl_app.html">http://erlang.org/doc/man/ssl_app.html</a></div><div>If 'HighestVersion' should always contain a highest version, the obvious</div><div>  (but may be not the best) fix is to sort default versions in 'ssl:handle_options',</div><div>  like it is done for specified 'versions'.</div><div><br></div><div><br></div><div>Obvious workaround for this is to store 'protocol_version' env parameter starting from highest version.</div><div><br></div><div><br></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><font face="'courier new', monospace">Danil Zagoskin | <a href="mailto:z@gosk.in" target="_blank">z@gosk.in</a></font></div></div></div></div></div>