<div dir="ltr"><div><div><div>Hi!<br><br>Humm, well I take the patch back, I was a little to quick there. <br></div>I will come back with a new patch suggestion.<br></div>And of course we want to have a full understanding of the problem before making it official, so that we do not break anything else.<br><br></div>Regards Ingela Erlang/OTP team -Ericsson AB<br><div><div><div><div><br><div><br><br><div><div class="gmail_extra"><div class="gmail_quote">2015-06-08 11:02 GMT+02:00 Andreas Schultz <span dir="ltr"><<a href="mailto:aschultz@tpip.net" target="_blank">aschultz@tpip.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">Hi,<br>
<span class=""><br>
----- On 8 Jun, 2015, at 10:30, Ingela Andin <a href="mailto:ingela.andin@gmail.com">ingela.andin@gmail.com</a> wrote:<br>
<br>
> I think the following patch would solve the problem, in a good way.<br>
><br>
> I am not sure why they send an invalid value instead of no value, but this way<br>
> invalid values will be ignored and ssl will fallback to default values if there<br>
> are no valid values in the extension.<br>
<br>
</span>Some more context on this, RFC 5246, Section 7.4.1.4.1. has this to say about<br>
unknown values:<br>
<br>
Note: this extension is not meaningful for TLS versions prior to 1.2.<br>
Clients MUST NOT offer it if they are offering prior versions.<br>
However, even if clients do offer it, the rules specified in [TLSEXT]<br>
require servers to ignore extensions they do not understand.<br>
<br>
Also, the Apple server send the extension in question in an "Certificate Request",<br>
with the actual value beeing: 0xEF 0xEF (in decimal 239,239). IANA's TLS extension<br>
registry (<a href="http://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml" target="_blank">http://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml</a>)<br>
defines the range 224-255 for SignatureAlgorithm and HashAlgorithm as<br>
"Reserved for Private Use". So it is perfectly valid for the server to send those.<br>
<br>
Andreas<br>
<div><div class="h5"><br>
> diff --git a/lib/ssl/src/ssl_cipher.erl<br>
> b/lib/ssl/src/ssl_cipher.erl<br>
> index 8584e56..fd101ef 100644<br>
> --- a/lib/ssl/src/ssl_cipher.erl<br>
> +++ b/lib/ssl/src/ssl_cipher.erl<br>
> @@ -1573,8 +1573,9 @@ hash_algorithm(?SHA) -> sha;<br>
> hash_algorithm(?SHA224) -> sha224;<br>
> hash_algorithm(?SHA256) -> sha256;<br>
> hash_algorithm(?SHA384) -> sha384;<br>
> -hash_algorithm(?SHA512) -> sha512.<br>
> -<br>
> +hash_algorithm(?SHA512) -> sha512;<br>
> +hash_algorithm(_) -> undefined.<br>
> +<br>
> sign_algorithm(anon) -> ?ANON;<br>
> sign_algorithm(rsa) -> ?RSA;<br>
> sign_algorithm(dsa) -> ?DSA;<br>
> @@ -1582,7 +1583,8 @@ sign_algorithm(ecdsa) -> ?ECDSA;<br>
> sign_algorithm(?ANON) -> anon;<br>
> sign_algorithm(?RSA) -> rsa;<br>
> sign_algorithm(?DSA) -> dsa;<br>
> -sign_algorithm(?ECDSA) -> ecdsa.<br>
> +sign_algorithm(?ECDSA) -> ecdsa;<br>
> +sign_algorithm(_) -> undefined.<br>
><br>
> hash_size(null) -><br>
> 0;<br>
> diff --git a/lib/ssl/src/ssl_handshake.erl b/lib/ssl/src/ssl_handshake.erl<br>
> index 12a17cb..32da478 100644<br>
> --- a/lib/ssl/src/ssl_handshake.erl<br>
> +++ b/lib/ssl/src/ssl_handshake.erl<br>
> @@ -587,7 +587,11 @@ select_hashsign(#hash_sign_algos{hash_sign_algos =<br>
> HashSigns}, Cert, {Major, Min<br>
> #'OTPCertificate'{tbsCertificate = TBSCert} =public_key:pkix_decode_cert(Cert,<br>
> otp),<br>
> #'OTPSubjectPublicKeyInfo'{algorithm = {_,Algo, _}} =<br>
> TBSCert#'OTPTBSCertificate'.subjectPublicKeyInfo,<br>
> DefaultHashSign = {_, Sign} = select_hashsign_algs(undefined, Algo, Version),<br>
> - case lists:filter(fun({sha, dsa}) -><br>
> + case lists:filter(fun({_, undefined}) -> %% ignore invalid extension signature<br>
> values<br>
> + false;<br>
> + ({undefined, _}) -> %% ignore invalid extension hash values<br>
> + false;<br>
> + ({sha, dsa}) -><br>
> true;<br>
> ({_, dsa}) -><br>
> false;<br>
><br>
> Regards Ingela Erlang/OTP team - Ericsson AB<br>
><br>
><br>
><br>
><br>
> 2015-06-07 17:12 GMT+02:00 Denis Justinek < <a href="mailto:denis.justinek@gmail.com">denis.justinek@gmail.com</a> > :<br>
><br>
><br>
><br>
> Hello!<br>
><br>
> For the last few days I stared experiencing problems when connecting to Apple<br>
> Push Notification Service (APNS) with<br>
> Erlangs SSL.<br>
><br>
> When trying to connect I encounter the following error:<br>
><br>
> ** exception exit: {{function_clause,[{ssl_cipher,hash_algorithm,"ï",<br>
> [{file,"ssl_cipher.erl"},{line,1196}]},<br>
> {ssl_handshake,'-decode_handshake/3-lc$^0/1-0-',1,<br>
> [{file,"ssl_handshake.erl"},{line,945}]},<br>
> {ssl_handshake,'-decode_handshake/3-lc$^0/1-0-',1,<br>
> [{file,"ssl_handshake.erl"},{line,946}]},<br>
> {ssl_handshake,decode_handshake,3,<br>
> [{file,"ssl_handshake.erl"},{line,945}]},<br>
> {tls_handshake,get_tls_handshake_aux,3,<br>
> [{file,"tls_handshake.erl"},{line,155}]},<br>
> {tls_connection,next_state,4,<br>
> [{file,"tls_connection.erl"},{line,433}]},<br>
> {tls_connection,next_state,4,<br>
> [{file,"tls_connection.erl"},{line,437}]},<br>
> {gen_fsm,handle_msg,7,[{file,"gen_fsm.erl"},{line,503}]}]},<br>
> {gen_fsm,sync_send_all_state_event,<br>
> [<0.1221.0>,{start,1000},infinity]}}<br>
> in function gen_fsm:sync_send_all_state_event/3 (gen_fsm.erl, line 242)<br>
> in call from ssl_connection:sync_send_all_state_event/2 (ssl_connection.erl,<br>
> line 1654)<br>
> in call from ssl_connection:handshake/2 (ssl_connection.erl, line 101)<br>
> in call from tls_connection:start_fsm/8 (tls_connection.erl, line 81)<br>
> in call from ssl_connection:connect/8 (ssl_connection.erl, line 71)<br>
> 16:53:13.961 <0.1221.0> Undefined Undefined [error] gen_fsm <0.1221.0> in state<br>
> certify terminated with reason: no function clause matching<br>
> ssl_cipher:hash_algorithm(239) line 1196<br>
> 16:53:13.964 <0.1221.0> Undefined Undefined [error] CRASH REPORT Process<br>
> <0.1221.0> with 0 neighbours exited with reason: no function clause matching<br>
> ssl_cipher:hash_algorithm(239) line 1196 in gen_fsm:terminate/7 line 611<br>
> 16:53:13.965 <0.174.0> Undefined Undefined [error] Supervisor tls_connection_sup<br>
> had child undefined started with {tls_connection,start_link,undefined} at<br>
> <0.1221.0> exit with reason no function clause matching<br>
> ssl_cipher:hash_algorithm(239) line 1196 in context child_terminated<br>
><br>
> Steps to reproduce (you need an APNS certificate for this):<br>
><br>
> application:ensure_all_started(ssl).<br>
> Address = " <a href="http://gateway.sandbox.push.apple.com" target="_blank">gateway.sandbox.push.apple.com</a> ".<br>
> Port = 2195.<br>
> Cert = "cert.pem".<br>
> CertPass = "*****".<br>
> Options1 = [{certfile,Cert},{password,CertPass},{mode,binary}].<br>
> Timeout = 1000.<br>
> {ok,Socket} = ssl:connect(Address, Port, Options1, Timeout).<br>
><br>
> If we try to connect with the same certificate by using OpenSSL from command<br>
> line (s_client) if works fine with no errors.<br>
><br>
> Terminal command: openssl s_client -connect <a href="http://gateway.sandbox.push.apple.com:2195" target="_blank">gateway.sandbox.push.apple.com:2195</a><br>
> -cert cert.pem -debug<br>
> Enter pass phrase for cert.pem:<br>
> CONNECTED(00000003)<br>
> ...<br>
> Certificate chain<br>
> 0 s:/C=US/ST=California/L=Cupertino/O=Apple Inc./CN=<br>
> <a href="http://gateway.sandbox.push.apple.com" target="_blank">gateway.sandbox.push.apple.com</a><br>
</div></div>> i:/C=US/O=Entrust, Inc./OU= <a href="http://www.entrust.net/rpa" target="_blank">www.entrust.net/rpa</a> is incorporated by<br>
<span class="">> reference/OU=(c) 2009 Entrust, Inc./CN=Entrust Certification Authority - L1C<br>
</span>> 1 s:/C=US/O=Entrust, Inc./OU= <a href="http://www.entrust.net/rpa" target="_blank">www.entrust.net/rpa</a> is incorporated by<br>
<span class="">> reference/OU=(c) 2009 Entrust, Inc./CN=Entrust Certification Authority - L1C<br>
</span>> i:/O=Entrust.net/OU= <a href="http://www.entrust.net/CPS_2048" target="_blank">www.entrust.net/CPS_2048</a> incorp. by ref. (limits<br>
<span class="">> liab.)/OU=(c) 1999 Entrust.net Limited/CN=Entrust.net Certification Authority<br>
> (2048)<br>
> ---<br>
> ...<br>
> subject=/C=US/ST=California/L=Cupertino/O=Apple Inc./CN=<br>
> <a href="http://gateway.sandbox.push.apple.com" target="_blank">gateway.sandbox.push.apple.com</a><br>
</span>> issuer=/C=US/O=Entrust, Inc./OU= <a href="http://www.entrust.net/rpa" target="_blank">www.entrust.net/rpa</a> is incorporated by<br>
<div><div class="h5">> reference/OU=(c) 2009 Entrust, Inc./CN=Entrust Certification Authority - L1C<br>
> ---<br>
> No client certificate CA names sent<br>
> ---<br>
> SSL handshake has read 2760 bytes and written 2363 bytes<br>
> ---<br>
> New, TLSv1/SSLv3, Cipher is AES256-SHA<br>
> Server public key is 2048 bit<br>
> Secure Renegotiation IS supported<br>
> Compression: NONE<br>
> Expansion: NONE<br>
> SSL-Session:<br>
> Protocol : TLSv1<br>
> Cipher : AES256-SHA<br>
> Session-ID:<br>
> Session-ID-ctx:<br>
> Master-Key: ...<br>
> Key-Arg : None<br>
> Start Time: 1433689177<br>
> Timeout : 300 (sec)<br>
> Verify return code: 0 (ok)<br>
> ---<br>
><br>
> Is this an issue with Erlang SSL module? How can it be mitigated?<br>
><br>
> This can be reproduced on OSX and Linux - Erlang 17.4.<br>
><br>
> With regards,<br>
> Denis<br>
><br>
> _______________________________________________<br>
> erlang-questions mailing list<br>
> <a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
> <a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
><br>
><br>
><br>
> _______________________________________________<br>
> erlang-questions mailing list<br>
> <a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
> <a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
<br>
</div></div>--<br>
--<br>
Dipl. Inform.<br>
Andreas Schultz<br>
<br>
email: <a href="mailto:as@travelping.com">as@travelping.com</a><br>
phone: <a href="tel:%2B49-391-819099-224" value="+49391819099224">+49-391-819099-224</a><br>
mobil: <a href="tel:%2B49-170-2226073" value="+491702226073">+49-170-2226073</a><br>
<br>
------------------- enabling your networks -------------------<br>
<br>
Travelping GmbH phone: <a href="tel:%2B49-391-819099229" value="+49391819099229">+49-391-819099229</a><br>
Roentgenstr. 13 fax: <a href="tel:%2B49-391-819099299" value="+49391819099299">+49-391-819099299</a><br>
D-39108 Magdeburg email: <a href="mailto:info@travelping.com">info@travelping.com</a><br>
GERMANY web: <a href="http://www.travelping.com" target="_blank">http://www.travelping.com</a><br>
<br>
Company Registration: Amtsgericht Stendal Reg No.: HRB 10578<br>
Geschaeftsfuehrer: Holger Winkelmann | VAT ID No.: DE236673780<br>
--------------------------------------------------------------<br>
</blockquote></div><br></div></div></div></div></div></div></div></div>