(self, connections, request_kw)
Verify SSL certificates for unique connection domains.

        :param connections: iterable of ConnectionSettings objects
        :param request_kw: dict of kw args for `requests.request()` call
        :yields: (connection, exception) tuples for SSL verification failures
Verify SSL certificates for unique connection domains.
Verify SSL certificates for unique connection domains .
def verify_ssl_domains(self, connections, request_kw):
        """Verify SSL certificates for unique connection domains.

        :param connections: iterable of ConnectionSettings objects
        :param request_kw: dict of kw args for `requests.request()` call
        :yields: (connection, exception) tuples for SSL verification failures
        """
        successes = 0
        errors = []
        checked = set()
        for connection in connections:
            if connection.skip_cert_verify:
                self.debug(f"skipping (verify disabled): {connection.url}")
                continue
            urlparts = urlparse(connection.url)
            if urlparts.scheme != "https":
                if urlparts.scheme == "http":
                    self.debug(f"skipping (non-SSL): {connection.url}")
                else:
                    self.debug(f"skipping (unknown scheme): {connection.url}")
                continue
            hostname, x, port = urlparts.netloc.partition(":")
            if not port:
                # Key `checked` set by explicit port numbers to avoid duplicate
                # hits on domains where multiple URLs exist, some with the
                # port implied and others with port 443 set explicitly.
                port = IMPLICIT_HTTPS_PORT
            uniq = (hostname, int(port))
            if uniq in checked:
                continue
            checked.add(uniq)
            url = urlunparse(("https", urlparts.netloc, "/", "", "", ""))
            self.debug(f"HEAD {url}")
            try:
                requests.head(url, **request_kw)
                successes += 1
            except HTTPError:
                # HTTP errors mean SSL success
                successes += 1
            except SSLError as exc:
                # SSL errors are the only "failure" mode
                yield connection, exc
            except RequestException as exc:
                # other exceptions are logged as errors, but not reported as
                # "SSL failures"
                errors.append((url, exc.__class__.__name__))
        if errors:
            self.console(f"WARNING: encountered {len(errors)} request error(s):",
                self.style.NOTICE)
            for url, msg in errors:
                self.console(f"{msg}: {url}")
        self.log_totals("domains", successes, len(checked))
def verify_ssl_domains ( self , connections , request_kw ) : successes = 0 errors = [ ] checked = set ( ) for connection in connections : if connection . skip_cert_verify : self . debug ( f"skipping (verify disabled): {connection.url}" ) continue urlparts = urlparse ( connection . url ) if urlparts . scheme != "https" : if urlparts . scheme == "http" : self . debug ( f"skipping (non-SSL): {connection.url}" ) else : self . debug ( f"skipping (unknown scheme): {connection.url}" ) continue hostname , x , port = urlparts . netloc . partition ( ":" ) if not port : # Key `checked` set by explicit port numbers to avoid duplicate # hits on domains where multiple URLs exist, some with the # port implied and others with port 443 set explicitly. port = IMPLICIT_HTTPS_PORT uniq = ( hostname , int ( port ) ) if uniq in checked : continue checked . add ( uniq ) url = urlunparse ( ( "https" , urlparts . netloc , "/" , "" , "" , "" ) ) self . debug ( f"HEAD {url}" ) try : requests . head ( url , * * request_kw ) successes += 1 except HTTPError : # HTTP errors mean SSL success successes += 1 except SSLError as exc : # SSL errors are the only "failure" mode yield connection , exc except RequestException as exc : # other exceptions are logged as errors, but not reported as # "SSL failures" errors . append ( ( url , exc . __class__ . __name__ ) ) if errors : self . console ( f"WARNING: encountered {len(errors)} request error(s):" , self . style . NOTICE ) for url , msg in errors : self . console ( f"{msg}: {url}" ) self . log_totals ( "domains" , successes , len ( checked ) )