xaizek / rocketgit (License: AGPLv3+) (since 2018-12-09)
Light and fast Git hosting solution suitable to serve both as a hub or as a personal code storage with its tickets, pull requests, API and much more.
<root> / tests / ca.sh (af0a7be7ce66597a652ee981d16cb9889784fe2e) (1,135B) (mode 100755) [raw]
#!/bin/bash

ID=`date +%s`

set -e

# Generates a CA

if [ -z "${1}" ]; then
	echo "Usage: ca.sh name_of_the_ca"
	exit 1
fi

mkdir -p "ca/${1}"
cd "ca/${1}"

mkdir -p certs private csr

if [ ! -r private/cakey.pem ]; then
	echo "Creating CA key..."
	openssl genrsa -out private/cakey.pem 2048
fi

if [ ! -r certs/cacert.pem ]; then
	echo "Generating cert..."
	openssl req -new -x509 \
		-days 3650 \
		-extensions v3_ca \
		-key private/cakey.pem \
		-out certs/cacert.pem \
		-subj "/C=XX/ST=XXX/L=XXX/O=XXX-${ID}/CN=ca.example.com"
fi

for i in localhost client; do
	if [ ! -r private/${i}.key ]; then
		echo "Generating ${i} key..."
		openssl genrsa -out private/${i}.key 2048
	fi

	if [ ! -r csr/${i}.csr ]; then
		echo "Generating ${i} csr..."
		openssl req -new -key private/${i}.key -out csr/${i}.csr \
			-subj "/C=XX/ST=XXX/L=XXX/O=XXX-${ID}/CN=${i}"
	fi

	if [ ! -r certs/${i}.pem ]; then
		echo "Generating ${i} cert..."
		openssl x509 -req -in csr/${i}.csr \
			-CA certs/cacert.pem \
			-CAkey private/cakey.pem \
			-CAcreateserial \
			-days 500 \
			-out certs/${i}.pem
	fi
done

chmod -R 0600 private

echo "CA_SH_OK"
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/rocketgit

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/rocketgit

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master