# This file is part of acme-updater, written by Helmut Pozimski 2016-2017.
#
# stov is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 2 of the License.
#
# stov is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with stov. If not, see .
# -*- coding: utf8 -*-
"""
collection of helper functions used in other modules of acme-updater.
"""
import logging
import datetime
import os
import shutil
import hashlib
import OpenSSL
import dns.tsigkeyring
import dns.update
import dns.query
LOGGER = logging.getLogger("acme-updater")
def parse_apache_vhost(file_obj):
"""
Parses a given vhost file and extracts the main domain,
the certificate file, the TLS key file and all domains contained
within the vhost.
:param file_obj: file obj pointing to a vhost to parse
:return: list of tuples with domains and found certificates
:rtype: list
"""
vhost_started = False
parsed_info = []
cert_path = ""
key_path = ""
main_domain = ""
domains = set()
for line in file_obj:
if "