Use the crypto/tls package to create secure TLS connections by configuring a tls.Config and wrapping a network connection with tls.Client or tls.Server.
import "crypto/tls"
conn, err := tls.Dial("tcp", "example.com:443", &tls.Config{})
if err != nil {
// handle error
}
// use conn as a net.Conn
- Import the package and define a
tls.Configwith your security settings. - Wrap your network connection using
tls.Clientfor clients ortls.Serverfor servers. - Perform I/O on the returned
net.Connjust like a standard connection.