title: Python Pika connection with TLSv1_2
body: <p>I am using Python3.6 to get connection to RabbitMQ. This connection uses  TLSv1.2 protocol. Setting the connection parameters for SSL:</p>
  
  <pre><code>    cxt = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)
      ssl_options = pika.SSLOptions(context=cxt, server_hostname=rabbit_config['HOST'])
  
      conn_params = pika.ConnectionParameters(port=rabbit_config['PORT'],
                                              ssl_options=ssl_options,
                                              credentials=creds,
                                              virtual_host=rabbit_config['VIRTUAL_HOST'],
                                              channel_max=channel_size,
                                              heartbeat=heart_beat)
  </code></pre>
  
  <p>Getting following error when connecting to rabbitMq:</p>
  
  <pre><code>AMQPConnectionError: (AMQPConnectorSocketConnectError: ConnectionRefusedError(61, 'Connection refused'),)
  </code></pre>
  
  <p>I have referred pika docs for <a href="https://pika.readthedocs.io/en/stable/modules/parameters.html" rel="nofollow noreferrer">Connection Parameters</a>, and <a href="https://pika.readthedocs.io/en/stable/examples/tls_mutual_authentication.html" rel="nofollow noreferrer">TLS params example</a>, but no success so far.</p>
  
  <p>The similar code to connect to same Rabbit host is woriking in Java:</p>
  
  <pre><code>    @Bean
      CachingConnectionFactory connectionFactory(String host,
              Integer port, String username,
              String password, boolean ssl,
               String sslAlgorithm) throws KeyManagementException, NoSuchAlgorithmException {
  
          ConnectionFactory connectionFactory = new ConnectionFactory();
          connectionFactory.setHost(host);
          connectionFactory.setPort(port);
          connectionFactory.setUsername(username);
          connectionFactory.setPassword(password);
          if (ssl) {
            connectionFactory.useSslProtocol();
            connectionFactory.useSslProtocol(sslAlgorithm);
          }
  
          CachingConnectionFactory cachingConnectionFactory = new CachingConnectionFactory(connectionFactory);
          cachingConnectionFactory.setRequestedHeartBeat(50);
          cachingConnectionFactory.setChannelCacheSize(10);
          return cachingConnectionFactory;
      }
  </code></pre>