Obtain the DNS names from the common_name and dns_zones from the entry's SSL certificate. Determine if the entry's DNS names is in the list of provided zones. Return the matched zone.
(entry, zones)
| 220 | |
| 221 | |
| 222 | def check_in_zone(entry, zones): |
| 223 | """ |
| 224 | Obtain the DNS names from the common_name and dns_zones from the entry's SSL certificate. |
| 225 | Determine if the entry's DNS names is in the list of provided zones. |
| 226 | Return the matched zone. |
| 227 | """ |
| 228 | |
| 229 | try: |
| 230 | certificate = entry["server_certificates"]["certificate"] |
| 231 | except: |
| 232 | return [] |
| 233 | |
| 234 | try: |
| 235 | temp1 = certificate["parsed"]["subject"]["common_name"] |
| 236 | except KeyError: |
| 237 | temp1 = [] |
| 238 | |
| 239 | try: |
| 240 | temp2 = certificate["parsed"]["extensions"]["subject_alt_name"]["dns_names"] |
| 241 | except KeyError: |
| 242 | temp2 = [] |
| 243 | |
| 244 | cert_zones = [] |
| 245 | value_array = temp1 + temp2 |
| 246 | for value in value_array: |
| 247 | zone = zone_compare(value, zones) |
| 248 | if zone is not None and zone not in cert_zones: |
| 249 | cert_zones.append(zone) |
| 250 | |
| 251 | return cert_zones |
| 252 | |
| 253 | |
| 254 | def insert_result(entry, port, ip_context, all_zones, results_collection): |
no test coverage detected