Files
metacrypt/web/templates/pki.html

112 lines
3.7 KiB
HTML

{{define "title"}} - PKI: {{.MountName}}{{end}}
{{define "content"}}
<h2>PKI Engine: {{.MountName}}</h2>
<p><a href="/dashboard">&larr; Dashboard</a></p>
{{if .Error}}
<div class="error">{{.Error}}</div>
{{end}}
<h3>Root CA</h3>
{{if .HasRoot}}
<table>
<tr><th>Common Name</th><td>{{.RootCN}}</td></tr>
<tr><th>Organization</th><td>{{.RootOrg}}</td></tr>
<tr><th>Valid From</th><td>{{.RootNotBefore}}</td></tr>
<tr>
<th>Valid Until</th>
<td>
{{.RootNotAfter}}
{{if .RootExpired}} <span class="badge badge-danger">Expired</span>{{end}}
</td>
</tr>
</table>
<p style="margin-top: 0.5rem;">
<a href="/v1/pki/{{.MountName}}/ca" download="root-ca.pem">Download Root CA (PEM)</a>
</p>
{{else}}
<p>No root CA configured.</p>
{{end}}
{{if .IsAdmin}}
{{if or (not .HasRoot) .RootExpired}}
<h3>Import Root CA</h3>
<p>{{if .RootExpired}}The current root CA has expired. Import a new one.{{else}}No root CA is present. Import one to get started.{{end}}</p>
<form method="post" action="/pki/import-root" enctype="multipart/form-data">
<div class="form-group">
<label for="cert_file">Certificate PEM</label>
<input type="file" id="cert_file" name="cert_file" accept=".pem,.crt">
</div>
<div class="form-group">
<label for="cert_pem">Or paste certificate PEM</label>
<textarea id="cert_pem" name="cert_pem" rows="6" class="pem-input" placeholder="-----BEGIN CERTIFICATE-----"></textarea>
</div>
<div class="form-group">
<label for="key_file">Private Key PEM</label>
<input type="file" id="key_file" name="key_file" accept=".pem,.key">
</div>
<div class="form-group">
<label for="key_pem">Or paste private key PEM</label>
<textarea id="key_pem" name="key_pem" rows="6" class="pem-input" placeholder="-----BEGIN PRIVATE KEY-----"></textarea>
</div>
<button type="submit">Import Root CA</button>
</form>
{{end}}
{{end}}
<h3>Issuers</h3>
{{if .Issuers}}
<table>
<thead><tr><th>Name</th><th>Actions</th></tr></thead>
<tbody>
{{range .Issuers}}
<tr>
<td>{{.}}</td>
<td><a href="/pki/{{.}}" download="{{.}}.pem">Download Cert (PEM)</a></td>
</tr>
{{end}}
</tbody>
</table>
{{else}}
<p>No issuers configured.</p>
{{end}}
{{if .IsAdmin}}
{{if .HasRoot}}
<h3>Create Issuer</h3>
{{if .IssuerError}}<div class="error">{{.IssuerError}}</div>{{end}}
<form method="post" action="/pki/create-issuer">
<div class="form-row">
<div class="form-group">
<label for="issuer_name">Issuer Name</label>
<input type="text" id="issuer_name" name="name" placeholder="default" required>
</div>
<div class="form-group">
<label for="issuer_expiry">Expiry</label>
<input type="text" id="issuer_expiry" name="expiry" placeholder="26280h (3 years)">
</div>
</div>
<details>
<summary>Advanced options</summary>
<div class="form-row">
<div class="form-group">
<label for="issuer_key_alg">Key Algorithm</label>
<input type="text" id="issuer_key_alg" name="key_algorithm" placeholder="ecdsa (default)">
</div>
<div class="form-group">
<label for="issuer_key_size">Key Size</label>
<input type="text" id="issuer_key_size" name="key_size" placeholder="521 (default)">
</div>
</div>
<div class="form-group">
<label for="issuer_max_ttl">Max Leaf TTL</label>
<input type="text" id="issuer_max_ttl" name="max_ttl" placeholder="2160h (90 days)">
</div>
</details>
<button type="submit">Create Issuer</button>
</form>
{{end}}
{{end}}
{{end}}