code: def load_x509_certificates(buf):
    
    if not isinstance(buf, basestring):
      raise ValueError('`buf` should be an instance of `basestring` not `%s`' % type(buf))
  
    for pem in re.findall('(-----BEGIN CERTIFICATE-----\s(\S+\n*)+\s-----END CERTIFICATE-----\s)', buf):
      yield load_certificate(crypto.FILETYPE_PEM, pem[0])
docs: Load one or multiple X.509 certificates from a buffer.
  
    :param str buf: A buffer is an instance of `basestring` and can contain multiple
      certificates.
    :return: An iterator that iterates over certificates in a buffer.
    :rtype: list[:class:`OpenSSL.crypto.X509`]