A tls.Certificate often stores a certificate chain - in other words,> 1 certificate. Note that the Certificate field is of type [][]byte , where each certificate is []byte .
The tls package imports the x509 package, so there is no function in x509 to receive tls.Certificate; which will cause the import loop. But if you have x509.Certificate certificate, you already have tls.Certificate; just put x509.Certificate Raw bytes in tls.Certificate Certificate slice.
source share