예제 #1
0
def _try_fix_cert(hostname):
    cert_path = misc_dir + '/certs/' + hostname + '.crt'
    key_path = misc_dir + '/certs/' + hostname + '.key'
    cert = autonginx.certs.load_cert(cert_path)
    if autonginx._is_expiration_ok(cert) and autonginx.certs.matches(cert, hostname):
        return True

    ok_cert = _find_auto_cert(hostname)
    if not ok_cert:
        return False

    print('Found good automatic certificate for %s: %s' % (hostname, ok_cert.path), file=sys.stderr)
    ok_cert_path = ok_cert.path
    ok_key_path = ok_cert_path.rsplit('.', 1)[0] + '.key'

    autonginx._abs_symlink_force(ok_cert_path, cert_path)
    autonginx._abs_symlink_force(ok_key_path, key_path)
    return True
예제 #2
0
def _find_auto_cert(hostname):
    for cert in auto_certificates:
        if autonginx._is_expiration_ok(cert) and autonginx.certs.matches(cert, hostname):
            return cert

    return None