GithubHelp home page GithubHelp logo

transportlayersecurity.jl's Introduction

TransportLayerSecurity

Build Status

An API package defining a generic TLS interface allowing "user packages" to rely on a consistent set of types and functions to enable TLS communication, and encouraging "implementation packages" to implement the types and functions to become "swappable" candidates in "user packages".

To satisfy the interface, an implementing package should define:

  • An SSLConfig type holding various options and configurations
  • A constructor for SSLConfig with the signature SSLConfig(cert_file::String, key_file::String) constructing a "default" configuration given cert and key files
  • An SSLContext type representing a TLS-enable socket connection, a subtype of IO to allow reading requests from and writing responses to under TLS
  • A function setup!(tls::SSLContext, config::SSLConfig) that applies the SSLConfig configurations to a SSLContext socket
  • A function associate!(tls::SSLContext, tcp::TCPSocket) to associate a regular client TCPSocket with a TLS-enabled SSLContext
  • A function handshake!(tls::SSLContext) that performs the necessary handshake to initialize an https session

Users can then use this like functionality:

# load a package implementing the TransportLayerSecurity interface
using MbedTLS
# create a constant reference variable to our current TLS library
const TLS = MbedTLS

# create a default configuration
config = TLS.SSLConfig(cert_file, key_file)

# create a TLS socket
tls = TLS.SSLContext()

# setup our TLS socket with our configuration
TLS.setup!(tls, config)

# associate a client TCPSocket with our TLS socket
tcp = TCPSocket()
TLS.associate!(tls, tcp)

# perform TLS handshake to start a valid https session
# encrypted requests and responses can now be transferred over our TLS socket `tls`
TLS.handshake!(tls)

# read
bytes = readavailable(tls)
# write
write(tls, response)

This allows a user package to easily swap out a TLS implementation to another library if necessary.

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.