#NEWLINE# def get_all_certs_in_region( self , account , region , exception_map ) : #NEWLINE# #INDENT# from security_monkey.common.sts_connect import connect #NEWLINE# import traceback #NEWLINE# all_certs = [ ] #NEWLINE# app . logger . debug ( 'Checking {}/{}/{}' . format ( self . index , account , region ) ) #NEWLINE# try : #NEWLINE# #INDENT# iamconn = connect ( account , 'iam' , region = region ) #NEWLINE# marker = None #NEWLINE# while True : #NEWLINE# #INDENT# certs = self . wrap_aws_rate_limited_call ( iamconn . list_server_certs , marker = marker ) #NEWLINE# all_certs . extend ( certs . server_certificate_metadata_list ) #NEWLINE# if ( certs . is_truncated == 'true' ) : #NEWLINE# #INDENT# marker = certs . marker #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# #UNINDENT# for cert in marker : #NEWLINE# #INDENT# iam_cert = self . wrap_aws_rate_limited_call ( iamconn . get_server_certificate , cert_name = cert . server_certificate_name ) #NEWLINE# cert [ 'body' ] = iam_cert . certificate_body #NEWLINE# cert [ 'chain' ] = None #NEWLINE# if hasattr ( iam_cert , 'certificate_chain' ) : #NEWLINE# #INDENT# cert [ 'chain' ] = iam_cert . certificate_chain #NEWLINE# #UNINDENT# cert_info = get_cert_info ( cert [ 'body' ] ) #NEWLINE# for key in cert_info . iterkeys ( ) : #NEWLINE# #INDENT# cert [ key ] = cert_info [ key ] #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# except Exception as e : #NEWLINE# #INDENT# app . logger . warn ( traceback . format_exc ( ) ) #NEWLINE# if ( region not in TROUBLE_REGIONS ) : #NEWLINE# #INDENT# exc = BotoConnectionIssue ( str ( e ) , self . index , account , 'universal' ) #NEWLINE# self . slurp_exception ( ( self . index , account , 'universal' ) , exc , exception_map ) #NEWLINE# #UNINDENT# #UNINDENT# app . logger . info ( 'Found {} {} from {}/{}' . format ( len ( all_certs ) , self . i_am_plural , account , 'universal' ) ) #NEWLINE# return all_certs