This repository was archived by the owner on Jan 23, 2023. It is now read-only.
Commit 0b989eb
David Shulman
Fix Kerberos/NTLM for multiple domain/realm environments in Linux
This PR addresses some issues reported by a customer (not thru GitHub). They noticed that
multiple domain scenarios were working in .NET Core 2.0 but broke in .NET Core 2.1 on Linux
While the previous PR #35383 solved the Negotiate Kerberos to NTLM fallback issue,
it added more complexity than necessary. The retry logic I added wasn't really necessary
because the original code that used GSS_KRB5_NT_PRINCIPAL_NAME format for the target name
was wrong. That logic only works for pure Kerberos environments and doesn't handle domain
or realm referrals. So, it only handles the default Kerberos realm on the the single Linux
client. In addition, using GSS_KRB5_NT_PRINCIPAL_NAME defeats the logic of the SPNEGO mechanism.
That is why I originally needed to add the retry logic using GSS_C_NT_HOSTBASED_SERVICE format
for the target name.
The multiple domain/realm scenario worked in .NET Core 2.0 because it used CurlHandler.
And libcurl always uses GSS_C_NT_HOSTBASED_SERVICE format for target name.
This PR reworks the logic to use the GSS_C_NT_HOSTBASED_SERVICE format. It also removes the
now unneeded retry logic. I tested this against Windows and Linux as well as pure Kerberos
and Kerberos to NTLM fallback (using SPNEGO).
I added more tests. These tests are currently part of the enterprise scenario tests we are
building. They are activated via environment variables.
By definining all of the environment variables below, I am able to run the System.Net.Security
and System.Net.Http enterprise-scenario tests. Both SocketsHttpHandler in System.Net.Http and
NegotiateStream in System.Net.Security use the same common GSS-API logic in CoreFx.
Define domain-joined server remote endpoint:
* COREFX_NET_SECURITY_NEGOSERVERURI
* COREFX_DOMAINJOINED_HTTPHOST
* COREFX_NET_AD_DOMAINNAME
* COREFX_NET_AD_PASSWORD
* COREFX_NET_AD_USERNAME
Define standalone server remote endpoint:
* COREFX_NET_SERVER_PASSWORD
* COREFX_NET_SERVER_USERNAME
* COREFX_WINDOWSSERVER_HTTPHOST1 parent 3178158 commit 0b989eb
File tree
7 files changed
+79
-120
lines changed- src
- Common/src
- Interop/Unix/System.Net.Security.Native
- Microsoft/Win32/SafeHandles
- System/Net/Security
- Unix
- Native/Unix/System.Net.Security.Native
- System.Net.Http/tests/FunctionalTests
7 files changed
+79
-120
lines changedLines changed: 1 addition & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
45 | 44 | | |
46 | 45 | | |
47 | 46 | | |
| |||
77 | 76 | | |
78 | 77 | | |
79 | 78 | | |
80 | | - | |
81 | | - | |
82 | | - | |
| 79 | + | |
83 | 80 | | |
84 | 81 | | |
85 | 82 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
| 40 | + | |
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| |||
Lines changed: 4 additions & 18 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
102 | | - | |
103 | | - | |
104 | | - | |
| 102 | + | |
105 | 103 | | |
106 | 104 | | |
107 | 105 | | |
| |||
143 | 141 | | |
144 | 142 | | |
145 | 143 | | |
146 | | - | |
147 | | - | |
148 | | - | |
| 144 | + | |
149 | 145 | | |
150 | 146 | | |
151 | 147 | | |
| |||
180 | 176 | | |
181 | 177 | | |
182 | 178 | | |
183 | | - | |
184 | 179 | | |
185 | 180 | | |
186 | 181 | | |
| |||
190 | 185 | | |
191 | 186 | | |
192 | 187 | | |
193 | | - | |
194 | 188 | | |
195 | 189 | | |
196 | 190 | | |
| |||
207 | 201 | | |
208 | 202 | | |
209 | 203 | | |
210 | | - | |
211 | | - | |
212 | | - | |
| 204 | + | |
213 | 205 | | |
214 | 206 | | |
215 | 207 | | |
216 | 208 | | |
217 | 209 | | |
218 | 210 | | |
219 | | - | |
| 211 | + | |
220 | 212 | | |
221 | 213 | | |
222 | 214 | | |
223 | 215 | | |
224 | 216 | | |
225 | 217 | | |
226 | 218 | | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | 219 | | |
234 | 220 | | |
235 | 221 | | |
| |||
Lines changed: 11 additions & 30 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
16 | | - | |
| 15 | + | |
17 | 16 | | |
18 | | - | |
19 | 17 | | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
| 18 | + | |
| 19 | + | |
34 | 20 | | |
35 | | - | |
36 | | - | |
| 21 | + | |
37 | 22 | | |
38 | 23 | | |
39 | 24 | | |
| |||
53 | 38 | | |
54 | 39 | | |
55 | 40 | | |
56 | | - | |
57 | | - | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
58 | 45 | | |
59 | 46 | | |
60 | 47 | | |
| |||
84 | 71 | | |
85 | 72 | | |
86 | 73 | | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
| 74 | + | |
94 | 75 | | |
95 | | - | |
96 | | - | |
| 76 | + | |
| 77 | + | |
97 | 78 | | |
98 | 79 | | |
99 | 80 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
147 | 147 | | |
148 | 148 | | |
149 | 149 | | |
150 | | - | |
151 | 150 | | |
152 | 151 | | |
153 | 152 | | |
154 | 153 | | |
155 | | - | |
156 | 154 | | |
157 | 155 | | |
158 | 156 | | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | 157 | | |
171 | | - | |
| 158 | + | |
172 | 159 | | |
173 | 160 | | |
174 | 161 | | |
| |||
177 | 164 | | |
178 | 165 | | |
179 | 166 | | |
180 | | - | |
181 | | - | |
182 | | - | |
| 167 | + | |
183 | 168 | | |
184 | 169 | | |
185 | 170 | | |
| |||
190 | 175 | | |
191 | 176 | | |
192 | 177 | | |
193 | | - | |
194 | | - | |
195 | | - | |
| 178 | + | |
196 | 179 | | |
197 | 180 | | |
198 | 181 | | |
| |||
203 | 186 | | |
204 | 187 | | |
205 | 188 | | |
| 189 | + | |
206 | 190 | | |
207 | 191 | | |
208 | 192 | | |
| |||
212 | 196 | | |
213 | 197 | | |
214 | 198 | | |
215 | | - | |
216 | | - | |
217 | 199 | | |
| 200 | + | |
218 | 201 | | |
219 | 202 | | |
220 | 203 | | |
| |||
226 | 209 | | |
227 | 210 | | |
228 | 211 | | |
229 | | - | |
230 | 212 | | |
231 | 213 | | |
232 | | - | |
233 | 214 | | |
234 | 215 | | |
235 | 216 | | |
| |||
242 | 223 | | |
243 | 224 | | |
244 | 225 | | |
245 | | - | |
246 | | - | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
247 | 241 | | |
248 | | - | |
| 242 | + | |
249 | 243 | | |
250 | | - | |
| 244 | + | |
251 | 245 | | |
252 | | - | |
| 246 | + | |
253 | 247 | | |
254 | | - | |
255 | | - | |
256 | | - | |
257 | | - | |
258 | | - | |
259 | | - | |
260 | | - | |
261 | | - | |
262 | | - | |
263 | | - | |
264 | | - | |
265 | | - | |
266 | | - | |
267 | | - | |
268 | | - | |
269 | | - | |
270 | | - | |
271 | | - | |
272 | | - | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | | - | |
277 | | - | |
278 | | - | |
279 | | - | |
280 | | - | |
281 | | - | |
282 | | - | |
283 | | - | |
284 | | - | |
285 | | - | |
| 248 | + | |
286 | 249 | | |
287 | | - | |
| 250 | + | |
288 | 251 | | |
289 | 252 | | |
290 | 253 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
85 | | - | |
86 | 85 | | |
87 | 86 | | |
88 | 87 | | |
| |||
110 | 109 | | |
111 | 110 | | |
112 | 111 | | |
113 | | - | |
114 | | - | |
115 | | - | |
| 112 | + | |
116 | 113 | | |
117 | 114 | | |
118 | 115 | | |
| |||
Lines changed: 35 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
522 | 522 | | |
523 | 523 | | |
524 | 524 | | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
525 | 560 | | |
526 | 561 | | |
527 | 562 | | |
| |||
0 commit comments