func splitCertAndKey()

in pkg/provider/provider.go [766:788]


func splitCertAndKey(certAndKey string) (certs string, privKey string) {
	// split the cert and key for PEM format
	// This does not handle the case where cert and key is in PFX format
	// TODO(aramase) consider adding support for PFX format if there is an ask
	var cert, key []byte
	data := []byte(certAndKey)
	for {
		block, rest := pem.Decode(data)
		if block == nil {
			break
		}
		if block.Type == types.CertificateType {
			cert = append(cert, pem.EncodeToMemory(block)...)
		} else {
			key = append(key, pem.EncodeToMemory(block)...)
		}
		data = rest
	}

	certs = string(cert)
	privKey = string(key)
	return certs, privKey
}