Confirmed users
529
edits
| Line 526: | Line 526: | ||
<source lang="python"> | <source lang="python"> | ||
#!/usr/bin/env python | #!/usr/bin/env python | ||
# Apply recommendation from https://wiki.mozilla.org/Security/Server_Side_TLS | # Apply recommendation from https://wiki.mozilla.org/Security/Server_Side_TLS | ||
| Line 540: | Line 541: | ||
import sys | import sys | ||
if len(sys.argv) < | if len(sys.argv) < 3: | ||
print "usage : %s REGION ELB-NAME <MODE>" % sys.argv[0] | print "usage : %s REGION ELB-NAME <MODE>" % sys.argv[0] | ||
print "" | print "" | ||
| Line 559: | Line 560: | ||
#logging.basicConfig(level=logging.DEBUG) | #logging.basicConfig(level=logging.DEBUG) | ||
policy = {'old':{}, | |||
'intermediate':{}, | |||
'modern':{}} | |||
policy['old']['name'] = 'Mozilla-OpSec-TLS-Old-v-3-2' | |||
policy['old']['ciphersuite'] = { | |||
"ECDHE-ECDSA-AES128-GCM-SHA256": True, | |||
"ECDHE-RSA-AES128-GCM-SHA256": True, | "ECDHE-RSA-AES128-GCM-SHA256": True, | ||
"ECDHE-ECDSA-AES128-SHA256": True, | "ECDHE-ECDSA-AES128-SHA256": True, | ||
| Line 655: | Line 661: | ||
# reuse the Old policy minus SSLv3 and 3DES | # reuse the Old policy minus SSLv3 and 3DES | ||
policy['intermediate']['name'] = 'Mozilla-OpSec-TLS-Intermediate-v-3-2' | |||
policy['intermediate']['ciphersuite'] = policy['old']['ciphersuite'].copy() | |||
policy['intermediate']['ciphersuite'].update( | |||
{"Protocol-SSLv3": False, | |||
"DES-CBC3-SHA": False}) | |||
# reuse the intermediate policy minus TLSv1 and non PFS ciphers | # reuse the intermediate policy minus TLSv1 and non PFS ciphers | ||
policy['modern']['name'] = 'Mozilla-OpSec-TLS-Modern-v-3-2' | |||
policy['modern']['ciphersuite'] = policy['intermediate']['ciphersuite'].copy() | |||
policy['modern']['ciphersuite'].update( | |||
{"Protocol-TLSv1": False, | |||
"AES128-GCM-SHA256": False, | |||
"AES256-GCM-SHA384": False, | |||
"DHE-DSS-AES128-SHA": False, | |||
"AES128-SHA256": False, | |||
"AES128-SHA": False, | |||
"DHE-DSS-AES256-SHA256": False, | |||
"AES256-SHA256": False, | |||
"AES256-SHA": False, | |||
"CAMELLIA128-SHA": False, | |||
"CAMELLIA256-SHA": False}) | |||
if not conf_mode in policy.keys(): | |||
print "Invalid policy name, must be one of %s" % policy.keys() | |||
sys.exit(1) | |||
if conf_mode | |||
# Create the Ciphersuite Policy | # Create the Ciphersuite Policy | ||
params = {'LoadBalancerName': load_balancer_name, | params = {'LoadBalancerName': load_balancer_name, | ||
'PolicyName': | 'PolicyName': policy[conf_mode]['name'], | ||
'PolicyTypeName': 'SSLNegotiationPolicyType'} | 'PolicyTypeName': 'SSLNegotiationPolicyType'} | ||
conn_elb.build_complex_list_params(params, | conn_elb.build_complex_list_params( | ||
params, | |||
[(x, policy[conf_mode]['ciphersuite'][x]) for x in policy[conf_mode]['ciphersuite'].keys()], | |||
'PolicyAttributes.member', | |||
('AttributeName', 'AttributeValue')) | |||
policy_result = conn_elb.get_list('CreateLoadBalancerPolicy', params, None, verb='POST') | |||
# Apply the Ciphersuite Policy to your ELB | # Apply the Ciphersuite Policy to your ELB | ||
params = {'LoadBalancerName': load_balancer_name, | params = {'LoadBalancerName': load_balancer_name, | ||
'LoadBalancerPort': 443, | 'LoadBalancerPort': 443, | ||
'PolicyNames.member.1': | 'PolicyNames.member.1': policy[conf_mode]['name']} | ||
result = conn_elb.get_list('SetLoadBalancerPoliciesOfListener', params, None) | result = conn_elb.get_list('SetLoadBalancerPoliciesOfListener', params, None) | ||
print "New Policy '%s' created and applied to load balancer %s in %s" % ( | print "New Policy '%s' created and applied to load balancer %s in %s" % ( | ||
policy[conf_mode]['name'], | |||
load_balancer_name, | |||
region) | |||
</source> | </source> | ||