下面的內(nèi)容是從stackoverflow上面抄過(guò)來(lái)的。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)
根據(jù)同事的說(shuō)法,CipherSuites里面不能寫得太多,如果你把golang里面支持的那些都給寫在里面,那么很可能會(huì)導(dǎo)致你的瀏覽器連接不上。