Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERL-259: TLS/SSL connection issues #3536

Closed
OTP-Maintainer opened this issue Sep 21, 2016 · 9 comments
Closed

ERL-259: TLS/SSL connection issues #3536

OTP-Maintainer opened this issue Sep 21, 2016 · 9 comments
Assignees
Labels
bug Issue is reported as a bug priority:medium team:PS Assigned to OTP team PS
Milestone

Comments

@OTP-Maintainer
Copy link

Original reporter: laffer1
Affected version: OTP-19.0.2
Fixed in version: OTP-19.1.1
Component: Not Specified
Migrated from: https://bugs.erlang.org/browse/ERL-259


In Erlang 19.0.6 and 19.0.7, I noticed problems with some applications connecting via TLS/SSL from .NET/C#.  This does not occur with 18.3.x on the same platform (FreeBSD 10.3 with ports) 

My test case is rabbit mq 3.6.5 with TLS enabled. 

i see handshake failed from .NET clients and java clients work as expected. 
@OTP-Maintainer
Copy link
Author

ingela said:

Could it  be the same problem as in ERL-206 ?

@OTP-Maintainer
Copy link
Author

ingela said:

We have just discovered one bug that happens when using firefox as a client and that we think will be solved by the following patch. Would it help your case?
If not we would like some more details.

{code:java}
diff --git a/lib/ssl/src/ssl_connection.hrl b/lib/ssl/src/ssl_connection.hrl
index f1e612a..d1ed628 100644
--- a/lib/ssl/src/ssl_connection.hrl
+++ b/lib/ssl/src/ssl_connection.hrl
@@ -48,6 +48,7 @@
           socket_options        :: #socket_options{},
           connection_states     :: ssl_record:connection_states() | secret_printout(),
 	  protocol_buffers      :: term() | secret_printout() , %% #protocol_buffers{} from tls_record.hrl or dtls_recor.hrl
+	  unprocessed_handshake_events = 0    :: integer(),
           tls_handshake_history :: ssl_handshake:ssl_handshake_history() | secret_printout()
                                  | 'undefined',
 	  cert_db               :: reference() | 'undefined',
diff --git a/lib/ssl/src/tls_connection.erl b/lib/ssl/src/tls_connection.erl
index 9b90314..9401785 100644
--- a/lib/ssl/src/tls_connection.erl
+++ b/lib/ssl/src/tls_connection.erl
@@ -421,7 +421,7 @@ handle_common_event(internal,  #ssl_tls{type = ?HANDSHAKE, fragment = Data},
 	    connection ->
 		ssl_connection:hibernate_after(StateName, State, Events);
 	    _ ->
-		{next_state, StateName, State, Events}
+		{next_state, StateName, State#state{unprocessed_handshake_events = no_events(Events)}, Events}
 	end
     catch throw:#alert{} = Alert ->
 	    ssl_connection:handle_own_alert(Alert, Version, StateName, State0)
@@ -537,7 +537,9 @@ next_tls_record(Data, #state{protocol_buffers = #protocol_buffers{tls_record_buf
 	#alert{} = Alert ->
 	    Alert
     end.
-
+next_record(#state{unprocessed_handshake_events = N} = State) when N > 0 ->
+    {no_record, State#state{unprocessed_handshake_events = N-1}};
+					 
 next_record(#state{protocol_buffers =
 		       #protocol_buffers{tls_packets = [], tls_cipher_texts = [CT | Rest]}
 		   = Buffers,
@@ -712,3 +714,5 @@ gen_info(Event, StateName, #state{negotiated_version = Version} = State) ->
 					    Version, StateName, State)  
     end.
 	    
+no_events(Events) ->
+    erlang:length(Events)-1.

{code}

@OTP-Maintainer
Copy link
Author

laffer1 said:

I won't be able to test the patch until Monday. However, what other details would be of use?

Here's a little more information about the environment:
* Server: FreeBSD 10.3 with latest patches (excluding the TLS patch released today)
* TLS/SSL certificate is not self signed, but it is from a weird CA.  This is generated by the university of michigan CA which is based on an  InCommon RSA Server CA.  You can see a similar certificate generated by the same process at https://api.dev.umich.edu/health if it is helpful.  The message queue is limited by ip rules so I can't expose that for testing. 
* I can provide the source code for the test client I created on Monday, although it's basically just the example from RabbitMQ but without sending a client cert for authentication (just password auth)  using .NET 4.5.1 / C# on Windows 7 Enterprise with latest patches and service packs. 

Regarding versions and patches of erlang, it was built from FreeBSD ports with this version working https://svnweb.freebsd.org/ports?view=revision&revision=420247 and this version broken  https://svnweb.freebsd.org/ports?view=revision&revision=422137

@OTP-Maintainer
Copy link
Author

ingela said:

Could you tell me what TLS Alert the connection fails with? Have you tested the patch?

@OTP-Maintainer
Copy link
Author

ingela said:

Have you tested the patch? If you have problems applying it you can take 19.1.1 that has now been released.

@OTP-Maintainer
Copy link
Author

ingela said:

I think that your problem is likely fixed by 19.1.1 if not you are welcome to reopen this issue.

@OTP-Maintainer
Copy link
Author

leachdaniel said:

@laffer1 were you able to confirm this worked? I'm having the same problem but it's with 19.1.1

@OTP-Maintainer
Copy link
Author

ingela said:

@leachdaniel Did you try specefing the versions option to only use TLS-1.2  to rule out  ERL-206? 

@OTP-Maintainer
Copy link
Author

leachdaniel said:

I cannot connect with a .Net client using TLS 1.0, 1.1 and 1.2. The same Cert and CA work with openssl and Python. Server sends back a Handshake Failure alert after the .Net client sends the handshake message containing cert.


@OTP-Maintainer OTP-Maintainer added bug Issue is reported as a bug team:PS Assigned to OTP team PS priority:medium labels Feb 10, 2021
@OTP-Maintainer OTP-Maintainer added this to the OTP-19.1.1 milestone Feb 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue is reported as a bug priority:medium team:PS Assigned to OTP team PS
Projects
None yet
Development

No branches or pull requests

2 participants