Skip to content

Commit

Permalink
Fixed issue with gen certs
Browse files Browse the repository at this point in the history
  • Loading branch information
massenz committed Jul 21, 2024
1 parent 3d45eb3 commit 2b36364
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 39 deletions.
11 changes: 4 additions & 7 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install YQ
run: |
sudo wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/bin/yq &&\
sudo chmod +x /usr/bin/yq
- name: Generate Certs
run: |
export GOPATH=/opt/go
Expand All @@ -32,10 +36,3 @@ jobs:
mkdir -p ${HOME}/.aws && cp data/credentials ${HOME}/.aws/
export AWS_REGION=us-west-2
go test ./pkg/api ./pkg/grpc ./pkg/pubsub ./pkg/storage
# TODO: need to disable for now, as this fails when using SSL and I can't figure out why
# - name: Test CLI
# run: |
# mkdir -p ${HOME}/.fsm/certs
# cp certs/ca.pem ${HOME}/.fsm/certs/
# RELEASE=$(make version) BASEDIR=$(pwd) go test ./client
50 changes: 18 additions & 32 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ all_go := $(shell for d in $(pkgs); do find $$d -name "*.go"; done)
test_srcs := $(shell for d in $(pkgs); do find $$d -name "*_test.go"; done)
srcs := $(filter-out $(test_srcs),$(all_go))

# Certificates
certs_dir := ssl-config
ca-csr := $(certs_dir)/ca-csr.json
ca-config := $(certs_dir)/ca-config.json
server-csr := $(certs_dir)/localhost-csr.json

##@ General
.PHONY: clean
img=$(shell docker images -q --filter=reference=$(image))
Expand Down Expand Up @@ -118,35 +112,27 @@ check_certs:
echo "$(GREEN)[OK]$(RESET) Certificates found in $(shell pwd)/certs"; \
fi

config_dir := ssl-config
ca-csr := $(config_dir)/ca-csr.json
ca-config := $(config_dir)/ca-config.json
server-csr := $(config_dir)/localhost-csr.json

cfssl != which cfssl
cfssljson != which cfssljson
ifeq ($(strip $(cfssl)),)
$(error cfssl not installed)
endif
ifeq ($(strip $(cfssljson)),)
$(error cfssljson not installed)
endif
ssl_config := ../ssl-config
ca-csr := $(ssl_config)/ca-csr.json
ca-config := $(ssl_config)/ca-config.json
server-csr := $(ssl_config)/localhost-csr.json

.PHONY: certs
certs: $(ca-csr) $(config) $(server-csr) ## Generates all certificates in the certs directory (requires cfssl, see https://github.com/cloudflare/cfssl#installation)
$(cfssl) gencert \
-initca $(ca-csr) | cfssljson -bare ca
$(cfssl) gencert \
-ca=ca.pem \
-ca-key=ca-key.pem \
-config=$(ca-config) \
-profile=server \
$(server-csr) | $(cfssljson) -bare server
certs: ## Generates all certificates in the certs directory (requires cfssl, see https://github.com/cloudflare/cfssl#installation)
@mkdir -p certs
@mv *.pem certs/
@rm *.csr
@chmod a+r certs/*
@echo "Certificates generated in $(shell pwd)/certs"
@cd certs && \
cfssl gencert \
-initca $(ca-csr) 2>/dev/null | cfssljson -bare ca
@cd certs && \
cfssl gencert \
-ca=ca.pem \
-ca-key=ca-key.pem \
-config=$(ca-config) \
-profile=server \
$(server-csr) 2>/dev/null | cfssljson -bare server
@rm certs/*.csr
@chmod a+r certs/*.pem
@echo "$(GREEN)[SUCCESS]$(RESET) Certificates generated"

.PHONY: clean-cert
clean-cert:
Expand Down

0 comments on commit 2b36364

Please sign in to comment.