code: func ReadCertificateChain(certificateChainBytes []byte) ([]*x509.Certificate, error) {
  	// build the certificate chain next
  	var certificateBlock *pem.Block
  	var remainingBytes []byte = bytes.TrimSpace(certificateChainBytes)
  	var certificateChain [][]byte
  
  	for {
  		certificateBlock, remainingBytes = pem.Decode(remainingBytes)
  		if certificateBlock == nil || certificateBlock.Type != pemBlockCertificate {
  			return nil, trace.NotFound("no PEM data found")
  		}
  		certificateChain = append(certificateChain, certificateBlock.Bytes)
  
  		if len(remainingBytes) == 0 {
  			break
  		}
  	}
  
  	// build a concatenated certificate chain
  	var buf bytes.Buffer
  	for _, cc := range certificateChain {
  		_, err := buf.Write(cc)
  		if err != nil {
  			return nil, trace.Wrap(err)
  		}
  	}
  
  	// parse the chain and get a slice of x509.Certificates.
  	x509Chain, err := x509.ParseCertificates(buf.Bytes())
  	if err != nil {
  		return nil, trace.Wrap(err)
  	}
  
  	return x509Chain, nil
  }
docs: // ReadCertificateChain parses PEM encoded bytes that can contain one or
  // multiple certificates and returns a slice of x509.Certificate.