Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flatten the generated zip archives and include individual certs #116

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion validation/certs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ VRESULTS_FILE=$(VDIR)/vresults.yml
# port counter
PORT_CTR_FILE=$(VDIR)/.port

# Chain splitting script
SPLIT_SCRIPT=$(UTILS_DIR)/split_chain.py

# All individual chain script directories
CHAINS_ALL=$(notdir $(wildcard $(CHAINS_DIR)/*))
# All individual chain build folders
Expand Down Expand Up @@ -92,7 +95,10 @@ $(VRESULTS_DIR)/%.yml: $(BUILD_DIR)/%/$(CHAIN_FILENAME)
$(ARCHIVE_DIR)/%.zip: $(BUILD_DIR)/%/$(CHAIN_FILENAME)
@mkdir -p $(ARCHIVE_DIR)
@printf "Creating a zip archive: %-50s" $(basename $(@F))
@cd $(BUILD_DIR) && zip --filesync --quiet ../$@ $(*F)/*.pem $(ROOT)/$(ROOT).pem
@mkdir -p ./tmp/
@python3 $(SPLIT_SCRIPT) $< ./tmp/
@cd $(BUILD_DIR) && zip -j --filesync --quiet ../$@ ../tmp/* ../$< $(*F)/crl*.pem $(ROOT)/$(ROOT).pem
@rm -rf ./tmp/
@printf "[ OK ]\n"

clean:
Expand Down
17 changes: 17 additions & 0 deletions validation/certs/utils/split_chain.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import sys

BEGIN_STR = '-----BEGIN CERTIFICATE-----'

with open(sys.argv[1], 'r') as f:
chain = f.read()

tmp = chain.split(BEGIN_STR)
tmp.pop(0)
certs = list(map(lambda x: BEGIN_STR + x, tmp))

with open(sys.argv[2] + 'endpoint.pem', 'w') as f:
f.write(certs[0])

for i, cert in enumerate(certs[1:]):
with open(sys.argv[2] + 'intermediate' + str(i + 1) + '.pem', 'w') as f:
f.write(cert)