Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Commit 267ff3a

Browse files
committed
common: TLS connections to the production AMQP backend need "amqps://"
1 parent a798e62 commit 267ff3a

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

common/live.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,13 @@ func CloseMQConnection(connection *amqp.Connection) (err error) {
108108
// ConnectMQ creates a connection to the backend MQ server
109109
func ConnectMQ(nodeName string) (channel *amqp.Channel, err error) {
110110
var conn *amqp.Connection
111-
conn, err = amqp.Dial(fmt.Sprintf("amqp://%s:%s@%s:%d/", Conf.MQ.Username, Conf.MQ.Password, Conf.MQ.Server, Conf.MQ.Port))
111+
if Conf.Environment.Environment == "production" {
112+
// Force use of TLS in production
113+
conn, err = amqp.Dial(fmt.Sprintf("amqps://%s:%s@%s:%d/", Conf.MQ.Username, Conf.MQ.Password, Conf.MQ.Server, Conf.MQ.Port))
114+
} else {
115+
// Everywhere else (eg docker container) doesn't *have* to use TLS
116+
conn, err = amqp.Dial(fmt.Sprintf("amqp://%s:%s@%s:%d/", Conf.MQ.Username, Conf.MQ.Password, Conf.MQ.Server, Conf.MQ.Port))
117+
}
112118
if err != nil {
113119
return
114120
}

0 commit comments

Comments
 (0)