Git Product home page Git Product logo

python-tls's Introduction

Simple TLS connection

This example was tested under Ubuntu 18.04.2 with python 3.6.8.

Open the terminal and enter the following commands:

user@pc:~$ sudo apt install git -y
user@pc:~$ git clone https://github.com/arthurazs/python-tls

The first command install git, the second command downloads this repository.

Note that user@pc:~$ represents your username and computer name. You should type into the terminal only the text after the dollar sign, e.g. sudo apt install git -y.

Generate the certificate and private key

Open the terminal and enter the following commands:

user@pc:~$ cd python-tls
user@pc:~/python-tls$ openssl req -new -x509 -days 365 -nodes -out cert.pem -keyout key.pem -subj "/C=BR/ST=Rio de Janeiro/L=Niteroi/O=UFF/OU=Midiacom/CN=example.org/[email protected]"

The first command changes the directory to the downloaded repository, the second command generates the certificate and private key.

Note that you can change some parameters:

  • C, which is a 2 letter code for a country;
  • ST, which is a state or province name;
  • L (optional), which is a city name;
  • O, which is an organization name;
  • OU (optional), which is an organizational unit name;
  • CN, which is the hostname:
    • Warning If you change the CN value, you have to change the hostname under client.py to reflect the new hostname.
  • emailAddress (optional), which is an email address.

Running the TLS connection example

Run the server example

Open the terminal and enter the following commands:

user@pc:~$ cd python-tls
user@pc:~/python-tls$ python3 server.py

Run the client example

Open the terminal and enter the following commands:

user@pc:~$ cd python-tls
user@pc:~/python-tls$ python3 client.py

python-tls's People

Watchers

 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.