Giter Site home page Giter Site logo

ligzy / rabbitssl Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nepitwin/rabbitssl

0.0 1.0 0.0 170 KB

Example Java, Spring-Boot and Python RabbitMQ SSL configuration

License: Apache License 2.0

Java 78.02% Python 16.69% Shell 1.61% Dockerfile 3.68%

rabbitssl's Introduction

RabbitMQ - SSL Example

SSL-Example for Python and Java Clients from https://www.rabbitmq.com/ssl.html.

Docker - RabbitMQ-Server

If you don't want create your own RabbitMQ-Server a docker container can be used. Build and Start a sample RabbitMQ TLS Docker Container to test TLS-Messaging. Build docker container or use container from Dockerhub.

cd Docker
docker build --rm=true --tag=ssl/rabbit .
docker run -d -p 5671:5671 ssl/rabbit
docker pull nepitwin/rabbitssl
docker run -d -p 5671:5671 nepitwin/rabbitssl

RabbitMQ-Server Certificates

SSL Certificate Generation

Using tls-gen's tool from michael klishin --> https://github.com/michaelklishin/tls-ge

git clone https://github.com/michaelklishin/tls-gen
cd tls-gen/basic
# private key password
make PASSWORD=bunnies
make verify
make info
ls -l ./result
# Files generated in result folder
--> ca_certificate.pem
--> ca_key.pem
--> client_certificate.pem
--> client_key.p12
--> client_key.pem
--> server_certificate.pem
--> server_key.p12
--> server_key.pem

Create a Java Keystore File

https://docs.cloudera.com/documentation/enterprise/5-10-x/topics/cm_sg_openssl_jks.html

cd result

keytool.exe -importkeystore -srckeystore server_key.p12
  -srcstoretype PKCS12 -srcstorepass bunnies 
  -deststorepass bunnies -destkeypass password 
  -destkeystore server_store.jks

SSL Certificate Setup

Copy /Certificates/testca/cacert.pem, /Certificates/server/key.pem and /Certificates/server/cert.pem to /etc/ssl/rabbit/ to setup certificate example files to establish a RabbitMQ-TLS connection.

cd /etc/ssl/
mkdir rabbit
cd <GIT_Project_PATH>
cp /Certificates/testca/cacert.pem /etc/ssl/rabbit/cacert.pem
cp /Certificates/server/cert.pem /etc/ssl/rabbit/cert.pem
cp /Certificates/server/key.pem /etc/ssl/rabbit/key.pem

SSL-Configuration

Copy this example file for RabbiMQ and restart service.

[
  {rabbit, [
     {ssl_listeners, [5671]},
     {ssl_options, [{cacertfile,"/etc/ssl/rabbit/cacert.pem"},
                    {certfile,"/etc/ssl/rabbit/cert.pem"},
                    {keyfile,"/etc/ssl/rabbit/key.pem"},
                    {verify,verify_peer},
                    {fail_if_no_peer_cert,true}]}
   ]}
].

Execute Examples

Use Java (Gradle) or Python examples to execute examples.

Python

Python client is split up for a consumer (rabitssl_consume.py) and producer (rabitssql_send.py). Producer sends a message to RabbitMQ-Server and consumer receives this message. PIKA is needed to establish connections.

cd Python
python rabitssql_consume.py/rabitssql_send.py

Java

Java client sends and receives message from a single main file. Simple use Gradle to build and run example.

cd Java
gradle run

Spring-Boot-amqp

RabbitMQ-SSL Spring-Boot example can be build and executed to use Gradle. Clients sends by scheduled task every 5 seconds a sample message.

cd Spring
gradle bootRun

License

Copyright 2017-2018 Andreas Sekulski

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

rabbitssl's People

Contributors

nepitwin avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.