golang里面自定义tls的ciphers

下面的内容是从stackoverflow上面抄过来的。https://stackoverflow.com/questions/31226131/how-to-set-tls-cipher-for-go-server


You can see an example in secrpc/tls_server.go:

tls.Listen("tcp", addr, &tls.Config{
    Certificates: []tls.Certificate{cert},
    CipherSuites: []uint16{
        tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
        tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
    },
    MinVersion:               tls.VersionTLS12,
    PreferServerCipherSuites: true,
})

See also go/issues/11047 for an example using ListenAndServeTLS: once you have defined your Config, you define your server:

server := &http.Server{Addr: ":4000", Handler: nil, TLSConfig: config}
server.ListenAndServeTLS(tlsPublicKey, tlsPrivateKey)

根据同事的说法,CipherSuites里面不能写得太多,如果你把golang里面支持的那些都给写在里面,那么很可能会导致你的浏览器连接不上。

你可能感兴趣的:(golang里面自定义tls的ciphers)