sslexample

sslexample.git
git clone git://git.lenczewski.org/sslexample.git
Log | Files | Refs

commit 7d462fcd193af006ab4484bbb85953d026c5bf3e
Author: MikoĊ‚aj Lenczewski <mblenczewski@gmail.com>
Date:   Sat, 14 Jun 2025 15:03:39 +0100

Initial commit

Diffstat:
A.editorconfig | 17+++++++++++++++++
A.gitignore | 8++++++++
Abuild.sh | 15+++++++++++++++
Aclean.sh | 5+++++
Agencert.sh | 6++++++
Asslclient.c | 14++++++++++++++
Asslserver.c | 14++++++++++++++
7 files changed, 79 insertions(+), 0 deletions(-)

diff --git a/.editorconfig b/.editorconfig @@ -0,0 +1,17 @@ +root = true + +[*] +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true +charset = utf-8 + +guidelines = 80, 120, 160 + +[*.{c,h}] +indent_style = tab +indent_size = 8 + +[*.{md,txt}] +indent_style = space +indent_size = 2 diff --git a/.gitignore b/.gitignore @@ -0,0 +1,8 @@ +bin/ + +ecc.key +ecc.crt + +imgui.ini + +**/.*.swp diff --git a/build.sh b/build.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +CC="${CC:-clang}" + +WARNINGS="-Wall -Wextra -Wpedantic ${WERROR:+-Werror} -Wno-unused-parameter -Wno-format-pedantic" +FLAGS="-std=c99 -Og -g" + +DEPS="$(pkg-config --cflags --libs liburing openssl)" + +set -ex + +mkdir -p bin + +$CC -o bin/sslclient sslclient.c $WARNINGS $FLAGS $DEPS +$CC -o bin/sslserver sslserver.c $WARNINGS $FLAGS $DEPS diff --git a/clean.sh b/clean.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +set -ex + +rm -rf bin diff --git a/gencert.sh b/gencert.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +set -ex + +openssl ecparam -genkey -name prime256v1 -noout -out ecc.key +openssl req -x509 -new -key ecc.key -days 9999 -out ecc.crt -subj "/CN=localhost" diff --git a/sslclient.c b/sslclient.c @@ -0,0 +1,14 @@ +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + +int +main(int argc, char **argv) +{ + if (argc < 3) { + fprintf(stderr, "Usage: %s <host> <port> <cert>\n", argv[0]); + exit(EXIT_FAILURE); + } + + exit(EXIT_SUCCESS); +} diff --git a/sslserver.c b/sslserver.c @@ -0,0 +1,14 @@ +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + +int +main(int argc, char **argv) +{ + if (argc < 3) { + fprintf(stderr, "Usage: %s <host> <port> <cert>\n", argv[0]); + exit(EXIT_FAILURE); + } + + exit(EXIT_SUCCESS); +}