Skip to content

Instantly share code, notes, and snippets.

@lqez
Created May 8, 2015 02:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save lqez/bc019e56f463cbbbfbb1 to your computer and use it in GitHub Desktop.
Save lqez/bc019e56f463cbbbfbb1 to your computer and use it in GitHub Desktop.
Verify ELB's https connection
import boto.route53
import boto.ec2.elb
import requests
region = 'ap-northeast-1'
# Get all records from Route53
r53_conn = boto.route53.connect_to_region(region)
zones = r53_conn.get_zones()
aliases = dict()
for zone in zones:
for r in zone.get_records():
if r.alias_dns_name:
aliases[r.alias_dns_name[:-1]] = r.name[:-1]
# Get all load balancers and match with Route53 records
elb_conn = boto.ec2.elb.connect_to_region(region)
elbs = elb_conn.get_all_load_balancers()
for elb in elbs:
for port in elb.listeners:
if port[0] != 443:
continue
for alias, name in aliases.iteritems():
if elb.canonical_hosted_zone_name in alias:
try:
requests.get('https://' + name, verify=True)
except requests.exceptions.SSLError:
print name, elb.canonical_hosted_zone_name, 'has SSL problem.'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment