Commit d97dd19f authored by aoh's avatar aoh
Browse files

Add module

Update as well which explains how to use the module.
Signed-off-by: aoh's avataraoh <>
parent d0d2e98c
echo "K$9.+157+20416"
import subprocess
import os
class dnssec_keygen():
def __init__(self):
def __enter__(self):
return self
def __exit__(self, type, value, traceback):
def create_keys(self, fqdn):
command = 'dnssec-keygen -r /dev/urandom -a HMAC-MD5 -b 512 -K /tmp/ -n HOST'
args = command.split(' ')
args += [fqdn]
with subprocess.Popen(args, stdout=subprocess.PIPE) as proc:
keyfile = "{}.key".format('utf-8'))
keyfile = keyfile.replace("\n", "")
keyfile = "/tmp/" + keyfile
with open(keyfile, "r") as kf:
row = kf.readline()
public_key, part = row.split(" ")[6:8]
self.public_key = public_key
self.private_key = public_key + part
privatefile = keyfile.replace("key", "private")
return self.public_key, self.private_key
#!/usr/bin/env python3
from db import DB
import subprocess
from dnssec_keygen import dnssec_keygen
with DB() as d:
for id in d.get_domain_ids():
......@@ -8,18 +8,7 @@ with DB() as d:
for sid in d.get_subdomain_ids(id):
subdomain_name = d.get_subdomain_name(sid)
fqdn = subdomain_name + '.' + domain_name
# TODO remove "./" from dnssec-keygen
command = './dnssec-keygen -r /dev/urandom -a HMAC-MD5 -b 512 -n HOST' # TODO add -K <dirname>
args = command.split(' ')
args += [fqdn]
with subprocess.Popen(args, stdout=subprocess.PIPE) as proc:
filename = "{}.key".format('utf-8'))
filename = filename.replace("\n", "")
# TODO read file from correct dir
with open(filename, "r") as keyfile:
row = keyfile.readline()
# TODO not sure about the syntax of the keyfile, this is just a guess..
public_key, part = row.split(" ")[6:8]
private_key = public_key + part
with dnssec_keygen() as dk:
public_key, private_key = dk.create_keys(fqdn)
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