<p>I am trying to access rabbitmq cluster where TLS is enabled. I have written sample go app which trying to connect to the rabbitmq server using set of client certificates and client keys.</p>
<p>I am facing error -</p>
<pre><code>Error is - Exception (403) Reason: &quot;username or password not allowed&quot;
panic: Exception (403) Reason: &quot;username or password not allowed&quot;
</code></pre>
<p>My code snippet</p>
<pre><code>package main

import (
    &quot;crypto/tls&quot;
    &quot;crypto/x509&quot;
    &quot;fmt&quot;
    &quot;io/ioutil&quot;
    &quot;log&quot;

    &quot;github.com/streadway/amqp&quot;
)

func main() {
    fmt.Println(&quot;Go RabbitMQ Consumer Tutorial&quot;)
    fmt.Println(&quot;Testing ClusterIP service connection over TLS&quot;)

    cert, err := tls.LoadX509KeyPair(&quot;client.crt&quot;, &quot;client.key&quot;)
    if err != nil {
        panic(err)
    }
    //Load CA cert.
    caCert, err := ioutil.ReadFile(&quot;ca.crt&quot;) // The same you configured in your MQ server
    if err != nil {
        log.Fatal(err)
    }
    caCertPool := x509.NewCertPool()
    caCertPool.AppendCertsFromPEM(caCert)

    TlsConfig1 := &amp;tls.Config{
        Certificates:       []tls.Certificate{cert}, // from tls.LoadX509KeyPair
        RootCAs:            caCertPool,
        InsecureSkipVerify: true,
        // ...other options are just the same as yours
    }
    
    conn, err := amqp.DialTLS(&quot;amqps://&lt;username&gt;:&lt;password&gt;@&lt;rabbitmq-service-name&gt;.&lt;namespace&gt;.svc.cluster.local:5671/&quot;, TlsConfig1)
    if err != nil {
        fmt.Println(&quot;Error is -&quot;, err)
        panic(err)
    }

    fmt.Println(&quot;Connected to consumer successfully&quot;)
    defer conn.Close()

    ch, err := conn.Channel()
    if err != nil {
        fmt.Println(err)
    }
    defer ch.Close()

    if err != nil {
        fmt.Println(err)
    }

    msgs, err := ch.Consume(
        &quot;TestQueue&quot;,
        &quot;&quot;,
        true,
        false,
        false,
        false,
        nil,
    )

    forever := make(chan bool)
    go func() {
        for d := range msgs {
            fmt.Printf(&quot;Recieved Message: %s\n&quot;, d.Body)
        }
    }()

    fmt.Println(&quot;Successfully Connected to our RabbitMQ Instance&quot;)
    fmt.Println(&quot; [*] - Waiting for messages&quot;)
    &lt;-forever

}
</code></pre>
<p>The code snippet is running as pod in the EKS cluster where my rabbitmq cluster is running.</p>

Rajendra Gosavi
<p>After going through the rabbitmq TLS debugging doc- <a href="https://www.rabbitmq.com/access-control.html" rel="nofollow noreferrer">https://www.rabbitmq.com/access-control.html</a> I figured out that I was giving wrong username and password.</p>
<p>NOTE: if any one who is also getting the same error - please confirm that you are using correct username and password.</p>
<p>You can check the username and password for the cluster by logging into the rabbitmq cluster pod.</p>
