Full codebase including API server (32 modules + routes), dashboard frontend, DashCA certificate distribution, installer script, and deployment skills.
1285 lines
45 KiB
HTML
1285 lines
45 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>DashCA - Certificate Authority</title>
|
|
<link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>🔐</text></svg>">
|
|
|
|
<!-- QR Code Library -->
|
|
<script src="https://cdn.jsdelivr.net/npm/qrcodejs@1.0.0/qrcode.min.js"></script>
|
|
|
|
<style>
|
|
/* DashCaddy Theme Variables */
|
|
:root {
|
|
--accent: #8FD6FF;
|
|
--accent-strong: #1F7BFF;
|
|
--bg: #0b0f1a;
|
|
--fg: #e8ecf5;
|
|
--muted: #9aa6bf;
|
|
--card-base: #121826;
|
|
--border: #263552;
|
|
--radius: 12px;
|
|
--success: #4ade80;
|
|
--warning: #fbbf24;
|
|
--error: #f87171;
|
|
}
|
|
|
|
/* Font Loading */
|
|
@font-face {
|
|
font-family: 'Sami Grotesk';
|
|
src: url('/assets/fonts/SamiGrotesk-Regular.woff2') format('woff2'),
|
|
url('/assets/fonts/SamiGrotesk-Regular.woff') format('woff');
|
|
font-weight: 400;
|
|
font-style: normal;
|
|
font-display: swap;
|
|
}
|
|
|
|
@font-face {
|
|
font-family: 'Sami Grotesk';
|
|
src: url('/assets/fonts/SamiGrotesk-Medium.woff2') format('woff2'),
|
|
url('/assets/fonts/SamiGrotesk-Medium.woff') format('woff');
|
|
font-weight: 500;
|
|
font-style: normal;
|
|
font-display: swap;
|
|
}
|
|
|
|
@font-face {
|
|
font-family: 'Sami Grotesk';
|
|
src: url('/assets/fonts/SamiGrotesk-Bold.woff2') format('woff2'),
|
|
url('/assets/fonts/SamiGrotesk-Bold.woff') format('woff');
|
|
font-weight: 700;
|
|
font-style: normal;
|
|
font-display: swap;
|
|
}
|
|
|
|
/* Reset & Base Styles */
|
|
* {
|
|
margin: 0;
|
|
padding: 0;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
body {
|
|
font-family: 'Sami Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
|
|
background: var(--bg);
|
|
color: var(--fg);
|
|
line-height: 1.6;
|
|
min-height: 100vh;
|
|
padding: 2rem 1rem;
|
|
font-size: 16px;
|
|
}
|
|
|
|
.container {
|
|
max-width: 900px;
|
|
margin: 0 auto;
|
|
}
|
|
|
|
/* Header */
|
|
.header {
|
|
text-align: center;
|
|
margin-bottom: 3rem;
|
|
}
|
|
|
|
.logo {
|
|
font-size: 4rem;
|
|
margin-bottom: 1rem;
|
|
line-height: 1;
|
|
}
|
|
|
|
h1 {
|
|
font-size: 2.5rem;
|
|
font-weight: 700;
|
|
margin-bottom: 0.5rem;
|
|
color: var(--accent);
|
|
}
|
|
|
|
.subtitle {
|
|
font-size: 1.125rem;
|
|
color: var(--muted);
|
|
font-weight: 400;
|
|
}
|
|
|
|
/* Card Styles */
|
|
.card {
|
|
background: var(--card-base);
|
|
border: 1px solid var(--border);
|
|
border-radius: var(--radius);
|
|
padding: 2rem;
|
|
margin-bottom: 2rem;
|
|
}
|
|
|
|
.card-title {
|
|
font-size: 1.5rem;
|
|
font-weight: 600;
|
|
margin-bottom: 1.5rem;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 0.75rem;
|
|
}
|
|
|
|
.card-icon {
|
|
font-size: 1.75rem;
|
|
}
|
|
|
|
/* Certificate Info Grid */
|
|
.cert-info {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
|
|
gap: 1.5rem;
|
|
}
|
|
|
|
.cert-field {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 0.5rem;
|
|
}
|
|
|
|
.cert-label {
|
|
font-size: 0.875rem;
|
|
color: var(--muted);
|
|
font-weight: 500;
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.5px;
|
|
}
|
|
|
|
.cert-value {
|
|
font-size: 1rem;
|
|
color: var(--fg);
|
|
font-weight: 500;
|
|
word-break: break-all;
|
|
}
|
|
|
|
.cert-value.fingerprint {
|
|
font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
|
|
font-size: 0.875rem;
|
|
line-height: 1.8;
|
|
}
|
|
|
|
.cert-value-with-copy {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 0.5rem;
|
|
flex-wrap: wrap;
|
|
}
|
|
|
|
/* Copy Button */
|
|
.copy-btn {
|
|
background: transparent;
|
|
border: 1px solid var(--border);
|
|
border-radius: 6px;
|
|
color: var(--muted);
|
|
cursor: pointer;
|
|
padding: 0.25rem 0.5rem;
|
|
font-size: 0.75rem;
|
|
transition: all 0.2s;
|
|
display: inline-flex;
|
|
align-items: center;
|
|
gap: 0.25rem;
|
|
}
|
|
|
|
.copy-btn:hover {
|
|
border-color: var(--accent);
|
|
color: var(--accent);
|
|
}
|
|
|
|
.copy-btn.copied {
|
|
border-color: var(--success);
|
|
color: var(--success);
|
|
}
|
|
|
|
/* Primary Action Button */
|
|
.primary-btn {
|
|
background: var(--accent-strong);
|
|
color: white;
|
|
border: none;
|
|
border-radius: var(--radius);
|
|
padding: 1.25rem 2.5rem;
|
|
font-size: 1.125rem;
|
|
font-weight: 600;
|
|
cursor: pointer;
|
|
transition: all 0.2s;
|
|
width: 100%;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
gap: 0.75rem;
|
|
font-family: inherit;
|
|
}
|
|
|
|
.primary-btn:hover {
|
|
background: var(--accent);
|
|
transform: translateY(-1px);
|
|
box-shadow: 0 8px 16px rgba(31, 123, 255, 0.3);
|
|
}
|
|
|
|
.primary-btn:active {
|
|
transform: translateY(0);
|
|
}
|
|
|
|
.btn-icon {
|
|
font-size: 1.5rem;
|
|
}
|
|
|
|
/* Detected Platform Badge */
|
|
.detected-platform {
|
|
background: var(--card-base);
|
|
border: 1px solid var(--accent);
|
|
border-radius: 8px;
|
|
padding: 0.75rem 1.25rem;
|
|
text-align: center;
|
|
margin-top: 1rem;
|
|
color: var(--accent);
|
|
font-size: 0.875rem;
|
|
}
|
|
|
|
/* Downloads Grid */
|
|
.downloads-grid {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
|
gap: 1rem;
|
|
}
|
|
|
|
.download-link {
|
|
background: var(--card-base);
|
|
border: 1px solid var(--border);
|
|
border-radius: 10px;
|
|
padding: 1rem;
|
|
text-decoration: none;
|
|
color: var(--fg);
|
|
transition: all 0.2s;
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
text-align: center;
|
|
gap: 0.5rem;
|
|
}
|
|
|
|
.download-link:hover {
|
|
border-color: var(--accent);
|
|
background: rgba(143, 214, 255, 0.05);
|
|
transform: translateY(-2px);
|
|
}
|
|
|
|
.download-icon {
|
|
font-size: 2rem;
|
|
}
|
|
|
|
.download-name {
|
|
font-weight: 500;
|
|
}
|
|
|
|
.download-desc {
|
|
font-size: 0.75rem;
|
|
color: var(--muted);
|
|
}
|
|
|
|
/* QR Code Container */
|
|
.qr-container {
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
gap: 1rem;
|
|
padding: 2rem;
|
|
background: white;
|
|
border-radius: var(--radius);
|
|
margin: 2rem 0;
|
|
}
|
|
|
|
.qr-container h3 {
|
|
color: #0b0f1a;
|
|
font-size: 1.25rem;
|
|
}
|
|
|
|
#qrcode {
|
|
padding: 1rem;
|
|
background: white;
|
|
border-radius: 8px;
|
|
}
|
|
|
|
.qr-hint {
|
|
color: #666;
|
|
font-size: 0.875rem;
|
|
text-align: center;
|
|
}
|
|
|
|
/* Service Certificates Section */
|
|
.service-certs {
|
|
background: var(--card-base);
|
|
border-radius: var(--radius);
|
|
padding: 2rem;
|
|
margin: 2rem 0;
|
|
}
|
|
|
|
.service-certs h3 {
|
|
margin: 0 0 1.5rem 0;
|
|
color: var(--accent);
|
|
font-size: 1.5rem;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 0.5rem;
|
|
}
|
|
|
|
.cert-grid {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
|
|
gap: 1rem;
|
|
}
|
|
|
|
.cert-card {
|
|
background: rgba(143, 214, 255, 0.05);
|
|
border: 1px solid var(--border);
|
|
border-radius: 10px;
|
|
padding: 1.25rem;
|
|
transition: all 0.2s;
|
|
}
|
|
|
|
.cert-card:hover {
|
|
border-color: var(--accent);
|
|
transform: translateY(-2px);
|
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
|
}
|
|
|
|
.cert-header {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
margin-bottom: 1rem;
|
|
}
|
|
|
|
.cert-domain {
|
|
font-size: 1.1rem;
|
|
font-weight: 600;
|
|
color: var(--fg);
|
|
}
|
|
|
|
.cert-status {
|
|
padding: 0.25rem 0.75rem;
|
|
border-radius: 20px;
|
|
font-size: 0.75rem;
|
|
font-weight: 500;
|
|
text-transform: uppercase;
|
|
}
|
|
|
|
.cert-status.valid {
|
|
background: rgba(34, 197, 94, 0.2);
|
|
color: #22c55e;
|
|
}
|
|
|
|
.cert-status.expiring-soon {
|
|
background: rgba(251, 191, 36, 0.2);
|
|
color: #fbbf24;
|
|
}
|
|
|
|
.cert-status.expired {
|
|
background: rgba(239, 68, 68, 0.2);
|
|
color: #ef4444;
|
|
}
|
|
|
|
.cert-status.loading {
|
|
background: rgba(143, 214, 255, 0.2);
|
|
color: var(--accent);
|
|
}
|
|
|
|
.cert-info {
|
|
font-size: 0.875rem;
|
|
color: var(--muted);
|
|
margin-bottom: 0.5rem;
|
|
}
|
|
|
|
.cert-info strong {
|
|
color: var(--fg);
|
|
}
|
|
|
|
.cert-actions {
|
|
display: flex;
|
|
gap: 0.5rem;
|
|
margin-top: 1rem;
|
|
}
|
|
|
|
.cert-btn {
|
|
flex: 1;
|
|
padding: 0.5rem;
|
|
border: 1px solid var(--border);
|
|
border-radius: 6px;
|
|
background: var(--bg);
|
|
color: var(--fg);
|
|
cursor: pointer;
|
|
transition: all 0.2s;
|
|
text-decoration: none;
|
|
text-align: center;
|
|
font-size: 0.875rem;
|
|
}
|
|
|
|
.cert-btn:hover {
|
|
border-color: var(--accent);
|
|
background: rgba(143, 214, 255, 0.1);
|
|
}
|
|
|
|
.cert-btn-primary {
|
|
background: var(--accent);
|
|
color: var(--bg);
|
|
border-color: var(--accent);
|
|
}
|
|
|
|
.cert-btn-primary:hover {
|
|
background: #5eb9e8;
|
|
border-color: #5eb9e8;
|
|
}
|
|
|
|
.cert-empty {
|
|
text-align: center;
|
|
padding: 2rem;
|
|
color: var(--muted);
|
|
}
|
|
|
|
/* Instructions Tabs */
|
|
.tabs {
|
|
display: flex;
|
|
gap: 0.5rem;
|
|
margin-bottom: 1.5rem;
|
|
flex-wrap: wrap;
|
|
}
|
|
|
|
.tab-btn {
|
|
background: transparent;
|
|
border: 1px solid var(--border);
|
|
border-radius: 8px;
|
|
color: var(--muted);
|
|
padding: 0.75rem 1.25rem;
|
|
font-size: 0.875rem;
|
|
font-weight: 500;
|
|
cursor: pointer;
|
|
transition: all 0.2s;
|
|
font-family: inherit;
|
|
}
|
|
|
|
.tab-btn:hover {
|
|
border-color: var(--accent);
|
|
color: var(--accent);
|
|
}
|
|
|
|
.tab-btn.active {
|
|
background: var(--accent-strong);
|
|
border-color: var(--accent-strong);
|
|
color: white;
|
|
}
|
|
|
|
.tab-content {
|
|
display: none;
|
|
}
|
|
|
|
.tab-content.active {
|
|
display: block;
|
|
}
|
|
|
|
.instruction-step {
|
|
display: flex;
|
|
gap: 1rem;
|
|
margin-bottom: 1.5rem;
|
|
padding-bottom: 1.5rem;
|
|
border-bottom: 1px solid var(--border);
|
|
}
|
|
|
|
.instruction-step:last-child {
|
|
border-bottom: none;
|
|
margin-bottom: 0;
|
|
padding-bottom: 0;
|
|
}
|
|
|
|
.step-number {
|
|
background: var(--accent-strong);
|
|
color: white;
|
|
border-radius: 50%;
|
|
width: 2rem;
|
|
height: 2rem;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
font-weight: 700;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.step-content h4 {
|
|
font-size: 1rem;
|
|
font-weight: 600;
|
|
margin-bottom: 0.5rem;
|
|
}
|
|
|
|
.step-content p {
|
|
color: var(--muted);
|
|
font-size: 0.875rem;
|
|
line-height: 1.6;
|
|
}
|
|
|
|
.code-block {
|
|
background: var(--bg);
|
|
border: 1px solid var(--border);
|
|
border-radius: 8px;
|
|
padding: 1rem;
|
|
margin-top: 0.75rem;
|
|
font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
|
|
font-size: 0.875rem;
|
|
color: var(--accent);
|
|
overflow-x: auto;
|
|
position: relative;
|
|
}
|
|
|
|
.code-copy-btn {
|
|
position: absolute;
|
|
top: 0.5rem;
|
|
right: 0.5rem;
|
|
background: var(--card-base);
|
|
border: 1px solid var(--border);
|
|
border-radius: 6px;
|
|
color: var(--muted);
|
|
padding: 0.25rem 0.5rem;
|
|
font-size: 0.75rem;
|
|
cursor: pointer;
|
|
transition: all 0.2s;
|
|
}
|
|
|
|
.code-copy-btn:hover {
|
|
border-color: var(--accent);
|
|
color: var(--accent);
|
|
}
|
|
|
|
/* Status Badges */
|
|
.status-badge {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
gap: 0.5rem;
|
|
padding: 0.5rem 1rem;
|
|
border-radius: 8px;
|
|
font-size: 0.875rem;
|
|
font-weight: 500;
|
|
}
|
|
|
|
.status-badge.success {
|
|
background: rgba(74, 222, 128, 0.1);
|
|
color: var(--success);
|
|
}
|
|
|
|
.status-badge.warning {
|
|
background: rgba(251, 191, 36, 0.1);
|
|
color: var(--warning);
|
|
}
|
|
|
|
/* Responsive */
|
|
@media (max-width: 768px) {
|
|
h1 {
|
|
font-size: 2rem;
|
|
}
|
|
|
|
.logo {
|
|
font-size: 3rem;
|
|
}
|
|
|
|
.card {
|
|
padding: 1.5rem;
|
|
}
|
|
|
|
.primary-btn {
|
|
padding: 1rem 2rem;
|
|
font-size: 1rem;
|
|
}
|
|
|
|
.cert-info {
|
|
grid-template-columns: 1fr;
|
|
}
|
|
|
|
.downloads-grid {
|
|
grid-template-columns: 1fr;
|
|
}
|
|
}
|
|
|
|
/* Loading State */
|
|
.loading {
|
|
display: inline-block;
|
|
width: 1rem;
|
|
height: 1rem;
|
|
border: 2px solid var(--border);
|
|
border-radius: 50%;
|
|
border-top-color: var(--accent);
|
|
animation: spin 0.6s linear infinite;
|
|
}
|
|
|
|
@keyframes spin {
|
|
to { transform: rotate(360deg); }
|
|
}
|
|
|
|
/* Footer */
|
|
.footer {
|
|
text-align: center;
|
|
margin-top: 4rem;
|
|
padding-top: 2rem;
|
|
border-top: 1px solid var(--border);
|
|
color: var(--muted);
|
|
font-size: 0.875rem;
|
|
}
|
|
|
|
.footer a {
|
|
color: var(--accent);
|
|
text-decoration: none;
|
|
}
|
|
|
|
.footer a:hover {
|
|
text-decoration: underline;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<!-- Header -->
|
|
<div class="header">
|
|
<div class="logo">🔐</div>
|
|
<h1>DashCA</h1>
|
|
<p class="subtitle">Certificate Authority Distribution</p>
|
|
</div>
|
|
|
|
<!-- Certificate Information Card -->
|
|
<div class="card">
|
|
<h2 class="card-title">
|
|
<span class="card-icon">📜</span>
|
|
Certificate Information
|
|
</h2>
|
|
<div class="cert-info" id="certInfo">
|
|
<div class="cert-field">
|
|
<div class="cert-label">Certificate Name</div>
|
|
<div class="cert-value" id="certName">
|
|
<span class="loading"></span> Loading...
|
|
</div>
|
|
</div>
|
|
<div class="cert-field">
|
|
<div class="cert-label">Algorithm</div>
|
|
<div class="cert-value" id="certAlgorithm">
|
|
<span class="loading"></span> Loading...
|
|
</div>
|
|
</div>
|
|
<div class="cert-field">
|
|
<div class="cert-label">Valid Until</div>
|
|
<div class="cert-value" id="certValidUntil">
|
|
<span class="loading"></span> Loading...
|
|
</div>
|
|
</div>
|
|
<div class="cert-field">
|
|
<div class="cert-label">Days Remaining</div>
|
|
<div class="cert-value" id="certDaysRemaining">
|
|
<span class="loading"></span> Loading...
|
|
</div>
|
|
</div>
|
|
<div class="cert-field" style="grid-column: 1 / -1;">
|
|
<div class="cert-label">SHA-256 Fingerprint</div>
|
|
<div class="cert-value fingerprint cert-value-with-copy">
|
|
<span id="certFingerprint"><span class="loading"></span> Loading...</span>
|
|
<button class="copy-btn" onclick="copyFingerprint()" id="fpCopyBtn">
|
|
📋 Copy
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Primary Installation Button -->
|
|
<div class="card">
|
|
<button class="primary-btn" id="primaryInstallBtn" onclick="primaryInstallAction()">
|
|
<span class="btn-icon">⬇️</span>
|
|
<span id="btnText">Install Certificate</span>
|
|
</button>
|
|
<div class="detected-platform" id="detectedPlatform">
|
|
Detecting your operating system...
|
|
</div>
|
|
<div id="httpTip" style="display: none; margin-top: 0.75rem; padding: 0.75rem 1.25rem; background: rgba(251, 191, 36, 0.1); border: 1px solid rgba(251, 191, 36, 0.3); border-radius: 8px; font-size: 0.875rem; color: var(--warning);">
|
|
New device? Visit <a id="httpLink" href="#" style="color: var(--accent); font-weight: 500;"></a> to run install commands without certificate warnings.
|
|
</div>
|
|
</div>
|
|
|
|
<!-- QR Code for Mobile Access -->
|
|
<div class="qr-container">
|
|
<h3>📱 Quick Access for Mobile</h3>
|
|
<div id="qrcode"></div>
|
|
<p class="qr-hint">Scan with your phone's camera to visit this page</p>
|
|
</div>
|
|
|
|
<!-- Service Certificates -->
|
|
<div class="service-certs">
|
|
<h3>
|
|
<span>🔐</span>
|
|
Service Certificates
|
|
</h3>
|
|
<p style="color: var(--muted); margin-bottom: 1.5rem;">
|
|
SSL certificates generated for services on your network
|
|
</p>
|
|
<div id="certGrid" class="cert-grid">
|
|
<!-- Loading state -->
|
|
<div class="cert-card">
|
|
<div class="cert-header">
|
|
<span class="cert-domain">Loading...</span>
|
|
<span class="cert-status loading">Checking</span>
|
|
</div>
|
|
<div class="cert-info">Fetching certificate status...</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Alternative Downloads -->
|
|
<div class="card">
|
|
<h2 class="card-title">
|
|
<span class="card-icon">📦</span>
|
|
Alternative Downloads
|
|
</h2>
|
|
<div class="downloads-grid">
|
|
<a href="/root.crt" class="download-link" download>
|
|
<div class="download-icon">📄</div>
|
|
<div class="download-name">Root Certificate (.crt)</div>
|
|
<div class="download-desc">PEM format, universal</div>
|
|
</a>
|
|
<a href="/root.der" class="download-link" download>
|
|
<div class="download-icon">📄</div>
|
|
<div class="download-name">Root Certificate (.der)</div>
|
|
<div class="download-desc">Binary format, Windows</div>
|
|
</a>
|
|
<a href="/root.mobileconfig" class="download-link" download>
|
|
<div class="download-icon">📱</div>
|
|
<div class="download-name">Apple Profile</div>
|
|
<div class="download-desc">iOS & macOS</div>
|
|
</a>
|
|
<a href="/api/ca/install-script?platform=windows" class="download-link" download="install-dashcaddy-ca.ps1">
|
|
<div class="download-icon">💻</div>
|
|
<div class="download-name">Windows Installer</div>
|
|
<div class="download-desc">PowerShell script</div>
|
|
</a>
|
|
<a href="/api/ca/install-script?platform=linux" class="download-link" download="install-dashcaddy-ca.sh">
|
|
<div class="download-icon">🐧</div>
|
|
<div class="download-name">Linux/Mac Installer</div>
|
|
<div class="download-desc">Shell script</div>
|
|
</a>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Platform-Specific Instructions -->
|
|
<div class="card">
|
|
<h2 class="card-title">
|
|
<span class="card-icon">📖</span>
|
|
Installation Instructions
|
|
</h2>
|
|
|
|
<div class="tabs">
|
|
<button class="tab-btn active" onclick="showTab('windows')">Windows</button>
|
|
<button class="tab-btn" onclick="showTab('macos')">macOS</button>
|
|
<button class="tab-btn" onclick="showTab('linux')">Linux</button>
|
|
<button class="tab-btn" onclick="showTab('ios')">iOS</button>
|
|
<button class="tab-btn" onclick="showTab('android')">Android</button>
|
|
</div>
|
|
|
|
<!-- Windows Instructions -->
|
|
<div class="tab-content active" id="tab-windows">
|
|
<div class="instruction-step">
|
|
<div class="step-number">1</div>
|
|
<div class="step-content">
|
|
<h4>Run PowerShell as Administrator</h4>
|
|
<p>Right-click the Start button and select "Windows PowerShell (Admin)" or "Terminal (Admin)"</p>
|
|
</div>
|
|
</div>
|
|
<div class="instruction-step">
|
|
<div class="step-number">2</div>
|
|
<div class="step-content">
|
|
<h4>Run the installation command</h4>
|
|
<p>Copy and paste this command into PowerShell:</p>
|
|
<div class="code-block" id="windows-install-cmd">
|
|
<button class="code-copy-btn" id="windows-install-copy">Copy</button>
|
|
<code id="windows-install-text"></code>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="instruction-step">
|
|
<div class="step-number">3</div>
|
|
<div class="step-content">
|
|
<h4>Verify installation</h4>
|
|
<p>Visit any *.sami domain (like https://status.sami) - you should see a secure connection with no warnings.</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- macOS Instructions -->
|
|
<div class="tab-content" id="tab-macos">
|
|
<div class="instruction-step">
|
|
<div class="step-number">1</div>
|
|
<div class="step-content">
|
|
<h4>Download the certificate profile</h4>
|
|
<p>Click "Apple Profile" above to download root.mobileconfig</p>
|
|
</div>
|
|
</div>
|
|
<div class="instruction-step">
|
|
<div class="step-number">2</div>
|
|
<div class="step-content">
|
|
<h4>Install the profile</h4>
|
|
<p>Open System Settings → Privacy & Security → Profiles. Click the downloaded profile and click "Install".</p>
|
|
</div>
|
|
</div>
|
|
<div class="instruction-step">
|
|
<div class="step-number">3</div>
|
|
<div class="step-content">
|
|
<h4>Alternative: Command line installation</h4>
|
|
<p>Open Terminal and run:</p>
|
|
<div class="code-block" id="macos-install-cmd">
|
|
<button class="code-copy-btn" id="macos-install-copy">Copy</button>
|
|
<code id="macos-install-text"></code>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Linux Instructions -->
|
|
<div class="tab-content" id="tab-linux">
|
|
<div class="instruction-step">
|
|
<div class="step-number">1</div>
|
|
<div class="step-content">
|
|
<h4>Open Terminal</h4>
|
|
<p>Open your terminal application (usually Ctrl+Alt+T)</p>
|
|
</div>
|
|
</div>
|
|
<div class="instruction-step">
|
|
<div class="step-number">2</div>
|
|
<div class="step-content">
|
|
<h4>Run the installation command</h4>
|
|
<p>Copy and paste this command (will prompt for sudo password):</p>
|
|
<div class="code-block" id="linux-install-cmd">
|
|
<button class="code-copy-btn" id="linux-install-copy">Copy</button>
|
|
<code id="linux-install-text"></code>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="instruction-step">
|
|
<div class="step-number">3</div>
|
|
<div class="step-content">
|
|
<h4>Supported distributions</h4>
|
|
<p>The installer supports Debian/Ubuntu, RedHat/CentOS/Fedora, and Arch Linux. It will automatically detect your distribution and use the appropriate commands.</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- iOS Instructions -->
|
|
<div class="tab-content" id="tab-ios">
|
|
<div class="instruction-step">
|
|
<div class="step-number">1</div>
|
|
<div class="step-content">
|
|
<h4>Scan QR code or visit this page</h4>
|
|
<p>Use your iPhone's camera to scan the QR code above, or visit https://ca.sami directly in Safari</p>
|
|
</div>
|
|
</div>
|
|
<div class="instruction-step">
|
|
<div class="step-number">2</div>
|
|
<div class="step-content">
|
|
<h4>Download the profile</h4>
|
|
<p>Tap "Apple Profile" to download root.mobileconfig. You'll see a notification that the profile was downloaded.</p>
|
|
</div>
|
|
</div>
|
|
<div class="instruction-step">
|
|
<div class="step-number">3</div>
|
|
<div class="step-content">
|
|
<h4>Install the profile</h4>
|
|
<p>Go to Settings (you should see a notification), tap on the downloaded profile, and tap "Install". Enter your passcode if prompted.</p>
|
|
</div>
|
|
</div>
|
|
<div class="instruction-step">
|
|
<div class="step-number">4</div>
|
|
<div class="step-content">
|
|
<h4>Trust the certificate</h4>
|
|
<p>Go to Settings → General → About → Certificate Trust Settings. Enable full trust for "Sami Home Network Root CA".</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Android Instructions -->
|
|
<div class="tab-content" id="tab-android">
|
|
<div class="instruction-step">
|
|
<div class="step-number">1</div>
|
|
<div class="step-content">
|
|
<h4>Download the certificate</h4>
|
|
<p>Tap "Root Certificate (.crt)" above to download the certificate to your device</p>
|
|
</div>
|
|
</div>
|
|
<div class="instruction-step">
|
|
<div class="step-number">2</div>
|
|
<div class="step-content">
|
|
<h4>Install the certificate</h4>
|
|
<p>Open Settings → Security → Encryption & credentials → Install a certificate → CA certificate. Select the downloaded file.</p>
|
|
</div>
|
|
</div>
|
|
<div class="instruction-step">
|
|
<div class="step-number">3</div>
|
|
<div class="step-content">
|
|
<h4>Note about user certificates</h4>
|
|
<p>Android installs this as a "user" certificate. Some apps may not trust user certificates for security reasons. For full trust, you would need to install it as a system certificate (requires root access).</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Footer -->
|
|
<div class="footer">
|
|
<p>Part of the <strong>DashCaddy</strong> project</p>
|
|
<p>Unified management for Docker + Caddy + DNS</p>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
// State
|
|
let detectedOS = 'unknown';
|
|
let certInfo = null;
|
|
|
|
// Detect OS
|
|
function detectOS() {
|
|
const userAgent = navigator.userAgent.toLowerCase();
|
|
const platform = navigator.platform.toLowerCase();
|
|
|
|
if (platform.includes('win') || userAgent.includes('windows')) {
|
|
return 'windows';
|
|
} else if (platform.includes('mac') || userAgent.includes('macintosh') || userAgent.includes('mac os')) {
|
|
// Distinguish between macOS and iOS
|
|
if (userAgent.includes('iphone') || userAgent.includes('ipad') || userAgent.includes('ipod')) {
|
|
return 'ios';
|
|
}
|
|
return 'macos';
|
|
} else if (userAgent.includes('android')) {
|
|
return 'android';
|
|
} else if (platform.includes('linux') || userAgent.includes('linux')) {
|
|
return 'linux';
|
|
}
|
|
|
|
return 'unknown';
|
|
}
|
|
|
|
// Load certificate information
|
|
async function loadCertInfo() {
|
|
try {
|
|
// Add cache-busting parameter
|
|
const response = await fetch('/api/ca/info?t=' + Date.now());
|
|
if (!response.ok) {
|
|
console.error('API response not OK:', response.status, response.statusText);
|
|
throw new Error('Failed to fetch certificate info');
|
|
}
|
|
|
|
const data = await response.json();
|
|
console.log('Certificate data loaded:', data);
|
|
|
|
if (data.success && data.certificate) {
|
|
certInfo = data.certificate;
|
|
displayCertInfo(certInfo);
|
|
} else {
|
|
throw new Error(data.error || 'Invalid response');
|
|
}
|
|
} catch (error) {
|
|
console.error('Error loading certificate info:', error);
|
|
// Fallback to static info
|
|
displayCertInfo({
|
|
name: 'Sami Home Network Root CA',
|
|
algorithm: 'ECDSA P-256 with SHA-256',
|
|
validUntil: 'Dec 22, 2034',
|
|
daysUntilExpiration: 3235,
|
|
fingerprint: '08:98:A5:63:F5:A1:A2:58:5F:02:D7:A8:A2:54:87:E6:BC:33:96:9F:9B:5D:B0:53:62:20:7F:AF:96:21:29:0E'
|
|
});
|
|
}
|
|
}
|
|
|
|
// Display certificate information
|
|
function displayCertInfo(info) {
|
|
document.getElementById('certName').textContent = info.name;
|
|
document.getElementById('certAlgorithm').textContent = info.algorithm;
|
|
document.getElementById('certValidUntil').textContent = info.validUntil || new Date(info.validUntil).toLocaleDateString();
|
|
|
|
const daysRemaining = info.daysUntilExpiration;
|
|
const daysEl = document.getElementById('certDaysRemaining');
|
|
if (daysRemaining < 90) {
|
|
daysEl.innerHTML = `<span class="status-badge warning">${daysRemaining} days</span>`;
|
|
} else {
|
|
daysEl.innerHTML = `<span class="status-badge success">${daysRemaining} days</span>`;
|
|
}
|
|
|
|
document.getElementById('certFingerprint').textContent = info.fingerprint;
|
|
}
|
|
|
|
// Copy fingerprint to clipboard
|
|
function copyFingerprint() {
|
|
const fp = document.getElementById('certFingerprint').textContent;
|
|
copyToClipboard(fp, document.getElementById('fpCopyBtn'));
|
|
}
|
|
|
|
// Generic copy to clipboard
|
|
function copyToClipboard(text, button) {
|
|
navigator.clipboard.writeText(text).then(() => {
|
|
const originalText = button.textContent;
|
|
button.textContent = '✓ Copied!';
|
|
button.classList.add('copied');
|
|
setTimeout(() => {
|
|
button.textContent = originalText;
|
|
button.classList.remove('copied');
|
|
}, 2000);
|
|
}).catch(err => {
|
|
console.error('Failed to copy:', err);
|
|
alert('Failed to copy to clipboard');
|
|
});
|
|
}
|
|
|
|
// Copy code block
|
|
function copyCode(button, code) {
|
|
copyToClipboard(code, button);
|
|
}
|
|
|
|
// Primary install action based on detected OS
|
|
function primaryInstallAction() {
|
|
const origin = window.location.origin;
|
|
switch (detectedOS) {
|
|
case 'windows':
|
|
const psCommand = `irm ${origin}/api/ca/install-script?platform=windows | iex`;
|
|
if (navigator.clipboard) {
|
|
navigator.clipboard.writeText(psCommand).then(() => {
|
|
alert('PowerShell command copied to clipboard!\n\nOpen PowerShell as Administrator and paste the command to install.\n\nCommand:\n' + psCommand);
|
|
});
|
|
} else {
|
|
prompt('Copy this PowerShell command (Run as Administrator):', psCommand);
|
|
}
|
|
break;
|
|
case 'macos':
|
|
case 'ios':
|
|
window.location.href = '/root.mobileconfig';
|
|
break;
|
|
case 'linux':
|
|
const bashCommand = `curl -fsSk ${origin}/api/ca/install-script?platform=linux | sudo bash`;
|
|
if (navigator.clipboard) {
|
|
navigator.clipboard.writeText(bashCommand).then(() => {
|
|
alert('Install command copied to clipboard!\n\nOpen Terminal and paste the command to install.\n\nCommand:\n' + bashCommand);
|
|
});
|
|
} else {
|
|
prompt('Copy this command (run in terminal with sudo):', bashCommand);
|
|
}
|
|
break;
|
|
case 'android':
|
|
window.location.href = '/root.crt';
|
|
break;
|
|
default:
|
|
window.location.href = '/root.crt';
|
|
}
|
|
}
|
|
|
|
// Show instruction tab
|
|
function showTab(platform, event) {
|
|
// Remove active class from all tabs and content
|
|
document.querySelectorAll('.tab-btn').forEach(btn => btn.classList.remove('active'));
|
|
document.querySelectorAll('.tab-content').forEach(content => content.classList.remove('active'));
|
|
|
|
// Add active class to selected tab button (if called from click event)
|
|
if (event && event.target) {
|
|
event.target.classList.add('active');
|
|
} else {
|
|
// If called programmatically, find and activate the button
|
|
const tabBtn = document.querySelector(`[onclick*="showTab('${platform}')"]`);
|
|
if (tabBtn) tabBtn.classList.add('active');
|
|
}
|
|
|
|
// Add active class to tab content
|
|
const tabContent = document.getElementById('tab-' + platform);
|
|
if (tabContent) tabContent.classList.add('active');
|
|
}
|
|
|
|
// Generate QR code
|
|
function generateQRCode() {
|
|
const qrContainer = document.getElementById('qrcode');
|
|
qrContainer.innerHTML = ''; // Clear any existing QR code
|
|
|
|
new QRCode(qrContainer, {
|
|
text: window.location.origin,
|
|
width: 200,
|
|
height: 200,
|
|
colorDark: "#000000",
|
|
colorLight: "#ffffff",
|
|
correctLevel: QRCode.CorrectLevel.M
|
|
});
|
|
}
|
|
|
|
// Build and display platform-specific install commands using dynamic URLs
|
|
function updateInstallCommands() {
|
|
const origin = window.location.origin;
|
|
const windowsCmd = `irm ${origin}/api/ca/install-script?platform=windows | iex`;
|
|
const macosCmd = `curl -fsSk ${origin}/api/ca/install-script?platform=macos | sudo bash`;
|
|
const linuxCmd = `curl -fsSk ${origin}/api/ca/install-script?platform=linux | sudo bash`;
|
|
|
|
// Windows
|
|
const winText = document.getElementById('windows-install-text');
|
|
const winCopy = document.getElementById('windows-install-copy');
|
|
if (winText) winText.textContent = windowsCmd;
|
|
if (winCopy) winCopy.onclick = function() { copyCode(this, windowsCmd); };
|
|
|
|
// macOS
|
|
const macText = document.getElementById('macos-install-text');
|
|
const macCopy = document.getElementById('macos-install-copy');
|
|
if (macText) macText.textContent = macosCmd;
|
|
if (macCopy) macCopy.onclick = function() { copyCode(this, macosCmd); };
|
|
|
|
// Linux
|
|
const linuxText = document.getElementById('linux-install-text');
|
|
const linuxCopy = document.getElementById('linux-install-copy');
|
|
if (linuxText) linuxText.textContent = linuxCmd;
|
|
if (linuxCopy) linuxCopy.onclick = function() { copyCode(this, linuxCmd); };
|
|
}
|
|
|
|
// Initialize on page load
|
|
window.addEventListener('DOMContentLoaded', () => {
|
|
// Detect OS
|
|
detectedOS = detectOS();
|
|
|
|
// Update button text and detected platform
|
|
const osNames = {
|
|
'windows': 'Windows',
|
|
'macos': 'macOS',
|
|
'linux': 'Linux',
|
|
'ios': 'iOS',
|
|
'android': 'Android',
|
|
'unknown': 'Your Platform'
|
|
};
|
|
|
|
const osIcons = {
|
|
'windows': '🪟',
|
|
'macos': '🍎',
|
|
'linux': '🐧',
|
|
'ios': '📱',
|
|
'android': '🤖',
|
|
'unknown': '💻'
|
|
};
|
|
|
|
const btnText = document.getElementById('btnText');
|
|
const detectedPlatform = document.getElementById('detectedPlatform');
|
|
|
|
btnText.textContent = `Install for ${osNames[detectedOS]}`;
|
|
detectedPlatform.textContent = `${osIcons[detectedOS]} Detected: ${osNames[detectedOS]}`;
|
|
|
|
// Auto-open correct tab
|
|
if (detectedOS !== 'unknown') {
|
|
showTab(detectedOS);
|
|
document.querySelectorAll('.tab-btn').forEach(btn => {
|
|
if (btn.textContent.toLowerCase() === osNames[detectedOS].toLowerCase()) {
|
|
btn.classList.add('active');
|
|
} else {
|
|
btn.classList.remove('active');
|
|
}
|
|
});
|
|
}
|
|
|
|
// Load certificate info
|
|
loadCertInfo();
|
|
|
|
// Load service certificates
|
|
loadServiceCertificates();
|
|
|
|
// Generate QR code
|
|
generateQRCode();
|
|
|
|
// Build dynamic install commands
|
|
updateInstallCommands();
|
|
|
|
// Show HTTP tip when accessed over HTTPS (new devices need HTTP)
|
|
if (window.location.protocol === 'https:') {
|
|
const httpTip = document.getElementById('httpTip');
|
|
const httpLink = document.getElementById('httpLink');
|
|
const httpUrl = 'http://' + window.location.host;
|
|
httpLink.href = httpUrl;
|
|
httpLink.textContent = httpUrl;
|
|
httpTip.style.display = 'block';
|
|
}
|
|
});
|
|
|
|
// Load service certificates
|
|
async function loadServiceCertificates() {
|
|
try {
|
|
const response = await fetch('/api/ca/certs');
|
|
if (!response.ok) {
|
|
throw new Error('Failed to fetch certificates');
|
|
}
|
|
|
|
const data = await response.json();
|
|
|
|
if (data.success && data.certificates && data.certificates.length > 0) {
|
|
displayServiceCertificates(data.certificates);
|
|
} else {
|
|
displayNoCertificates();
|
|
}
|
|
} catch (error) {
|
|
console.error('Error loading service certificates:', error);
|
|
displayNoCertificates();
|
|
}
|
|
}
|
|
|
|
// Display service certificates
|
|
function displayServiceCertificates(certificates) {
|
|
const certGrid = document.getElementById('certGrid');
|
|
|
|
// Sort by domain name
|
|
certificates.sort((a, b) => a.domain.localeCompare(b.domain));
|
|
|
|
certGrid.innerHTML = certificates.map(cert => {
|
|
const statusClass = cert.status === 'valid' ? 'valid' :
|
|
cert.status === 'expiring-soon' ? 'expiring-soon' : 'expired';
|
|
const statusText = cert.status === 'valid' ? 'Valid' :
|
|
cert.status === 'expiring-soon' ? 'Expiring Soon' : 'Expired';
|
|
|
|
const expiryDate = new Date(cert.validUntil);
|
|
const formattedDate = expiryDate.toLocaleDateString('en-US', {
|
|
month: 'short',
|
|
day: 'numeric',
|
|
year: 'numeric'
|
|
});
|
|
|
|
return `
|
|
<div class="cert-card">
|
|
<div class="cert-header">
|
|
<span class="cert-domain">${cert.domain}</span>
|
|
<span class="cert-status ${statusClass}">${statusText}</span>
|
|
</div>
|
|
<div class="cert-info">
|
|
<strong>Expires:</strong> ${formattedDate}
|
|
</div>
|
|
<div class="cert-info">
|
|
<strong>Days remaining:</strong> ${cert.daysUntilExpiration}
|
|
</div>
|
|
<div class="cert-info" style="font-size: 0.75rem; word-break: break-all;">
|
|
<strong>Fingerprint:</strong><br>${cert.fingerprint}
|
|
</div>
|
|
<div class="cert-actions">
|
|
<a href="/api/ca/cert/${cert.domain}?format=pfx&password=dashcaddy"
|
|
class="cert-btn cert-btn-primary"
|
|
download="${cert.domain}.pfx">
|
|
Download PFX
|
|
</a>
|
|
<a href="/api/ca/cert/${cert.domain}?format=pem"
|
|
class="cert-btn"
|
|
download="${cert.domain}.pem">
|
|
PEM
|
|
</a>
|
|
<a href="/api/ca/cert/${cert.domain}?format=crt"
|
|
class="cert-btn"
|
|
download="${cert.domain}.crt">
|
|
CRT
|
|
</a>
|
|
</div>
|
|
</div>
|
|
`;
|
|
}).join('');
|
|
}
|
|
|
|
// Display message when no certificates exist
|
|
function displayNoCertificates() {
|
|
const certGrid = document.getElementById('certGrid');
|
|
certGrid.innerHTML = `
|
|
<div class="cert-empty">
|
|
<p>No service certificates generated yet.</p>
|
|
<p style="font-size: 0.875rem; margin-top: 0.5rem;">
|
|
Certificates are automatically generated when services request them.
|
|
</p>
|
|
</div>
|
|
`;
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|