-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from SgtCoDFish/certtweak
Overhaul implementation
- Loading branch information
Showing
12 changed files
with
696 additions
and
263 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
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 |
---|---|---|
@@ -0,0 +1,98 @@ | ||
#! /usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
certname=${1:-} | ||
fetchkey=${2:-} | ||
|
||
if [[ -z $certname || -z $fetchkey ]]; then | ||
echo "usage: $0 <certname> <fetchkey>" | ||
fi | ||
|
||
echo "Reading PEM from stdin..." >&2 | ||
cat >/tmp/crt-$certname | ||
|
||
# When printing to the Brother QL-820WNB, the width of the image (as opposed to | ||
# the height) is scaled to the 6.2 cm of the label tape's width. In the | ||
# following, e.g., 984 x 696 px, means height x width. So the "second" number is | ||
# the one scaled to 6.2 cm. | ||
# | ||
# For example, with a portrait-mode image of 696 x 232 px, the "top" if the | ||
# image is scaled to the width of the paper roll (6.2 cm). If the "top" is 696 | ||
# px, which the the nominal pixel width, then no scaling is neededd. | ||
# | ||
# 696 x 232 px | ||
# ^^^ ^^^ | ||
# width height | ||
# (6.2 cm) | ||
# | ||
# - - - - - - - - - - +--------------+ ^ | ||
# | RIGHT | | | ||
# | | | | ||
# PAPER UNROLLS THIS WAY | TOP | | width | ||
# --------------------> | | | 696 px | ||
# | (normal | | (6.2 cm) | ||
# | orienta.) | | | ||
# - - - - - - - - - - +--------------+ v | ||
# <--------------> | ||
# height 232 px (2.9 cm) | ||
# | ||
# | ||
# If I want the "right" of the image to scale to the 6.2 cm of the paper roll, | ||
# I need to --rotate 90. Since the "right" of the image is now scaled to the | ||
# width of the paper roll, I need to have an image with a in which case the size | ||
# is 696 x 984 px: | ||
# | ||
# 696 x 984 px (rotated 90 degrees) | ||
# ^^^ ^^^ | ||
# width height | ||
# (6.2 cm) | ||
# | ||
# - - - - - - - - - - +------------------------------+ ^ | ||
# | TOP | | | ||
# | | | | ||
# PAPER UNROLLS THIS WAY | | | width | ||
# --------------------> | RIGHT | | 696 px | ||
# | | | (6.2 cm) | ||
# | (rotated 90) | | | ||
# - - - - - - - - - - +------------------------------+ v | ||
# <------------------------------> | ||
# height 984 px (8.4 cm) | ||
# | ||
# | ||
# Format 1: 984 x 696 px (8.7 x 6.2 cm), requires --rotate 90 so that "696 px" | ||
# (the height) coincides with the the width of the paper roll. | ||
# | ||
# Format 2: 696 x 492 px (6.2 x 4.4 cm), requires no rotation. | ||
|
||
line1=$( | ||
cat <<EOF | ||
Thank you for visiting the cert-manager | ||
booth! We hope you are enjoying | ||
your time in Paris. | ||
EOF | ||
) | ||
|
||
line2=$( | ||
cat <<EOF | ||
This card is proof that you | ||
were there! On the back of | ||
the card, the QR code | ||
links to your certificate. | ||
EOF | ||
) | ||
|
||
# \( -gravity NorthEast logo.png -resize 160 -background white -alpha remove -alpha off -monochrome \) -geometry +40+20 -composite \ | ||
# \( -gravity East kubecon-eu-2022-logo.png -resize 280 -background white -alpha remove -alpha off -monochrome \) -geometry +80+10 \ | ||
convert -size 696x492 canvas:white \ | ||
\( -gravity NorthWest -font Open-Sans-Regular -pointsize 22 -fill black -annotate +0-0 "$line1" \) -geometry +0+0 \ | ||
\( -gravity NorthWest -font Open-Sans-Regular -pointsize 22 -fill black -annotate +0+115 "$line2" \) -geometry +0+0 \ | ||
\( -gravity SouthWest -font DejaVu-Sans-Mono -pointsize 22 -fill black -annotate +0+0 "$(step certificate inspect --short /tmp/crt-$certname | sed -e 's/\[\(.*\)\]/\n\1/' -e 's/Certificate (\(.*\))/Certificate\nAlgorithm: \1/' | sed 's/^ //')" \) -geometry +0+0 \ | ||
-background None -layers Flatten front-$certname.png | ||
|
||
# TODO: update this URL | ||
# url="http://print-your-cert.cert-manager.io/certificate?certName=$certname&fetchKey=$fetchkey" | ||
url="http://192.168.1.171:8080/certificate?certName=$certname&fetchKey=$fetchkey" | ||
echo "$url" >&2 | ||
echo "$url" | qrencode --type PNG --margin 4 -o - | convert -size 696x492 canvas:white \ | ||
\( -gravity Center -monochrome -filter point -interpolate nearest - -resize 492 \) -composite back-$certname.png |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<link rel="preconnect" href="https://fonts.googleapis.com" /> | ||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin /> | ||
<link | ||
href="https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;500;700&display=swap" | ||
rel="stylesheet" | ||
/> | ||
<link rel="stylesheet" href="static/styles.css" /> | ||
</head> | ||
|
||
<body> | ||
<div class="wrapper"> | ||
<br /> | ||
<img src="static/images/logo.svg" alt="Logo" width="220" height="191" /> | ||
<h1 class="mainTitle">Print Your Certificate</h1> | ||
|
||
<div class="divider"></div> | ||
|
||
<div class="error">{{.Error}}</div> | ||
|
||
<div class="divider"></div> | ||
|
||
<div> | ||
<a href="/"> | ||
<button type="submit" class="constrain">Go back to the creation page</button> | ||
</a> | ||
</div> | ||
</div> | ||
|
||
<footer> | ||
<p> | ||
Powered by <a href="https://cert-manager.io" target="_blank">cert-manager.io</a> | ||
</p> | ||
<p class="small"> | ||
Project proudly supported by | ||
<a href="https://venafi.com" target="_blank">Venafi</a> | ||
</p> | ||
<p class="small"> | ||
Design by <a href="https://constantinchirila.com" target="_blank">Constantin Chirila</a> | ||
</p> | ||
</footer> | ||
</body> | ||
</html> |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
module github.com/maelvls/print-your-cert | ||
module github.com/cert-manager/print-your-cert | ||
|
||
go 1.21 | ||
|
||
|
Oops, something went wrong.