Skip to content

Instantly share code, notes, and snippets.

@eugenestarchenko
Forked from lqez/verify_elb_https.py
Created September 27, 2016 14:03
Show Gist options
  • Select an option

  • Save eugenestarchenko/667e97d728357699dee570676cae0ae2 to your computer and use it in GitHub Desktop.

Select an option

Save eugenestarchenko/667e97d728357699dee570676cae0ae2 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