Commit 60517bdd authored by Andreas Kempe's avatar Andreas Kempe
Browse files

Convert generate_keys.py to a CGI script.

parent c110895c
...@@ -2,14 +2,18 @@ ...@@ -2,14 +2,18 @@
from db import DB from db import DB
from dnssec_keygen import dnssec_keygen from dnssec_keygen import dnssec_keygen
with DB() as d: def application(env, start_response):
for id in d.get_domain_ids(): with DB() as d:
domain_name = d.get_domain_name(id) for id in d.get_domain_ids():
for sid in d.get_subdomain_ids_without_keys(id): domain_name = d.get_domain_name(id)
subdomain_name = d.get_subdomain_name(sid) for sid in d.get_subdomain_ids_without_keys(id):
fqdn = subdomain_name + '.' + domain_name subdomain_name = d.get_subdomain_name(sid)
with dnssec_keygen() as dk: fqdn = subdomain_name + '.' + domain_name
print('Generating keys for {}'.format(sid)) with dnssec_keygen() as dk:
public_key, private_key = dk.create_keys(fqdn) print('Generating keys for {}'.format(sid))
if not d.set_subdomain_keys(sid, public_key, private_key): public_key, private_key = dk.create_keys(fqdn)
print('Could not save keys for {}!'.format(sid)) if not d.set_subdomain_keys(sid, public_key, private_key):
print('Could not save keys for {}!'.format(sid))
start_response('200 OK', [('Content-Type', 'text/html')])
return [b""]
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment