mobileconfig.go RawHistoryFolder

1package pki
2
3import (
4	"encoding/base64"
5	"fmt"
6	"html"
7	"strings"
8	"unicode"
9
10	"github.com/google/uuid"
11)
12
13// GenerateMobileconfig generates an iOS configuration profile containing
14// the root CA certificate for one-tap trust installation.
15func GenerateMobileconfig(rootDER []byte, rootCN string) []byte {
16	b64Cert := base64.StdEncoding.EncodeToString(rootDER)
17	profileUUID := uuid.New().String()
18	certUUID := uuid.New().String()
19
20	safeCN := html.EscapeString(rootCN)
21	identifierCN := payloadIdentifierComponent(rootCN)
22	profile := fmt.Sprintf(`<?xml version="1.0" encoding="UTF-8"?>
23<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
24<plist version="1.0">
25<dict>
26	<key>PayloadContent</key>
27	<array>
28		<dict>
29			<key>PayloadCertificateFileName</key>
30			<string>gordon-ca.crt</string>
31			<key>PayloadContent</key>
32			<data>%s</data>
33			<key>PayloadDescription</key>
34			<string>Installs the Gordon internal CA root certificate</string>
35			<key>PayloadDisplayName</key>
36			<string>%s</string>
37			<key>PayloadIdentifier</key>
38			<string>dev.gordon.ca.%s</string>
39			<key>PayloadType</key>
40			<string>com.apple.security.root</string>
41			<key>PayloadUUID</key>
42			<string>%s</string>
43			<key>PayloadVersion</key>
44			<integer>1</integer>
45		</dict>
46	</array>
47	<key>PayloadDescription</key>
48	<string>Trust Gordon's internal Certificate Authority for HTTPS access</string>
49	<key>PayloadDisplayName</key>
50	<string>Gordon CA Trust</string>
51	<key>PayloadIdentifier</key>
52	<string>dev.gordon.ca-profile</string>
53	<key>PayloadType</key>
54	<string>Configuration</string>
55	<key>PayloadUUID</key>
56	<string>%s</string>
57	<key>PayloadVersion</key>
58	<integer>1</integer>
59	</dict>
60</plist>`, b64Cert, safeCN, identifierCN, certUUID, profileUUID)
61
62	return []byte(profile)
63}
64
65func payloadIdentifierComponent(rootCN string) string {
66	var b strings.Builder
67	lastHyphen := false
68
69	for _, r := range rootCN {
70		r = unicode.ToLower(r)
71		switch {
72		case (r >= 'a' && r <= 'z') || (r >= '0' && r <= '9') || r == '.':
73			b.WriteRune(r)
74			lastHyphen = false
75		case r == '-':
76			if !lastHyphen {
77				b.WriteRune(r)
78				lastHyphen = true
79			}
80		default:
81			if !lastHyphen {
82				b.WriteRune('-')
83				lastHyphen = true
84			}
85		}
86	}
87
88	identifier := strings.Trim(b.String(), "-.")
89	if identifier == "" {
90		return "gordon-ca"
91	}
92
93	return identifier
94}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 7

Tags 106

↑↓ moveenter openesc close