예제 #1
0
def create_cert_that_expires_in_days(days,
                                     serial=None,
                                     domains=None,
                                     owner=None):
    import random
    from random import randrange
    from string import ascii_lowercase

    now = arrow.utcnow()
    not_after = now + timedelta(
        days=days,
        hours=1)  # a bit more than specified since we'll check in the future

    certificate = CertificateFactory()
    certificate.not_after = not_after
    certificate.notify = True
    certificate.owner = ''.join(
        random.choice(ascii_lowercase) for _ in range(10)) + '@example.com'
    endpoints = []
    for i in range(0, randrange(0, 5)):
        endpoints.append(EndpointFactory())
    certificate.endpoints = endpoints
    if serial:
        certificate.serial = serial
    if owner:
        certificate.owner = owner
    if domains:
        certificate.domains = domains
    return certificate
예제 #2
0
def create_ca_cert_that_expires_in_days(days):
    now = arrow.utcnow()
    not_after = now + timedelta(days=days, hours=1)  # a bit more than specified since we'll check in the future

    authority = AuthorityFactory()
    certificate = CertificateFactory()
    certificate.not_after = not_after
    certificate.notify = True
    certificate.root_authority_id = authority.id
    certificate.authority_id = None
    return certificate
예제 #3
0
def create_cert_that_expires_in_days(days):
    from random import randrange

    now = arrow.utcnow()
    not_after = now + timedelta(days=days, hours=1)  # a bit more than specified since we'll check in the future

    certificate = CertificateFactory()
    certificate.not_after = not_after
    certificate.notify = True
    endpoints = []
    for i in range(0, randrange(0, 5)):
        endpoints.append(EndpointFactory())
    certificate.endpoints = endpoints
    return certificate