#!/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"
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