Test for version support (SNI/non-SNI), get all SANs, get certificate details
        :param sni: True will call cause _exec_openssl to call openssl with -servername flag
196172
async def _execute_ssl_data_extraction(self, sni=False):
        
        # Do for all responses
        responses = await self._run_openssl_sclient_cmd(self._base_script, sni)
        tls_dict = self._parse_openssl_sclient_output(responses)
        # Do for one successful SSL response
        for res in responses:
            if self._is_certificate_exists(res):
                tls_dict["SANs"] = await self._get_sans_from_openssl_cmd(res)
                tls_dict["Certificate_details"] = await self._extract_certificate_details(res)
                break

        return tls_dict
1230626
def _certifi_where_for_ssl_version():
    
    if not ssl:
        return

    if ssl.OPENSSL_VERSION_INFO < (1, 0, 2):
        warnings.warn(
            'You are using an outdated version of OpenSSL that '
            'can\'t use stronger root certificates.')
        return certifi.old_where()

    return certifi.where()
531564
def get_cas_client(service_url=None, request=None):
    
    # Handle CAS_SERVER_URL without protocol and hostname
    server_url = django_settings.CAS_SERVER_URL
    if server_url and request and server_url.startswith('/'):
        scheme = request.META.get("X-Forwarded-Proto", request.scheme)
        server_url = scheme + "://" + request.META['HTTP_HOST'] + server_url
    # assert server_url.startswith('http'), "settings.CAS_SERVER_URL invalid"

    if not django_settings.CAS_VERIFY_SSL_CERTIFICATE:
        warnings.warn(
            "`CAS_VERIFY_SSL_CERTIFICATE` is disabled, meaning that SSL certificates "
            "are not being verified by a certificate authority. This can expose your "
            "system to various attacks and should _never_ be disabled in a production "
            "environment."
        )

    return CASClient(
        service_url=service_url,
        version=django_settings.CAS_VERSION,
        server_url=server_url,
        extra_login_params=django_settings.CAS_EXTRA_LOGIN_PARAMS,
        renew=django_settings.CAS_RENEW,
        username_attribute=django_settings.CAS_USERNAME_ATTRIBUTE,
        proxy_callback=django_settings.CAS_PROXY_CALLBACK,
        verify_ssl_certificate=django_settings.CAS_VERIFY_SSL_CERTIFICATE
    )
336539
def get_browser_versions(browser, verify_ssl=True):
    
    html = get(
        settings.BROWSER_BASE_PAGE.format(browser=quote_plus(browser)),
        verify_ssl=verify_ssl,
    )
    html = html.decode('iso-8859-1')
    html = html.split('<div id=\'liste\'>')[1]
    html = html.split('</div>')[0]

    pattern = r'\?id=\d+\'>(.+?)</a'
    browsers_iter = re.finditer(pattern, html, re.UNICODE)

    browsers = []

    for browser in browsers_iter:
        if 'more' in browser.group(1).lower():
            continue

        browsers.append(browser.group(1))

        if len(browsers) == settings.BROWSERS_COUNT_LIMIT:
            break

    if not browsers:
        raise FakeUserAgentError(
            'No browsers version found for {browser}'.format(browser=browser))

    return browsers
965557
def get_iscsi_initiator_info(self):
        
        headers, bios_uri, bios_settings = self._check_bios_resource()
        if('links' in bios_settings and 'iScsi' in bios_settings['links']):
            iscsi_uri = bios_settings['links']['iScsi']['href']
            status, headers, iscsi_settings = self._rest_get(iscsi_uri)

            if status != 200:
                msg = self._get_extended_error(iscsi_settings)
                raise exception.IloError(msg)
            return iscsi_settings['iSCSIInitiatorName']
        else:
            msg = ('"links/iScsi" section in bios '
                   'does not exist')
            raise exception.IloCommandNotSupportedError(msg)
877785
def get_stored_cert_serials(store):
    '''
    
    '''
    cmd = "certutil.exe -store {0}".format(store)
    out = __salt__['cmd.run'](cmd)
    # match serial numbers by header position to work with multiple languages
    matches = re.findall(r"={16}\r\n.*:\s*(\w*)\r\n", out)
    return matches
118681
def get_arch_string():
    
    '''
    rc, stdout, stderr = exec_command('uname -sm')
    if rc > 0:
        raise AssertionError('Error checking OS')

    stdout = stdout.lower().strip()
    if not 'linux' in stdout:
        raise AssertionError('Unsupported OS')

    if 'armv7l' in stdout:
        return 'arm'

    if 'x86_64' in stdout:
        nv_rc, nv_stdout, nv_stderr = exec_command('nvidia-smi')
        nv_stdout = nv_stdout.lower().strip()
        if 'NVIDIA-SMI' in nv_stdout:
            return 'gpu'
        else:
            return 'cpu'

    raise AssertionError('Unsupported arch:', stdout)
1012124
def is_ssl_error(error=None):
    """"""
    exc_types = (ssl.SSLError,)
    try:
        from OpenSSL.SSL import Error

        exc_types += (Error,)
    except ImportError:
        pass

    if error is None:
        error = sys.exc_info()[1]
    return isinstance(error, exc_types)
1121234
def _get_certificate_obj(cert):
    '''
    
    '''
    if isinstance(cert, M2Crypto.X509.X509):
        return cert

    text = _text_or_file(cert)
    text = get_pem_entry(text, pem_type='CERTIFICATE')
    return M2Crypto.X509.load_cert_string(text)
867537
def _get_ssl_opts():
    '''
    
    '''
    sslopts = __salt__['config.option']('cassandra').get('ssl_options', None)
    ssl_opts = {}

    if sslopts:
        ssl_opts['ca_certs'] = sslopts['ca_certs']
        if SSL_VERSION in sslopts:
            if not sslopts[SSL_VERSION].startswith('PROTOCOL_'):
                valid_opts = ', '.join(
                    [x for x in dir(ssl) if x.startswith('PROTOCOL_')]
                )
                raise CommandExecutionError('Invalid protocol_version '
                                            'specified! '
                                            'Please make sure '
                                            'that the ssl protocol'
                                            'version is one from the SSL'
                                            'module. '
                                            'Valid options are '
                                            '{0}'.format(valid_opts))
            else:
                ssl_opts[SSL_VERSION] = \
                    getattr(ssl, sslopts[SSL_VERSION])
        return ssl_opts
    else:
        return None
423114
def _get_cached_certs(cert_uri, cache):
  
  certs = cache.get(cert_uri, namespace=_CERT_NAMESPACE)
  if certs is None:
    _logger.debug('Cert cache miss for %s', cert_uri)
    try:
      result = urlfetch.fetch(cert_uri)
    except AssertionError:
      # This happens in unit tests.  Act as if we couldn't get any certs.
      return None

    if result.status_code == 200:
      certs = json.loads(result.content)
      expiration_time_seconds = _get_cert_expiration_time(result.headers)
      if expiration_time_seconds:
        cache.set(cert_uri, certs, time=expiration_time_seconds,
                  namespace=_CERT_NAMESPACE)
    else:
      _logger.error(
          'Certs not available, HTTP request returned %d', result.status_code)

  return certs
1200802
def call_openssl(cmd, message, silent=False):
    
    if silent:
        with open(os.devnull, 'w') as devnull:
            return subprocess.check_call(cmd, shell=True, stdout=devnull,
                                         stderr=subprocess.STDOUT)
    else:
        print message
        return subprocess.check_call(cmd, shell=True)
1353428
def version():
    '''
    
    '''
    cmd = 'dnsmasq -v'
    out = __salt__['cmd.run'](cmd).splitlines()
    comps = out[0].split()
    return comps[2]
353914
def get_cert_file():
    
    try:
        current_path = os.path.realpath(__file__)
        ca_cert_path = os.path.join(current_path, "..", "..", "..",
                                    "conf", "cacert.pem")
        return os.path.abspath(ca_cert_path)
    except Exception:
        return None
521314
def get_version():
    
    reg = re.compile(r'__version__ = [\'"]([^\'"]*)[\'"]')
    with open('requests_kerberos/__init__.py') as fd:
        matches = list(filter(lambda x: x, map(reg.match, fd)))

    if not matches:
        raise RuntimeError(
            'Could not find the version information for requests_kerberos'
            )

    return matches[0].group(1)
401418
def system_info(url, auth, verify_ssl):
    
    sysinfo_response = requests.get(url + '/info', headers=X_REQ_BY, auth=auth, verify=verify_ssl)
    sysinfo_response.raise_for_status()
    return sysinfo_response.json()
1140342
def verifyCertificate(self, name):
        
        certPath = os.path.join(self.basePath, self.DIR_CERTS, '%s.cert.pem' % name)
        if not os.path.isfile(certPath):
            raise ValueError('Certificate [%s] not found' % certPath)
        if subprocess.call([ 'openssl', 'x509', '-noout', '-text', '-in', certPath ]) != 0:
            raise ValueError('Failed to verify the certificate')