Coder Social home page Coder Social logo

two-way-ssl-c's Introduction

Two-way SSL authentication example in C

A simple example program that demonstrates two-way authentication between a client and the server.

There are a couple of things to be noted here:

  1. Hostname verification is not performed. If you want to perform it, you should take a look at this repository.
  2. Don't plugin this code directly into multi-threaded applications, you need to call some additional routines so that OpenSSL routines become reentrant.
  3. You can generate the keys by looking at this gist or by using the included script certs_gen.sh (Unix based OS).

Steps to run the example

Pre-requisities

  • Any decent C compiler
  • OpenSSL development library

Build

make

Create the certificates

To create the certificates and the private keys call ./certs_gen.sh. It creates a subdirectory certs which contains the privates keys, the certificate requests and the certificates.

Server

The server side can be executed either using the openssl CLI or this example.

Using this example

./ssl-2way server 8888 ./certs/ca/ca_cert.pem ./certs/server/server_cert.pem ./certs/server/private/server_key.pem

Using the opensll CLI

openssl s_server -accept 8888 -cert ./certs/server/server_cert.pem -key ./certs/server/private/server_key.pem -CAfile ./certs/ca/ca_cert.pem

Client

The client side can be executed either using the openssl CLI or this example.

Using this example

./ssl-2way client 0.0.0.0:8888 ./certs/ca/ca_cert.pem ./certs/client/client_cert.pem ./certs/client/private/client_key.pem

Using the opensll CLI

openssl s_client -connect 0.0.0.0:8888 -cert ./certs/client/client_cert.pem -key ./certs/client/private/client_key.pem -CAfile ./certs/ca/ca_cert.pem -showcerts  -msg

two-way-ssl-c's People

Contributors

agambier avatar zapstar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

two-way-ssl-c's Issues

Handshake fail

I am getting "Could not perform SSL handshake" on the server side. Any solution?

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.