-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
58 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,33 +11,56 @@ gateway: ## run gateway configured to access upstream powered with TLS | |
clean: | ||
$(DOCKER) compose down --volumes --remove-orphans | ||
$(DOCKER) compose -f docker-compose.yml down --volumes --remove-orphans | ||
$(MAKE) cleancerts -C $(WORKDIR)/gateway-cert -f $(WORKDIR)/Makefile | ||
$(MAKE) cleancerts -C $(WORKDIR)/upstream-cert -f $(WORKDIR)/Makefile | ||
- rm -rf gateway-cert | ||
- rm -rf upstream-cert | ||
- rm -rf bin | ||
|
||
cleancerts: | ||
- rm *.crt *.key *.pem *.csr | ||
|
||
ca: | ||
openssl genrsa -out rootCA.key 2048 | ||
ca: | ||
openssl genrsa -out rootCA.key 2048 | ||
openssl req -batch -new -x509 -nodes -key rootCA.key -sha256 -days 1024 -out rootCA.pem | ||
|
||
clientcerts: | ||
clientcerts: | ||
openssl req -subj '/CN=$(DOMAIN)' -newkey rsa:4096 -nodes \ | ||
-sha256 \ | ||
-days 3650 \ | ||
-keyout $(DOMAIN).key \ | ||
-out $(DOMAIN).csr | ||
-out $(DOMAIN).csr | ||
chmod +r $(DOMAIN).key | ||
openssl x509 -req -in $(DOMAIN).csr -CA rootCA.pem -CAkey rootCA.key -CAcreateserial -out $(DOMAIN).crt -days 500 -sha256 | ||
|
||
gateway-certs: | ||
$(WORKDIR)/gateway-cert: | ||
mkdir -p gateway-cert | ||
$(MAKE) cleancerts -C $(WORKDIR)/gateway-cert -f $(WORKDIR)/Makefile | ||
|
||
.PHONY: gateway-certs | ||
gateway-certs: $(WORKDIR)/gateway-cert | ||
$(MAKE) ca -C $(WORKDIR)/gateway-cert -f $(WORKDIR)/Makefile | ||
$(MAKE) clientcerts -C $(WORKDIR)/gateway-cert -f $(WORKDIR)/Makefile DOMAIN=gateway.example.com | ||
|
||
upstream-certs: | ||
$(WORKDIR)/upstream-cert: | ||
mkdir -p upstream-cert | ||
$(MAKE) cleancerts -C $(WORKDIR)/upstream-cert -f $(WORKDIR)/Makefile | ||
|
||
.PHONY: upstream-certs | ||
upstream-certs: $(WORKDIR)/upstream-cert | ||
$(MAKE) ca -C $(WORKDIR)/upstream-cert -f $(WORKDIR)/Makefile | ||
$(MAKE) clientcerts -C $(WORKDIR)/upstream-cert -f $(WORKDIR)/Makefile DOMAIN=upstream.example.com | ||
cat $(WORKDIR)/upstream-cert/upstream.example.com.key $(WORKDIR)/upstream-cert/upstream.example.com.crt >$(WORKDIR)/upstream-cert/upstream.example.com.pem | ||
|
||
GRPCURL=$(WORKDIR)/bin/grpcurl | ||
$(GRPCURL): | ||
$(call go-install-tool,$(GRPCURL),github.com/fullstorydev/grpcurl/cmd/[email protected]) | ||
|
||
.PHONY: grpcurl | ||
grpcurl: $(GRPCURL) ## Download grpcurl locally if necessary. | ||
|
||
# go-install-tool will 'go install' any package $2 and install it to $1. | ||
define go-install-tool | ||
@[ -f $(1) ] || { \ | ||
set -e ;\ | ||
TMP_DIR=$$(mktemp -d) ;\ | ||
cd $$TMP_DIR ;\ | ||
go mod init tmp ;\ | ||
echo "Downloading $(2)" ;\ | ||
GOBIN=$(WORKDIR)/bin go install $(2) ;\ | ||
rm -rf $$TMP_DIR ;\ | ||
} | ||
endef |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters