All Projects → darrenjs → Openssl_examples

darrenjs / Openssl_examples

Licence: mit
examples of using OpenSSL

Programming Languages

c
50402 projects - #5 most used programming language

Labels

Projects that are alternatives of or similar to Openssl examples

easy-shell
A pure Python script to easily get a reverse shell
Stars: ✭ 48 (-28.36%)
Mutual labels:  ssl, socket
Python Mocket
a socket mock framework - for all kinds of socket animals, web-clients included
Stars: ✭ 209 (+211.94%)
Mutual labels:  socket, ssl
Tls Channel
A Java library that implements a ByteChannel interface over SSLEngine, enabling easy-to-use (socket-like) TLS for Java applications.
Stars: ✭ 113 (+68.66%)
Mutual labels:  socket, ssl
Beetlex
high performance dotnet core socket tcp communication components, support TLS, HTTP, HTTPS, WebSocket, RPC, Redis protocols, custom protocols and 1M connections problem solution
Stars: ✭ 802 (+1097.01%)
Mutual labels:  socket, ssl
Testssl.sh
Testing TLS/SSL encryption anywhere on any port
Stars: ✭ 5,676 (+8371.64%)
Mutual labels:  socket, ssl
Hp Socket
High Performance TCP/UDP/HTTP Communication Component
Stars: ✭ 4,420 (+6497.01%)
Mutual labels:  socket, ssl
Androidasyncsocketexamples
This project includes a few examples on how to create different types of sockets using AndroidAsync. It includes examples for a TCP client/server, TCP client with SSL and UDP client/server.
Stars: ✭ 152 (+126.87%)
Mutual labels:  socket, ssl
Yasio
A multi-platform support c++11 library with focus on asio (asynchronous socket I/O) for any client application.
Stars: ✭ 483 (+620.9%)
Mutual labels:  socket, ssl
Elixir Socket
Socket wrapping for Elixir.
Stars: ✭ 642 (+858.21%)
Mutual labels:  socket, ssl
Bigq
Messaging platform in C# for TCP and Websockets, with or without SSL
Stars: ✭ 18 (-73.13%)
Mutual labels:  socket, ssl
Vibe Core
Repository for the next generation of vibe.d's core package.
Stars: ✭ 56 (-16.42%)
Mutual labels:  socket
Quibbler
An experimental website powered by Socket.IO where anonymous chat messages are beautifully visualized in real time
Stars: ✭ 57 (-14.93%)
Mutual labels:  socket
Gmtls
GM TLS/SSL Based on Golang (基于国密算法的TLS/SSL代码库)
Stars: ✭ 63 (-5.97%)
Mutual labels:  ssl
Newsup
Fully feature high performance binary usenet uploader/poster
Stars: ✭ 65 (-2.99%)
Mutual labels:  ssl
Notifier
NO LIBRARIES socket per page bridge for your Laravel application. (CLIENT PART INCLUDED)
Stars: ✭ 57 (-14.93%)
Mutual labels:  socket
Castore
Up-to-date certificate store for Elixir.
Stars: ✭ 62 (-7.46%)
Mutual labels:  ssl
Ssl Baseline
DevSec SSL/TLS Baseline - InSpec Profile
Stars: ✭ 56 (-16.42%)
Mutual labels:  ssl
Omigo
☎️ A mobile compatible anonymous random chat using socket.io and WebRTC
Stars: ✭ 55 (-17.91%)
Mutual labels:  socket
Esp8266 Wifi Socket
Custom SW for the OBI "Wifi Stecker Schuko"
Stars: ✭ 55 (-17.91%)
Mutual labels:  socket
React Deploy S3
Deploy create react app's in AWS S3
Stars: ✭ 66 (-1.49%)
Mutual labels:  ssl

openssl_examples

examples of using OpenSSL

ssl_server_nonblock.c is a simple OpenSSL example program to illustrate the use of memory BIO's (BIO_s_mem) to perform SSL read and write with non-blocking socket IO.

The program accepts connections from SSL clients. To keep it simple only a single live connection is supported. While a client is connected the program will receive any bytes which it sends, unencrypt them and write to stdout, using non-blocking socket reads. It will also read from stdin, encrypt the bytes and send to the client, using non-blocking socket writes.

Note that this program is single threaded. This means it does not have to set up SSL locking. The program does not exit, and so it does not have code to free up the resources associated with the SSL context and library.

ssl_client_nonblock.c is a client version of the same program.

Compilation

To compile the program, use something like:

    gcc ssl_server_nonblock.c -Wall -O0 -g3 -std=c99 -lcrypto -lssl -o ssl_server_nonblock

Or on MacOS:

 gcc -Wall -O0 -g3 -std=c99 -I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib -lssl -lcrypto  -o ssl_server_nonblock ssl_server_nonblock.c

Or just try the makefile, for Linux platforms.

On Ubuntu systems you may need to run sudo apt install libssl-dev to install OpenSSL headers.

Running

Running the program requires that a SSL certificate and private key are available to be loaded. These can be generated using the 'openssl' program using these steps:

  1. Generate the private key, this is what we normally keep secret:
    openssl genrsa -des3 -passout pass:ABCD -out server.pass.key 2048
    openssl rsa -passin pass:ABCD -in server.pass.key -out server.key
    rm -f server.pass.key
  1. Next generate the CSR. We can leave the password empty when prompted (because this is self-sign):
    openssl req -new -key server.key -out server.csr
  1. Next generate the self signed certificate:
    openssl x509 -req -sha256 -days 365 -in server.csr -signkey server.key -out server.crt
    rm -f server.csr

The openssl program can also be used to connect to this program as an SSL client. Here's an example command (assuming we're using port 55555):

    openssl s_client -connect 127.0.0.1:55555 -msg -debug -state -showcerts

Flow of encrypted & unencrypted bytes

This diagram shows how the read and write memory BIO's (rbio & wbio) are associated with the socket read and write respectively. On the inbound flow (data into the program) bytes are read from the socket and copied into the rbio via BIO_write. This represents the the transfer of encrypted data into the SSL object. The unencrypted data is then obtained through calling SSL_read. The reverse happens on the outbound flow to convey unencrypted user data into a socket write of encrypted data.

  +------+                                    +-----+
  |......|--> read(fd) --> BIO_write(rbio) -->|.....|--> SSL_read(ssl)  --> IN
  |......|                                    |.....|
  |.sock.|                                    |.SSL.|
  |......|                                    |.....|
  |......|<-- write(fd) <-- BIO_read(wbio) <--|.....|<-- SSL_write(ssl) <-- OUT
  +------+                                    +-----+

          |                                  |       |                     |
          |<-------------------------------->|       |<------------------->|
          |         encrypted bytes          |       |  unencrypted bytes  |
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].