Exemplo n.º 1
0
def get_host_certificate(request):
    try:
        hostname = hostname_from_principal(request.user.username)
    except ValueError:
        return HttpResponse(status=401, content='Unable to get host certificate: invalid username')
    entry = entry_from_hostname(hostname)
    return CertificateEntryResponse(entry)
Exemplo n.º 2
0
def get_host_certificate(request):
    try:
        hostname = hostname_from_principal(request.user.username)
    except ValueError:
        return HttpResponse(
            status=401,
            content='Unable to get host certificate: invalid username')
    entry = entry_from_hostname(hostname)
    return CertificateEntryResponse(entry)
Exemplo n.º 3
0
 def register_host(short_hostname, main_ip_address=None, admin_ip_address=None):
     fqdn = '%s.%s%s' % (short_hostname, settings.PDNS_INFRA_PREFIX, settings.PENATES_DOMAIN)
     principal = principal_from_hostname(fqdn, settings.PENATES_REALM)
     add_principal(principal)
     Host.objects.get_or_create(fqdn=fqdn)
     # create private key, public key, public certificate, public SSH key
     entry = entry_from_hostname(fqdn)
     pki = PKI()
     pki.ensure_certificate(entry)
     # create DNS records
     if main_ip_address:
         Domain.ensure_auto_record(main_ip_address, fqdn, unique=True, override_reverse=True)
         Host.objects.filter(fqdn=fqdn).update(main_ip_address=main_ip_address)
     if admin_ip_address:
         admin_fqdn = '%s.%s%s' % (short_hostname, settings.PDNS_ADMIN_PREFIX, settings.PENATES_DOMAIN)
         Domain.ensure_auto_record(admin_ip_address, admin_fqdn, unique=True, override_reverse=False)
         Host.objects.filter(fqdn=fqdn).update(admin_ip_address=admin_ip_address)
     return principal
Exemplo n.º 4
0
 def register_host(short_hostname, main_ip_address=None, admin_ip_address=None):
     fqdn = '%s.%s%s' % (short_hostname, settings.PDNS_INFRA_PREFIX, settings.PENATES_DOMAIN)
     principal = principal_from_hostname(fqdn, settings.PENATES_REALM)
     add_principal(principal)
     Host.objects.get_or_create(fqdn=fqdn)
     # create private key, public key, public certificate, public SSH key
     entry = entry_from_hostname(fqdn)
     pki = PKI()
     pki.ensure_certificate(entry)
     # create DNS records
     if main_ip_address:
         Domain.ensure_auto_record(main_ip_address, fqdn, unique=True, override_reverse=True)
         Host.objects.filter(fqdn=fqdn).update(main_ip_address=main_ip_address)
     if admin_ip_address:
         admin_fqdn = '%s.%s%s' % (short_hostname, settings.PDNS_ADMIN_PREFIX, settings.PENATES_DOMAIN)
         Domain.ensure_auto_record(admin_ip_address, admin_fqdn, unique=True, override_reverse=False)
         Host.objects.filter(fqdn=fqdn).update(admin_ip_address=admin_ip_address)
     return principal