|
1 |
| -# docker-rabbitmq-ssl |
| 1 | +# RabbitMQ with SSL Configuration in Docker |
2 | 2 |
|
3 |
| -This repository has as goal to build a rabbitmq container with SSL. |
4 |
| -## To build this image: |
5 |
| -1. Go to `tests` directory: ``cd tests`` |
6 |
| -2. Run the script `build.sh`: ``./build.sh`` |
| 3 | +> RabbitMQ and SSL made easy for tests. |
7 | 4 |
|
8 |
| -The generated image contains SSL certificates on client side in `/home/client`. This directory is mounted as a volume to allowing the sharing of certificates. |
| 5 | +This repository aims at building a RabbitMQ container with SSL enabled. |
| 6 | +Generation of the server certificates, as well as server configuration, are performed during |
| 7 | +the image's build. A client certificate is generated when a container is created from this image. |
9 | 8 |
|
| 9 | +It is recommended to mount a volume so that the client certificate can be reached from the |
| 10 | +host system. Client certificates are generated under the **/home/client** directory. |
10 | 11 |
|
| 12 | + |
| 13 | +## To build this image |
| 14 | + |
| 15 | +``` |
| 16 | +cd tests && ./build.sh |
| 17 | +``` |
| 18 | + |
| 19 | +The generated image contains SSL certificates for the server side. |
| 20 | + |
| 21 | + |
| 22 | +## To run this image |
| 23 | + |
| 24 | +``` |
| 25 | +mkdir -p /tmp/docker-test \ |
| 26 | + && rm -rf /tmp/docker-test/* \ |
| 27 | + && docker run -d --rm -p 12000:5671 -v /tmp/docker-test:/home/client rabbitmq-with-ssl:latest |
| 28 | +``` |
| 29 | + |
| 30 | +Here, we bind the port 5671 from the container on the 12000 port on the local host. |
| 31 | +We also share a local directory with the container, to retrieve the client certificate. |
| 32 | +You can verify client certificates were generated with `ls /tmp/docker-test`. This directory contains |
| 33 | +a key store and a trust store, both in the PKCS12 format. |
| 34 | + |
| 35 | + |
| 36 | +## To stop the container |
| 37 | + |
| 38 | +`docker stop <container-id>` will stop the container. |
| 39 | +If you kept the `--rm` option, it will be deleted directly. |
| 40 | + |
| 41 | + |
| 42 | +## To run quick tests |
| 43 | + |
| 44 | +``` |
| 45 | +cd tests && ./test.sh |
| 46 | +``` |
| 47 | + |
| 48 | + |
| 49 | +## To diagnose troubles |
| 50 | + |
| 51 | +* Verify the client certificates were correctly generated: `ls -l /tmp/docker-test` |
| 52 | +* Inspect the container: `docker exec -ti <container-id> /bin/bash` |
| 53 | +* Check the logs: `docker logs <container-id>` |
| 54 | +* Verify the SSL connection works: `openssl s_client -connect 127.0.0.1:12000 -key /tmp/docker-test/key.pem` |
| 55 | +This last command will result in `Verify return code: 19 (self signed certificate in certificate chain)`, which is normal. |
| 56 | +We should specify the **-CApath**, which is inside the Docker container. This test is enough to verify SSL is enabled and |
| 57 | +the server is reachable from the host system. |
| 58 | + |
| 59 | + |
| 60 | +## Quick overview of the content |
| 61 | + |
| 62 | +* **Dockerfile**: the file with instructions to create a Docker image. |
| 63 | +* **rabbitmq.config**: the configuration file for RabbitMQ. |
| 64 | +* **openssl.cnf**: a configuration file used during certificates creation. |
| 65 | +* **prepare-server.sh**: a script during the generation of the image and that deals with server certificates. |
| 66 | +* **generate-client-keys.sh**: a script that is run by default when a container is created from this image. |
| 67 | +It deals with the generation of client certificates. |
0 commit comments