<div dir="ltr">I hope this hole fix please try it out:<br><div><br>diff --git a/lib/ssl/src/ssl_cipher.erl b/lib/ssl/src/ssl_cipher.erl<br>index 0956d35..ed8663b 100644<br>--- a/lib/ssl/src/ssl_cipher.erl<br>+++ b/lib/ssl/src/ssl_cipher.erl<br>@@ -2837,11 +2837,13 @@ key_uses(OtpCert) -><br> Extensions = ssl_certificate:extensions_list(TBSExtensions),<br> case ssl_certificate:select_extension(?'id-ce-keyUsage', Extensions) of<br> undefined -><br>- undefined;<br>+ [];<br> #'Extension'{extnValue = KeyUses} -><br> KeyUses<br> end.<br> <br>+filter_keyuse_suites(_, [], CipherSuits, _) -><br>+ CipherSuits;<br> filter_keyuse_suites(Use, KeyUse, CipherSuits, Suites) -><br> case ssl_certificate:is_valid_key_usage(KeyUse, Use) of<br> true -><br><br><div class="gmail_extra"><br></div><div class="gmail_extra">Regards Ingela Erlang/OTP Team - Ericsson AB<br></div><div class="gmail_extra"><br><br><br><div class="gmail_quote">2018-05-04 17:41 GMT+02:00 Ingela Andin <span dir="ltr"><<a href="mailto:ingela.andin@gmail.com" target="_blank">ingela.andin@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div>Hi!<br><br></div>Thank you for the example <br><br></div>I did find one bug, the patch is here:<br><div><br>diff --git a/lib/ssl/src/ssl_cipher.erl b/lib/ssl/src/ssl_cipher.erl<br>index 0956d35..dd3dc54 100644<br>--- a/lib/ssl/src/ssl_cipher.erl<br>+++ b/lib/ssl/src/ssl_cipher.erl<br>@@ -2837,7 +2837,7 @@ key_uses(OtpCert) -><br> Extensions = ssl_certificate:extensions_<wbr>list(TBSExtensions),<br> case ssl_certificate:select_<wbr>extension(?'id-ce-keyUsage', Extensions) of<br> undefined -><br>- undefined;<br>+ [];<br> #'Extension'{extnValue = KeyUses} -><br> KeyUses<br> end.<br><br><br></div><div>my other sslv2 issue seems not to be related. (Probably a OpenSSL issue) Your example does however not work perfect <br></div><div>so I am continuing to look into this!<br><br></div><div>Regards Ingela Erlang/OTP team - Ericsson AB<br></div><div><div class="gmail-h5"><div><br><br><br><br><div><div><div class="gmail_extra"><br><div class="gmail_quote">2018-05-04 12:25 GMT+02:00 Roger Lipscombe <span dir="ltr"><<a href="mailto:roger@differentpla.net" target="_blank">roger@differentpla.net</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail-m_7929091992748227100gmail-">On 4 May 2018 at 08:32, Ingela Andin <<a href="mailto:ingela.andin@gmail.com" target="_blank">ingela.andin@gmail.com</a>> wrote:<br>
> This error is consistent with one of the errors I am seeing in the nightly<br>
> builds when running OpenSSL with only default parameters so I suspect<br>
> something is off in combination<br>
> version negotiation and cipher suite selection checks. I am looking in to<br>
> it!<br>
<br>
</span>I'm seeing the same, if it helps to reproduce. I generated my certificates with:<br>
<br>
#!/bin/sh<br>
<br>
# Create the CA key and certificate.<br>
openssl genrsa -out ca.key 2048<br>
openssl req -new -x509 -nodes -key ca.key -days 3653 -out ca.pem -subj<br>
"/CN=Test CA"<br>
<br>
# Create the server key and CSR.<br>
openssl genrsa -out server.key 2048<br>
openssl req -new -key server.key -out server.csr -subj "/CN=localhost"<br>
<br>
# Sign the CSR with the CA key.<br>
serial=$(date +"%s")<br>
openssl x509 -req -days 3563 -CA ca.pem -CAserial $serial<br>
-CAcreateserial -CAkey ca.key -in server.csr -out server.pem<br>
rm $serial<br>
<br>
I tested with:<br>
<br>
% Server<br>
{ok, _} = application:ensure_all_started<wbr>(ssl).<br>
Port = 11002.<br>
LOpts = [{certfile, "server.pem"}, {keyfile, "server.key"}].<br>
{ok, LSock} = ssl:listen(Port, LOpts).<br>
{ok, CSock} = ssl:transport_accept(LSock).<br>
ok = ssl:ssl_accept(CSock).<br>
<br>
% Client<br>
{ok, _} = application:ensure_all_started<wbr>(ssl).<br>
Port = 11002.<br>
COpts = [{verify, verify_peer}, {cacertfile, "ca.pem"}].<br>
{ok, Sock} = ssl:connect("localhost", Port, COpts).<br>
<br>
The server reports:<br>
<br>
=INFO REPORT==== 4-May-2018::11:22:20.971130 ===<br>
<span class="gmail-m_7929091992748227100gmail-">TLS server: In state hello at tls_handshake.erl:130 generated SERVER<br>
ALERT: Fatal - Handshake Failure - malformed_handshake_data<br>
<br>
</span>** exception error: no match of right hand side value<br>
{error,{tls_alert,"handshake failure"}}<br>
<br>
The client reports:<br>
<br>
=INFO REPORT==== 4-May-2018::11:22:20.981524 ===<br>
<span class="gmail-m_7929091992748227100gmail-">TLS client: In state hello received SERVER ALERT: Fatal - Handshake Failure<br>
<br>
</span>** exception error: no match of right hand side value<br>
{error,{tls_alert,"handshake failure"}}<br>
<br>
The same code works fine with 20.3.1<br>
<br>
Thanks,<br>
Roger.<br>
</blockquote></div><br></div></div></div></div></div></div></div>
</blockquote></div><br></div></div></div>