Giter VIP home page Giter VIP logo

stunnel's Introduction

STunnel Docker Container

From the stunnel website:

stunnel is an open-source multi-platform application used to provide a universal TLS/SSL tunneling service. stunnel can be used to provide secure encrypted connections for clients or servers that do not speak TLS or SSL natively

Supported Tags and Respective Dockerfile Links

Examples

Allow Local Insecure Clients to Connect to PKI-Secured SSL/TLS Server

These examples show how you would proxy Redis clients that do not support TLS/SSL to a TLS-secured Redis server on Azure (should apply similarly to AWS).

Using the Default Root Certificate Chain

This example uses the default trusted root CA chain from Alpine Linux:

docker run -itd \
    -e STUNNEL_CLIENT=yes \
    -e STUNNEL_SERVICE=redis \
    -e STUNNEL_ACCEPT=6379 \
    -e STUNNEL_CONNECT=myredis.redis.cache.windows.net:6380 \
    -e STUNNEL_CHECK_HOST=myredis.redis.cache.windows.net \
    -e STUNNEL_VERIFY_CHAIN=yes \
    -p 6379:6379 \
    guyelsmorepaddock/stunnel

Using a Custom Root Certificate Chain

This example shows how to provide your own trusted root certificate chain:

docker run -itd \
    -e STUNNEL_CLIENT=yes \
    -e STUNNEL_SERVICE=redis \
    -e STUNNEL_ACCEPT=6379 \
    -e STUNNEL_CONNECT=myredis.redis.cache.windows.net:6380 \
    -e STUNNEL_CHECK_HOST=myredis.redis.cache.windows.net \
    -e STUNNEL_VERIFY_CHAIN=yes \
    -p 6379:6379 \
    -v /etc/ssl/private/ca-certificates.crt:/etc/ssl/certs/ca-certificates.crt:ro \
    guyelsmorepaddock/stunnel

This loads the custom certificate chain from /etc/ssl/private/ca-certificates.crt on the host system into /etc/ssl/certs/ca-certificates.crt in the container, which is the default location the container looks for the certificates. The location within the container can be overridden by setting the STUNNEL_CAFILE environment variable.

Wrap Local Server for PKI-Secured SSL/TLS Client Connections

These examples show you would secure an LDAP server running in a container named directory so that clients can connect to it over LDAPS.

Self-signed Certificate

docker run -itd --name ldaps --link directory:ldap \
    -e STUNNEL_SERVICE=ldaps \
    -e STUNNEL_ACCEPT=636 \
    -e STUNNEL_CONNECT=ldap:389 \
    -p 636:636 \
    guyelsmorepaddock/stunnel

This will automatically generate a self-signed certificate that expires in 365 days.

Custom Certificate

docker run -itd --name ldaps --link directory:ldap \
    -e STUNNEL_SERVICE=ldaps \
    -e STUNNEL_ACCEPT=636 \
    -e STUNNEL_CONNECT=ldap:389 \
    -p 636:636 \
    -v /etc/ssl/private/server.key:/etc/stunnel/stunnel.key:ro \
    -v /etc/ssl/private/server.crt:/etc/stunnel/stunnel.pem:ro \
    guyelsmorepaddock/stunnel

This accomplishes the following:

  • Loads the server private key from /etc/ssl/private/server.key on the host system into /etc/stunnel/stunnel.key in the container, which is the default location the container looks for the key. The location within the container can be overridden by setting the STUNNEL_KEY environment variable.

  • Loads the server certificate from /etc/ssl/private/server.crt on the host system into /etc/stunnel/stunnel.pem in the container, which is the default location the container looks for the certificate. The location within the container can be overridden by setting the STUNNEL_CRT environment variable.

Using a Custom Cipher List

By default, the container configures stunnel to use only ciphers indicated as "Grade A" on the OWASP Cheat Sheet (as of 2019-01-25).

For a variety of reasons, including a desire for more security, a need for compatibility with legacy systems and/or a delay in getting updates from vendors, this default may not work for everyone's needs.

This example shows how to provide your own list of allowed ciphers:

docker run -itd --name ldaps --link directory:ldap \
    -e STUNNEL_SERVICE=ldaps \
    -e STUNNEL_ACCEPT=636 \
    -e STUNNEL_CONNECT=ldap:389 \
    -e "STUNNEL_CIPHERS=DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-SHA256:DHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA"
    -p 636:636 \
    -v /etc/ssl/private/server.key:/etc/stunnel/stunnel.key:ro \
    -v /etc/ssl/private/server.crt:/etc/stunnel/stunnel.pem:ro \
    guyelsmorepaddock/stunnel

This example switches stunnel to using the "Broad Compatibility (Grade B)" list of ciphers from OWASP (as of 2019-01-25).

Allow Local Insecure Clients to Connect to PSK-Secured Server

This example demonstrates how to connect to a service that as been secured with a pre-shared key (PSK):

docker run -itd \
    -e STUNNEL_CLIENT=yes \
    -e STUNNEL_SERVICE=myservice \
    -e STUNNEL_CONNECT=myservice.net:1234 \
    -e STUNNEL_ACCEPT=6379 \
    -e STUNNEL_PSK=/etc/stunnel/stunnel.psk \
    -v /etc/ssl/private/server.psk:/etc/stunnel/stunnel.psk:ro \
    -p 6379:6379 \
    guyelsmorepaddock/stunnel

Wrap Local Server for PSK-Secured Client Connections

This example demonstrates how to secure a service with a pre-shared key (PSK):

docker run -itd \
    -e STUNNEL_SERVICE=myservice \
    -e STUNNEL_CONNECT=myservice.net:1234 \
    -e STUNNEL_ACCEPT=6379 \
    -e STUNNEL_PSK=/etc/stunnel/stunnel.psk \
    -v /etc/ssl/private/server.psk:/etc/stunnel/stunnel.psk:ro \
    -p 6379:6379 \
    guyelsmorepaddock/stunnel

Copyright Notice

The MIT License (MIT)

Copyright © 2015-2017 Jacob Blain Christen
Portions Copyright © 2017-2018, Emmanuel Frecon
Portions Copyright © 2018, Frederik Weber
Portions Copyright © 2018, "The Goofball (goofball222)"
Portions Copyright © 2019, Inveniem

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

stunnel's People

Contributors

dweomer avatar goofball222 avatar guypaddock 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.