Returns a dict containing details of a all certificates matching a glob

    glob_path:
        A path to certificates to be read and returned.

    CLI Example:

    .. code-block:: bash

        salt '*' x509.read_certificates "/etc/pki/*.crt"
429430
def read_certificates(glob_path):
    '''
    
    '''
    ret = {}

    for path in glob.glob(glob_path):
        if os.path.isfile(path):
            try:
                ret[path] = read_certificate(certificate=path)
            except ValueError as err:
                log.debug('Unable to read certificate %s: %s', path, err)

    return ret
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
318607
def read_certificate(self, certificate_name):

        '''
            
        '''

        title = '%s.read_certificate' % self.__class__.__name__

    # validate inputs
        input_fields = {
            'certificate_name': certificate_name
        }
        for key, value in input_fields.items():
            object_title = '%s(%s=%s)' % (title, key, str(value))
            self.fields.validate(value, '.%s' % key, object_title)

    # verify existence of server certificate
        if not certificate_name in self.certificate_list:
            self.printer_on = False
            self.list_certificates()
            self.printer_on = True
            if not certificate_name in self.certificate_list:
                raise Exception('\nServer certificate %s does not exist.' % certificate_name)

    # send request for certificate details
        try:
            cert_kwargs = { 'ServerCertificateName': certificate_name }
            response = self.connection.get_server_certificate(**cert_kwargs)
        except:
            raise AWSConnectionError(title)

    # construct certificate details from response
        from labpack.records.time import labDT
        from labpack.parsing.conversion import camelcase_to_lowercase
        cert_dict = response['ServerCertificate']
        cert_details = camelcase_to_lowercase(cert_dict)
        for key, value in cert_details['server_certificate_metadata'].item():
            cert_details.update(**{key:value})
        del cert_details['server_certificate_metadata']
        date_time = cert_details['expiration']
        epoch_time = labDT(date_time).epoch()
        cert_details['expiration'] = epoch_time

        return cert_details
934532
def search_certificate(self, hash):
        
        c = CensysCertificates(api_id=self.__uid, api_secret=self.__api_key)
        return c.view(hash)
511038
def get_default_ca_certs():
    
    # pylint: disable=protected-access
    if not hasattr(get_default_ca_certs, '_path'):
        for path in get_default_ca_cert_paths():
            if os.path.exists(path):
                get_default_ca_certs._path = path
                break
        else:
            get_default_ca_certs._path = None
    return get_default_ca_certs._path
727158
def get_certificates_der_v2(self):
        

        if self._v2_signing_data == None:
            self.parse_v2_signing_block()

        certs = []
        for signed_data in [signer.signed_data for signer in self._v2_signing_data]:
            for cert in signed_data.certificates:
                certs.append(cert)

        return certs
541108
def get_ssl_context(private_key, certificate):
    
    if (
        certificate
        and os.path.isfile(certificate)
        and private_key
        and os.path.isfile(private_key)
    ):
        context = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)
        context.load_cert_chain(certificate, private_key)
        return context
    return None
918381
def glob(self):
		
		matches = []
		for root, dirnames, filenames in os.walk(self.path):
			if not self.recursive:
				while len(dirnames) > 0:
					dirnames.pop()
			for include in self.include:
				for filename in fnmatch.filter(filenames, include):
					matches.append(os.path.join(root, filename))
		return matches
352423
function readCertificateDataFromFile ({ keyFile, certFile, caFile }) {
  let key, cert, ca;

  if (keyFile) {
    key = fs.readFileSync(keyFile);
  }

  if (certFile) {
    cert = fs.readFileSync(certFile);
  }

  if (caFile) {
    ca = fs.readFileSync(caFile);
  }

  return { key, cert, ca };
}
850220
def get_certificate(self, filename):
        
        cert = self.get_certificate_der(filename)
        certificate = x509.Certificate.load(cert)

        return certificate
88078
def certs(self):
        
        certstack = libcrypto.CMS_get1_certs(self.ptr)
        if certstack is None:
            raise CMSError("getting certs")
        return StackOfX509(ptr=certstack, disposable=True)
180748
def key_str(self, match):
        '''
        
        '''
        ret = {}
        for status, keys in six.iteritems(self.name_match(match)):
            ret[status] = {}
            for key in salt.utils.data.sorted_ignorecase(keys):
                path = os.path.join(self.opts['pki_dir'], status, key)
                with salt.utils.files.fopen(path, 'r') as fp_:
                    ret[status][key] = \
                        salt.utils.stringutils.to_unicode(fp_.read())
        return ret
381379
def load_cert_chain(chain_file):
    
    if hasattr(chain_file, 'read'):
        cert_chain = chain_file.read() 
    else:
        with open(chain_file, 'rb') as f:
            cert_chain = f.read()       
    
    if not cert_chain:
        raise ValueError('Certificate chain file is empty!')

    cert_type_matches = []
    for match in _PEM_RE.finditer(cert_chain):
        cert_type_matches.append((match.group(1), match.group(0)))
    
    if not cert_type_matches:
        raise ValueError('No certificate types were found. Valid types '
            'are: {}'.format(CERT_TYPES))

    return cert_type_matches
691843
def get_cert_serial(cert_file):
    '''
    
    '''
    cmd = "certutil.exe -silent -verify {0}".format(cert_file)
    out = __salt__['cmd.run'](cmd)
    # match serial number by paragraph to work with multiple languages
    matches = re.search(r":\s*(\w*)\r\n\r\n", out)
    if matches is not None:
        return matches.groups()[0].strip()
    else:
        return None
1265172
def find_ca_bundle():
    """"""
    extant_cert_paths = filter(os.path.isfile, cert_paths)
    return (
        get_win_certfile()
        or next(extant_cert_paths, None)
        or _certifi_where()
    )
801979
def getCaCerts(self):
        '''
        
        '''
        retn = []

        path = s_common.genpath(self.certdir, 'cas')

        for name in os.listdir(path):
            if not name.endswith('.crt'):
                continue

            full = s_common.genpath(self.certdir, 'cas', name)
            retn.append(self._loadCertPath(full))

        return retn
850436
def __search_ca_path(self):
        
        if "X509_CERT_DIR" in os.environ:
            self._ca_path = os.environ['X509_CERT_DIR']

        elif os.path.exists('/etc/grid-security/certificates'):
            self._ca_path = '/etc/grid-security/certificates'

        else:
            raise ClientAuthException("Could not find a valid CA path")