Commit b16da37
authored
util: update AdvancedTlsX509KeyManager to support key alias for reloaded cert (#12686)
## Overview
Make the alias in `AdvancedTlsX509KeyManager` dynamic so it can be used
with Netty's `OpenSslCachingX509KeyManagerFactory` to update key
material after reload.
Fixes #12670
Fixes #12485
## Problem
When using `SslProvider.OPENSSL`, each TLS handshake must encode Java
key material into a native buffer consumed by OpenSSL, which can account
for ~8% of server CPU. Netty's `OpenSslCachingX509KeyManagerFactory`
avoids this by caching the encoded buffer keyed by alias — but the
previous implementation always returned `"default"`, so the factory
could never detect credential rotations and create a new cache entry on
cert reload.
## Details
- The alias is now set to `key-<N>` (e.g. `key-1`, `key-2`, ...) and
incremented on every `updateIdentityCredentials` call, ensuring the
same alias always maps to the same key material.
- One prior key value is kept to allow consistent handshaking during key
changes.1 parent 0e39b29 commit b16da37
File tree
3 files changed
+114
-36
lines changed- netty/src/test/java/io/grpc/netty
- util/src
- main/java/io/grpc/util
- test/java/io/grpc/util
3 files changed
+114
-36
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
436 | 436 | | |
437 | 437 | | |
438 | 438 | | |
439 | | - | |
| 439 | + | |
440 | 440 | | |
441 | | - | |
442 | | - | |
443 | | - | |
444 | | - | |
445 | | - | |
446 | | - | |
447 | | - | |
448 | | - | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
449 | 446 | | |
450 | 447 | | |
451 | 448 | | |
| |||
Lines changed: 57 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
35 | 36 | | |
36 | 37 | | |
37 | 38 | | |
| |||
40 | 41 | | |
41 | 42 | | |
42 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
43 | 49 | | |
44 | 50 | | |
45 | 51 | | |
46 | 52 | | |
47 | | - | |
48 | | - | |
49 | | - | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
50 | 68 | | |
51 | 69 | | |
52 | 70 | | |
53 | | - | |
54 | | - | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
55 | 77 | | |
56 | 78 | | |
57 | 79 | | |
58 | 80 | | |
59 | 81 | | |
60 | 82 | | |
61 | | - | |
62 | | - | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
63 | 89 | | |
64 | 90 | | |
65 | 91 | | |
66 | 92 | | |
67 | 93 | | |
68 | 94 | | |
69 | | - | |
| 95 | + | |
| 96 | + | |
70 | 97 | | |
71 | 98 | | |
72 | 99 | | |
73 | 100 | | |
74 | | - | |
| 101 | + | |
75 | 102 | | |
76 | 103 | | |
77 | 104 | | |
78 | 105 | | |
79 | | - | |
| 106 | + | |
80 | 107 | | |
81 | 108 | | |
82 | 109 | | |
83 | 110 | | |
84 | | - | |
| 111 | + | |
| 112 | + | |
85 | 113 | | |
86 | 114 | | |
87 | 115 | | |
88 | 116 | | |
89 | | - | |
| 117 | + | |
90 | 118 | | |
91 | 119 | | |
92 | 120 | | |
93 | 121 | | |
94 | 122 | | |
95 | | - | |
| 123 | + | |
96 | 124 | | |
97 | 125 | | |
98 | 126 | | |
| |||
116 | 144 | | |
117 | 145 | | |
118 | 146 | | |
119 | | - | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
120 | 150 | | |
121 | 151 | | |
122 | 152 | | |
| |||
218 | 248 | | |
219 | 249 | | |
220 | 250 | | |
| 251 | + | |
221 | 252 | | |
222 | | - | |
| 253 | + | |
223 | 254 | | |
224 | 255 | | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
225 | 267 | | |
226 | 268 | | |
227 | 269 | | |
| |||
309 | 351 | | |
310 | 352 | | |
311 | 353 | | |
312 | | - | |
| |||
Lines changed: 51 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
48 | 49 | | |
49 | 50 | | |
50 | 51 | | |
51 | | - | |
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
| 82 | + | |
82 | 83 | | |
83 | | - | |
84 | | - | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
85 | 88 | | |
86 | 89 | | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
91 | 99 | | |
92 | | - | |
93 | | - | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
94 | 105 | | |
95 | 106 | | |
96 | | - | |
97 | | - | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
98 | 138 | | |
99 | 139 | | |
100 | 140 | | |
| |||
0 commit comments