Commit 0cc72e5
authored
🌱 refactor(tls) use IANA cipher suite names instead of OpenSSL names (#218)
* refactor(tls): use IANA cipher suite names instead of OpenSSL names
Switch cipherMap keys and cipherIDToName output from OpenSSL-style
(e.g. ECDHE-RSA-AES128-GCM-SHA256) to IANA format
(e.g. TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256), which matches what
Go's crypto/tls package uses.
cipherIDToName now looks up the name from tls.CipherSuites() and
tls.InsecureCipherSuites() by ID instead of reverse-iterating cipherMap,
so the returned name is always the authoritative Go/IANA name.
Update tests and README accordingly.
Signed-off-by: zhujian <jiazhu@redhat.com>
* refactor(tls): drop cipherMap, use Go's cipher suite lists directly
Replace the hand-maintained cipherMap allowlist with direct lookups
against tls.CipherSuites() and tls.InsecureCipherSuites():
- Secure ciphers are accepted silently
- Insecure ciphers are accepted but logged via klog.Warningf
- Unrecognized names are still rejected (existing behavior)
This removes the maintenance burden of keeping cipherMap in sync with
Go's cipher suite lists, and automatically picks up new secure ciphers
added in future Go releases. Previously excluded insecure ciphers
(RC4-based, TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA) are now accepted with
a warning instead of being silently rejected.
Signed-off-by: zhujian <jiazhu@redhat.com>
* perf(tls): build cipher lookup maps once at init time
Replace per-call tls.CipherSuites()/InsecureCipherSuites() iterations
with three package-level maps built in init():
secureCiphersByName map[string]uint16 -- name→ID for secure suites
insecureCiphersByName map[string]uint16 -- name→ID for insecure suites
cipherNamesByID map[uint16]string -- ID→name for all suites
parseCipherSuites now does O(1) map lookups instead of O(n) linear
scans, and no longer needs the findCipherID helper.
cipherIDToName is reduced to a single map lookup with no allocation.
Signed-off-by: zhujian <jiazhu@redhat.com>
* fix(tls): address CodeRabbit review comments
- ConfigFromFlags: trim whitespace from minVersion and cipherSuites
before the empty check so whitespace-only flag values are treated
as absent
- tls_test.go: remove `expectedLen > 0` guard on CipherSuites length
assertions so zero-length expectations are also verified
Signed-off-by: zhujian <jiazhu@redhat.com>
---------
Signed-off-by: zhujian <jiazhu@redhat.com>1 parent 9cbb733 commit 0cc72e5
4 files changed
Lines changed: 85 additions & 72 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
25 | | - | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| |||
108 | 109 | | |
109 | 110 | | |
110 | 111 | | |
111 | | - | |
| 112 | + | |
112 | 113 | | |
113 | 114 | | |
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
7 | 9 | | |
8 | 10 | | |
9 | 11 | | |
| |||
20 | 22 | | |
21 | 23 | | |
22 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
23 | 57 | | |
24 | 58 | | |
25 | 59 | | |
| |||
44 | 78 | | |
45 | 79 | | |
46 | 80 | | |
47 | | - | |
48 | | - | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
49 | 85 | | |
50 | 86 | | |
51 | 87 | | |
| |||
61 | 97 | | |
62 | 98 | | |
63 | 99 | | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
68 | 103 | | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
69 | 110 | | |
70 | 111 | | |
71 | 112 | | |
| |||
81 | 122 | | |
82 | 123 | | |
83 | 124 | | |
| 125 | + | |
| 126 | + | |
84 | 127 | | |
85 | 128 | | |
86 | 129 | | |
| |||
126 | 169 | | |
127 | 170 | | |
128 | 171 | | |
129 | | - | |
| 172 | + | |
130 | 173 | | |
131 | 174 | | |
132 | 175 | | |
| |||
160 | 203 | | |
161 | 204 | | |
162 | 205 | | |
163 | | - | |
| 206 | + | |
164 | 207 | | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
| 208 | + | |
171 | 209 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
72 | | - | |
| 72 | + | |
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
80 | | - | |
| 80 | + | |
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
94 | | - | |
| 94 | + | |
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
100 | | - | |
| 100 | + | |
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
108 | | - | |
| 108 | + | |
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
| |||
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
146 | | - | |
| 146 | + | |
147 | 147 | | |
148 | 148 | | |
149 | 149 | | |
| |||
212 | 212 | | |
213 | 213 | | |
214 | 214 | | |
215 | | - | |
| 215 | + | |
216 | 216 | | |
217 | 217 | | |
218 | 218 | | |
219 | 219 | | |
220 | 220 | | |
221 | 221 | | |
222 | 222 | | |
223 | | - | |
| 223 | + | |
224 | 224 | | |
225 | 225 | | |
226 | 226 | | |
| |||
229 | 229 | | |
230 | 230 | | |
231 | 231 | | |
232 | | - | |
| 232 | + | |
233 | 233 | | |
234 | 234 | | |
235 | 235 | | |
| |||
387 | 387 | | |
388 | 388 | | |
389 | 389 | | |
390 | | - | |
| 390 | + | |
391 | 391 | | |
392 | 392 | | |
393 | 393 | | |
| |||
441 | 441 | | |
442 | 442 | | |
443 | 443 | | |
444 | | - | |
| 444 | + | |
445 | 445 | | |
446 | 446 | | |
447 | 447 | | |
| |||
535 | 535 | | |
536 | 536 | | |
537 | 537 | | |
538 | | - | |
| 538 | + | |
539 | 539 | | |
540 | 540 | | |
541 | 541 | | |
| |||
888 | 888 | | |
889 | 889 | | |
890 | 890 | | |
891 | | - | |
| 891 | + | |
892 | 892 | | |
893 | 893 | | |
894 | 894 | | |
895 | 895 | | |
896 | | - | |
| 896 | + | |
897 | 897 | | |
898 | 898 | | |
899 | 899 | | |
| |||
904 | 904 | | |
905 | 905 | | |
906 | 906 | | |
907 | | - | |
| 907 | + | |
908 | 908 | | |
909 | 909 | | |
910 | 910 | | |
911 | 911 | | |
912 | 912 | | |
913 | | - | |
| 913 | + | |
914 | 914 | | |
915 | 915 | | |
916 | 916 | | |
917 | 917 | | |
918 | | - | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
919 | 929 | | |
920 | 930 | | |
921 | 931 | | |
| |||
944 | 954 | | |
945 | 955 | | |
946 | 956 | | |
947 | | - | |
| 957 | + | |
948 | 958 | | |
949 | 959 | | |
950 | 960 | | |
| |||
0 commit comments