Exemple #1
0
def certify_elbs(aws_credentials, region='us-east-1'):

    elbs = get_elbs(aws_credentials, region=region)

    retval = []

    for elb in elbs:

        if elb.scheme != 'internet-facing':
            continue

        for listener in elb.listeners:
            if listener[2] != 'HTTPS':
                continue

            expiry = None
            error_msg = None

            try:

                expiry = get_expiry(elb.dns_name)

            except CertifierWarningException as e:
                # print "CertifierWarningException"
                # print e.host
                # print e.message

                error_msg = e.message

            except CertifierException as e:
                # print "CertifierException"
                # print e.host
                # print e.message

                error_msg = e.message

            except SSL.WantReadError as e:
                # print e
                # print e.message
                # print dir(e)
                # print "OpenSSL.SSL.WantReadError"

                error_msg = e.message

            except timeout as e:
                # print e
                # print e.message
                # print e.args
                # print dir(e)
                # print type(e)

                error_msg = e.message

            retval.append(OrderedDict({
                            'dns_name': format_elb_dns_name(elb.dns_name),
                            'expiry': expiry,
                            'arn': format_arn(listener[4]),
                            'error': error_msg
                        }))

    return retval
Exemple #2
0
def certify_distributions(aws_credentials):

    distributions = get_distributions(aws_credentials)

    retval = []

    if 'Items' not in distributions['DistributionList']:
        return retval

    for distribution in distributions['DistributionList']['Items']:

        expiry = None
        error_msg = None

        # If there's no CNAME, we're using the *.cloudfront cert
        if 'CloudFrontDefaultCertificate' in distribution['ViewerCertificate'].keys():
            continue


        try:

            cname = distribution['Aliases']['Items'][0]
            expiry = get_expiry(cname)

        except CertifierWarningException as e:
            # print "CertifierWarningException"
            # print e.host
            # print e.message

            error_msg = e.message

        except CertifierException as e:
            # print "CertifierException"
            # print e.host
            # print e.message

            error_msg = e.message

        except SSL.WantReadError as e:
            # print e
            # print e.message
            # print dir(e)
            # print "OpenSSL.SSL.WantReadError"

            error_msg = e.message

        except gaierror as e:
            # print e
            # print e.message
            # print e.args
            # print dir(e)
            # print type(e)

            error_msg = e

        except error as e:
            # print e
            # print e.message
            # print e.args
            # print dir(e)
            # print type(e)

            error_msg = e

        except timeout as e:
            # print e
            # print e.message
            # print e.args
            # print dir(e)
            # print type(e)

            error_msg = e.message


        retval.append(OrderedDict({
                        'dns_name': cname,
                        'expiry': expiry,
                        'arn': None,
                        'error': error_msg
                    }))

    return retval
Exemple #3
0
def certify_elbs(aws_credentials, region='us-east-1'):

    elbs = get_elbs(aws_credentials, region=region)

    retval = []

    for elb in elbs:

        if elb.scheme != 'internet-facing':
            continue

        for listener in elb.listeners:
            if listener[2] != 'HTTPS':
                continue

            expiry = None
            error_msg = None

            try:

                expiry = get_expiry(elb.dns_name)

            except CertifierWarningException as e:
                # print "CertifierWarningException"
                # print e.host
                # print e.message

                error_msg = e.message

            except CertifierException as e:
                # print "CertifierException"
                # print e.host
                # print e.message

                error_msg = e.message

            except SSL.WantReadError as e:
                # print e
                # print e.message
                # print dir(e)
                # print "OpenSSL.SSL.WantReadError"

                error_msg = e.message

            except timeout as e:
                # print e
                # print e.message
                # print e.args
                # print dir(e)
                # print type(e)

                error_msg = e.message

            retval.append(
                OrderedDict({
                    'dns_name': format_elb_dns_name(elb.dns_name),
                    'expiry': expiry,
                    'arn': format_arn(listener[4]),
                    'error': error_msg
                }))

    return retval
Exemple #4
0
def certify_distributions(aws_credentials):

    distributions = get_distributions(aws_credentials)

    retval = []

    if 'Items' not in distributions['DistributionList']:
        return retval

    for distribution in distributions['DistributionList']['Items']:

        expiry = None
        error_msg = None

        # If there's no CNAME, we're using the *.cloudfront cert
        if 'CloudFrontDefaultCertificate' in distribution[
                'ViewerCertificate'].keys():
            continue

        try:

            cname = distribution['Aliases']['Items'][0]
            expiry = get_expiry(cname)

        except CertifierWarningException as e:
            # print "CertifierWarningException"
            # print e.host
            # print e.message

            error_msg = e.message

        except CertifierException as e:
            # print "CertifierException"
            # print e.host
            # print e.message

            error_msg = e.message

        except SSL.WantReadError as e:
            # print e
            # print e.message
            # print dir(e)
            # print "OpenSSL.SSL.WantReadError"

            error_msg = e.message

        except gaierror as e:
            # print e
            # print e.message
            # print e.args
            # print dir(e)
            # print type(e)

            error_msg = e

        except error as e:
            # print e
            # print e.message
            # print e.args
            # print dir(e)
            # print type(e)

            error_msg = e

        except timeout as e:
            # print e
            # print e.message
            # print e.args
            # print dir(e)
            # print type(e)

            error_msg = e.message

        retval.append(
            OrderedDict({
                'dns_name': cname,
                'expiry': expiry,
                'arn': None,
                'error': error_msg
            }))

    return retval