Add config and makefile command to generate CA and client/server certs.

This commit is contained in:
Mariano Uvalle 2021-08-11 18:28:38 -05:00
parent 0d71b5abfb
commit d03afcfd50
5 changed files with 93 additions and 0 deletions

View file

@ -1,3 +1,31 @@
CONFIG_PATH=${HOME}/.proglog/
.PHONY: init
init:
mkdir -p ${CONFIG_PATH}
.PHONY: gencert
gencert:
cfssl gencert \
-initca certs/ca-csr.json | cfssljson -bare ca
cfssl gencert \
-ca=ca.pem \
-ca-key=ca-key.pem \
-config=certs/ca-config.json \
-profile=server \
certs/server-csr.json | cfssljson -bare server
cfssl gencert \
-ca=ca.pem \
-ca-key=ca-key.pem \
-config=certs/ca-config.json \
-profile=client \
certs/client-csr.json | cfssljson -bare client
mv *.pem *.csr ${CONFIG_PATH}
.PHONY: compile
compile:
protoc api/v1/*.proto \
--go_out=. \
@ -6,5 +34,6 @@ compile:
--go-grpc_opt=paths=source_relative \
--proto_path=.
.PHONY: test
test:
go test -race ./...

14
certs/ca-config.json Normal file
View file

@ -0,0 +1,14 @@
{
"signing": {
"profiles": {
"server": {
"expiry": "8760h",
"usages": ["signing", "key encipherment", "server auth"]
},
"client": {
"expiry": "8760h",
"usages": ["signing", "key encipherment", "client auth"]
}
}
}
}

16
certs/ca-csr.json Normal file
View file

@ -0,0 +1,16 @@
{
"CN": "Mariano's CA",
"key": {
"algo": "rsa",
"size": 2048
},
"names": [
{
"C": "MX",
"ST": "NL",
"L": "MTY",
"O": "AYM Consulting",
"OU": "CA Services"
}
]
}

17
certs/client-csr.json Normal file
View file

@ -0,0 +1,17 @@
{
"CN": "client",
"hosts": [""],
"key": {
"algo": "rsa",
"size": 2048
},
"names": [
{
"C": "MX",
"ST": "NL",
"L": "MTY",
"O": "AYM Consulting",
"OU": "Distributed Services"
}
]
}

17
certs/server-csr.json Normal file
View file

@ -0,0 +1,17 @@
{
"CN": "127.0.0.1",
"hosts": ["localhost", "127.0.0.1"],
"key": {
"algo": "rsa",
"size": 2048
},
"names": [
{
"C": "MX",
"ST": "NL",
"L": "MTY",
"O": "AYM Consulting",
"OU": "Distributed services"
}
]
}