code: func ParsePEMBundle(bundle []byte) ([]*x509.Certificate, error) {
  	var certificates []*x509.Certificate
  	var certDERBlock *pem.Block
  
  	for {
  		certDERBlock, bundle = pem.Decode(bundle)
  		if certDERBlock == nil {
  			break
  		}
  
  		if certDERBlock.Type == "CERTIFICATE" {
  			cert, err := x509.ParseCertificate(certDERBlock.Bytes)
  			if err != nil {
  				return nil, err
  			}
  			certificates = append(certificates, cert)
  		}
  	}
  
  	if len(certificates) == 0 {
  		return nil, errors.New("no certificates were found while parsing the bundle")
  	}
  
  	return certificates, nil
  }
docs: // ParsePEMBundle parses a certificate bundle from top to bottom and returns
  // a slice of x509 certificates. This function will error if no certificates are found.