2

I’m new to rabbitmq but I have to connect to remote broker to send and receive messages. Remote server is out of my control and it’s almost impossible to get answers from its team. Nevertheless, I have address, port, virtual host and user credentials at my disposal. Server uses TLS v1.2. The problem is I cannot establish connection to the server with .NET client. Client is “rabbitmq.client.5.1.0”, .NET Framework 4.5.1 and VS 2017. My code is:

public bool Start() {
  try {
    var f = new ConnectionFactory();
    f.UserName = "TestUser";
    f.Password = "TestPwd";
    f.HostName = "x.x.x.x";
    f.Port = 5673;
    f.VirtualHost = "TestVH";

    f.Ssl.Version = SslProtocols.Tls12;
    f.Ssl.Enabled = true;
    f.Ssl.AcceptablePolicyErrors = SslPolicyErrors.RemoteCertificateChainErrors
        | SslPolicyErrors.RemoteCertificateNameMismatch
        | SslPolicyErrors.RemoteCertificateNotAvailable;
    var c = f.CreateConnection();
  } catch( Exception e ) {
    throw e;
  }
}

It throws an exception which innermost is:

Authentication failed because the remote party has closed the transport stream.

(Wireshark capture).

If I do it with Java (1.8, amqp-client-4.0.2), I can successfully connect to the server.

public static void main( String[] args ) throws Exception{
  ConnectionFactory factory = new ConnectionFactory();
  factory.setHost("x.x.x.x");
  factory.setPort(5673);
  factory.setUsername( "TestUser" );
  factory.setPassword( "TestPwd" );
  factory.setVirtualHost( "TestVH" );

  factory.useSslProtocol("TLSv1.2");
  Connection conn = factory.newConnection();
}

Wireshark capture

I would like to use C# to get the job done but I can not sort this thing out. Any help would be greatly appreciated!

4
  • What if you try to use Tls11 or Tls10 ? Commented Oct 17, 2018 at 7:28
  • It brings me the same result - remote server closes connection =\ Commented Oct 17, 2018 at 14:36
  • If you can get the logged message from RabbitMQ, that may help. Otherwise, I suggest following the TLS troubleshooting guide. What I would like to know is what cipher is being used by the Java connection vs the .NET one. That may be the difference. Use the openssl s_client command to get that information. Commented Oct 17, 2018 at 15:26
  • Thx for the tip, I will look into it! Commented Oct 17, 2018 at 17:56

1 Answer 1

2

try changing this line:

f.Ssl.Version = SslProtocols.Tls12;

to this:

f.Ssl.Version = SslProtocols.Tls12 | SslProtocols.Ssl3 | SslProtocols.Tls11 | SslProtocols.Ssl2;

If that works then you narrow them down

Sign up to request clarification or add additional context in comments.

1 Comment

I tried your suggestion, but it gives the same result. I was curious about Java, seems it uses some other settings (for ssl?). Its message longer then one C# is sending.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.