Commit 5a3c2113 authored by aoh's avatar aoh
Browse files

Merge remote-tracking branch 'origin/key-db-save'

parents 2232866a 60517bdd
......@@ -58,3 +58,13 @@ class DB():
'LEFT OUTER JOIN update_key ON subdomain.id = update_key.subid '
'WHERE subdomain.id = %s AND update_key.secret IS NULL', domainid)
return [item.get("id") for item in cursor.fetchall()]
def set_subdomain_keys(self, domainid, public, private):
with self.connection.cursor() as cursor:
res = cursor.execute('INSERT INTO update_key '
'(`subid`, `update_key`, `secret`) VALUES (%s, %s, %s)',
(domainid, public, private,))
if res == 1:
self.connection.commit()
return (res == 1)
......@@ -20,7 +20,7 @@ class dnssec_keygen():
row = kf.readline()
public_key, part = row.split(" ")[6:8]
self.public_key = public_key
self.private_key = public_key + part
self.private_key = (public_key + part).replace('\n', '')
os.unlink(keyfile)
privatefile = keyfile.replace("key", "private")
os.unlink(privatefile)
......
#!/usr/bin/env python3
from db import DB
from dnssec_keygen import dnssec_keygen
with DB() as d:
for id in d.get_domain_ids():
domain_name = d.get_domain_name(id)
for sid in d.get_subdomain_ids(id):
subdomain_name = d.get_subdomain_name(sid)
fqdn = subdomain_name + '.' + domain_name
with dnssec_keygen() as dk:
public_key, private_key = dk.create_keys(fqdn)
print(public_key)
print(private_key)
#!/usr/bin/env python3
from db import DB
from dnssec_keygen import dnssec_keygen
def application(env, start_response):
with DB() as d:
for id in d.get_domain_ids():
domain_name = d.get_domain_name(id)
for sid in d.get_subdomain_ids_without_keys(id):
subdomain_name = d.get_subdomain_name(sid)
fqdn = subdomain_name + '.' + domain_name
with dnssec_keygen() as dk:
print('Generating keys for {}'.format(sid))
public_key, private_key = dk.create_keys(fqdn)
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""]
#!/bin/sh
. /etc/rc.subr
name=uwsgi_generate_named_config
rcvar=uwsgi_generate_named_config_enable
uwsgi_generate_named_config_chdir="/usr/local/etc/nginx/cgi_scripts"
command="/usr/local/bin/uwsgi"
command_args="--plugin python36 --socket /tmp/generator_cgi.socket --py-programname /usr/local/bin/python3.6 --pythonpath /usr/local/lib/python3.6/site-packages --wsgi-file /usr/local/etc/nginx/cgi_scripts/generator.py --uid 80 --gid 80 --daemonize2 /var/log/uwsgi/generator.log"
load_rc_config $name
run_rc_command "$1"
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