feature: the VPN, the router, the name server and WebDAV are components switched on the System tab and installed on demand, Caddy from the Ubuntu archive is a dependency and serves every HTTP and HTTPS port, HTTPS is chosen at install, its certificate is of the Servers Issuing CA or self-signed by default, of ACME or of another CA, the issuing CAs are in one tab, a locked account is unlocked again, the name of a CA is fixed once the CA exists, and a run of setup is no longer cut short by a change.
Release / release (push) Failing after 8s
Release / release (push) Failing after 8s
This commit is contained in:
1 parent
a649331aa2
commit
a7bfabcb89
97 files changed
+4498
-1834
No files matched your search
@@ -6,8 +6,10 @@ or makes a key and writes a PFX file whose password is read from the first line
|
||||
CSR of an issuing CA that waits for the offline root, with the openssl extensions to sign it with, and ca import takes
|
||||
the signed certificate, and, named root, the certificate of the offline root. root import-crl takes a CRL of the
|
||||
offline root, and root setup-code exchanges a setup code of a Simple CA token, read from the first line of standard
|
||||
input, for the token. maintain signs the stale CRLs again, or fetches those of Simple CA; linux-manager-pki.service
|
||||
runs it daily. A change that needs linux-manager-setup restarts it without waiting.
|
||||
input, for the token. https status shows the server's HTTPS certificate, https csr prints a new CSR for
|
||||
wan.local_fqdn, to be signed by another CA, https import takes the certificate signed for it, and https import-pfx a
|
||||
PKCS#12 file whose password is read from the first line of standard input. maintain signs the stale CRLs again, or
|
||||
fetches those of Simple CA; linux-manager-pki.service runs it daily. A change that needs linux-manager-setup requests a run of it without waiting.
|
||||
|
||||
The answer is text for people on standard output, and a failure is a message on standard error. With --json the answer
|
||||
is JSON on standard output, and a failure is {"error": ...} there too. The exit status says what failed: 2 the request
|
||||
@@ -24,6 +26,9 @@ commands and their options.
|
||||
linux-manager-ca [--json] ca import NAME|root FILE
|
||||
linux-manager-ca [--json] root import-crl FILE
|
||||
linux-manager-ca [--json] root setup-code (setup code on stdin)
|
||||
linux-manager-ca [--json] https status|csr
|
||||
linux-manager-ca [--json] https import FILE
|
||||
linux-manager-ca [--json] https import-pfx FILE (password on stdin)
|
||||
"""
|
||||
|
||||
import argparse
|
||||
@@ -31,7 +36,6 @@ import base64
|
||||
import json
|
||||
import os
|
||||
import pathlib
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
sys.path.insert(0, '/usr/lib/linux-manager')
|
||||
@@ -56,10 +60,6 @@ def secret():
|
||||
return sys.stdin.readline().rstrip('\r\n')
|
||||
|
||||
|
||||
def restart_setup():
|
||||
subprocess.run(['systemctl', 'restart', '--no-block', 'linux-manager-setup.service'], capture_output=True, text=True)
|
||||
|
||||
|
||||
def show_status(document):
|
||||
root = document['root']
|
||||
source = {'local': 'created by the server', 'offline': 'offline',
|
||||
@@ -95,6 +95,13 @@ def run(options):
|
||||
if options.command == 'status':
|
||||
document = linuxmanager_pki.status(cfg)
|
||||
return document, None
|
||||
if options.command == 'https' and options.action == 'status':
|
||||
document = linuxmanager_pki.https_status(cfg)
|
||||
return document, (f'Source: {document["source"]}, served: {document["served"] or "none"}\n'
|
||||
f'Subject: {document["subject"] or "-"}, issuer: {document["issuer"] or "-"}, '
|
||||
f'expires {document["expires"] or "-"}\n'
|
||||
f'Names: {", ".join(document["sans"]) or "-"}' + ('\nA CSR waits for its certificate.'
|
||||
if document['pending'] else ''))
|
||||
if options.command == 'list':
|
||||
found = [entry for entry in linuxmanager_pki.certificates() if options.ca in (None, entry['ca'])]
|
||||
text = '\n'.join(f'{entry["serial"]} {entry["ca"]} {entry["kind"]} {entry["subject"]} {entry["state"]} '
|
||||
@@ -117,13 +124,13 @@ def run(options):
|
||||
if options.command == 'revoke':
|
||||
document = linuxmanager_pki.revoke(cfg, options.serial, options.reason)
|
||||
if document['reissue']:
|
||||
restart_setup()
|
||||
linuxmanager.request_setup()
|
||||
return document, f'Certificate {document["serial"]} revoked' + \
|
||||
('; linux-manager-setup issues a new one.' if document['reissue'] else '.')
|
||||
if options.command == 'maintain':
|
||||
notices, due = linuxmanager_pki.maintain(cfg)
|
||||
if due:
|
||||
restart_setup()
|
||||
linuxmanager.request_setup()
|
||||
return {'renewal': due, 'notices': notices}, '\n'.join(
|
||||
['CRLs checked' + ('; linux-manager-setup renews the certificates.' if due else '.'),
|
||||
*(f'Warning: {notice}' for notice in notices)])
|
||||
@@ -132,12 +139,24 @@ def run(options):
|
||||
return document, document['csr'] + '\n' + document['extensions']
|
||||
if options.command == 'ca':
|
||||
document = linuxmanager_pki.import_ca(cfg, options.name, pathlib.Path(options.file).read_text(encoding='ascii'))
|
||||
restart_setup()
|
||||
linuxmanager.request_setup()
|
||||
what = 'The root' if options.name == 'root' else f'Issuing CA {options.name}'
|
||||
return document, f'{what} has its certificate, which expires {document["expires"]}.'
|
||||
if options.command == 'https' and options.action == 'csr':
|
||||
document = linuxmanager_pki.https_csr(cfg)
|
||||
return document, document['csr']
|
||||
if options.command == 'https':
|
||||
if options.action == 'import':
|
||||
document = linuxmanager_pki.import_https_certificate(
|
||||
cfg, pathlib.Path(options.file).read_text(encoding='ascii'))
|
||||
else:
|
||||
document = linuxmanager_pki.import_https_pfx(cfg, pathlib.Path(options.file).read_bytes(), secret())
|
||||
linuxmanager.request_setup()
|
||||
return document, f'The HTTPS certificate of {document["subject"]}, issued by {document["issuer"]}, ' \
|
||||
f'expires {document["expires"]}.'
|
||||
if options.action == 'setup-code':
|
||||
document = linuxmanager_pki.exchange_code(cfg, secret())
|
||||
restart_setup()
|
||||
linuxmanager.request_setup()
|
||||
return document, (f'Simple CA token of issuing CA {document["upstream"]} taken'
|
||||
+ (f', valid until {document["expires"]}.' if document['expires'] else '.'))
|
||||
document = linuxmanager_pki.import_root_crl(cfg, pathlib.Path(options.file).read_bytes())
|
||||
@@ -172,6 +191,12 @@ def main(argv):
|
||||
root_actions = root.add_subparsers(dest='action', required=True, parser_class=Parser)
|
||||
root_actions.add_parser('import-crl', help='take a CRL of the offline root').add_argument('file')
|
||||
root_actions.add_parser('setup-code', help='exchange a Simple CA setup code from stdin for the token')
|
||||
host = commands.add_parser('https', help="the server's HTTPS certificate")
|
||||
host_actions = host.add_subparsers(dest='action', required=True, parser_class=Parser)
|
||||
host_actions.add_parser('status', help='show the certificate Caddy serves')
|
||||
host_actions.add_parser('csr', help='print a new CSR for wan.local_fqdn, to be signed by another CA')
|
||||
host_actions.add_parser('import', help='take the certificate signed for the CSR, PEM with its chain').add_argument('file')
|
||||
host_actions.add_parser('import-pfx', help='take a PKCS#12 file; the password is read from stdin').add_argument('file')
|
||||
options = parser.parse_args(argv)
|
||||
os.umask(0o077)
|
||||
|
||||
|
||||
Reference in new issue
Block a user