In this example we are going to create a Golang client to connect to our RabbitMQ server through TLS. For that, we will have to create self-signed SSL certificates and share those between the Golang application and the RabbitMQ server.

Create certificates

Create the Dockerfile below in your system and run docker build --no-cache . command. This will output the content of all the required certificate files in terminal. Manually create the files and keep them somewhere for now. For more details, visit  Using tls-gen’s Basic Profile link.

FROM python:3

RUN git clone https://github.com/michaelklishin/tls-gen tls-gen
RUN cd /tls-gen/basic && make PASSWORD= CN=localhost && make verify
## Without CN=localhost bit, which works just fine too.
## RUN cd /tls-gen/basic && make PASSWORD= && make verify

RUN cat /tls-gen/basic/result/ca_certificate.pem
RUN cat /tls-gen/basic/result/client_certificate.pem
RUN cat /tls-gen/basic/result/client_key.pem
RUN cat /tls-gen/basic/result/server_certificate.pem
RUN cat /tls-gen/basic/result/server_key.pem

#docker #go #rabbitmq #golang

Connecting to RabbitMQ Server From Golang with Self-signing SSL Certificates
3.30 GEEK