@@ -44,10 +44,25 @@ func (t TLSInfo) AuthType() string {
4444 return "tls"
4545}
4646
47+ // cipherSuiteLookup returns the string version of a TLS cipher suite ID.
48+ func cipherSuiteLookup (cipherSuiteID uint16 ) string {
49+ for _ , s := range tls .CipherSuites () {
50+ if s .ID == cipherSuiteID {
51+ return s .Name
52+ }
53+ }
54+ for _ , s := range tls .InsecureCipherSuites () {
55+ if s .ID == cipherSuiteID {
56+ return s .Name
57+ }
58+ }
59+ return fmt .Sprintf ("unknown ID: %v" , cipherSuiteID )
60+ }
61+
4762// GetSecurityValue returns security info requested by channelz.
4863func (t TLSInfo ) GetSecurityValue () ChannelzSecurityValue {
4964 v := & TLSChannelzSecurityValue {
50- StandardName : cipherSuiteLookup [ t .State .CipherSuite ] ,
65+ StandardName : cipherSuiteLookup ( t .State .CipherSuite ) ,
5166 }
5267 // Currently there's no way to get LocalCertificate info from tls package.
5368 if len (t .State .PeerCertificates ) > 0 {
@@ -205,32 +220,3 @@ type TLSChannelzSecurityValue struct {
205220 LocalCertificate []byte
206221 RemoteCertificate []byte
207222}
208-
209- var cipherSuiteLookup = map [uint16 ]string {
210- tls .TLS_RSA_WITH_RC4_128_SHA : "TLS_RSA_WITH_RC4_128_SHA" ,
211- tls .TLS_RSA_WITH_3DES_EDE_CBC_SHA : "TLS_RSA_WITH_3DES_EDE_CBC_SHA" ,
212- tls .TLS_RSA_WITH_AES_128_CBC_SHA : "TLS_RSA_WITH_AES_128_CBC_SHA" ,
213- tls .TLS_RSA_WITH_AES_256_CBC_SHA : "TLS_RSA_WITH_AES_256_CBC_SHA" ,
214- tls .TLS_RSA_WITH_AES_128_GCM_SHA256 : "TLS_RSA_WITH_AES_128_GCM_SHA256" ,
215- tls .TLS_RSA_WITH_AES_256_GCM_SHA384 : "TLS_RSA_WITH_AES_256_GCM_SHA384" ,
216- tls .TLS_ECDHE_ECDSA_WITH_RC4_128_SHA : "TLS_ECDHE_ECDSA_WITH_RC4_128_SHA" ,
217- tls .TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA : "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA" ,
218- tls .TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA : "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA" ,
219- tls .TLS_ECDHE_RSA_WITH_RC4_128_SHA : "TLS_ECDHE_RSA_WITH_RC4_128_SHA" ,
220- tls .TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA : "TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA" ,
221- tls .TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA : "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA" ,
222- tls .TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA : "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA" ,
223- tls .TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 : "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256" ,
224- tls .TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 : "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256" ,
225- tls .TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 : "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384" ,
226- tls .TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 : "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384" ,
227- tls .TLS_FALLBACK_SCSV : "TLS_FALLBACK_SCSV" ,
228- tls .TLS_RSA_WITH_AES_128_CBC_SHA256 : "TLS_RSA_WITH_AES_128_CBC_SHA256" ,
229- tls .TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 : "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256" ,
230- tls .TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 : "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256" ,
231- tls .TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305 : "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305" ,
232- tls .TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305 : "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305" ,
233- tls .TLS_AES_128_GCM_SHA256 : "TLS_AES_128_GCM_SHA256" ,
234- tls .TLS_AES_256_GCM_SHA384 : "TLS_AES_256_GCM_SHA384" ,
235- tls .TLS_CHACHA20_POLY1305_SHA256 : "TLS_CHACHA20_POLY1305_SHA256" ,
236- }
0 commit comments