@@ -297,12 +297,6 @@ public SspiHelper(string securityPackage, string remotePrincipal)
297
297
{
298
298
_securityPackage = securityPackage ;
299
299
_remotePrincipal = remotePrincipal ;
300
- _clientCredentials = new SecHandle ( ) ;
301
- var resCode = AcquireCredentialsHandle ( null , securityPackage , SECPKG_CRED_OUTBOUND ,
302
- IntPtr . Zero , IntPtr . Zero , 0 , IntPtr . Zero ,
303
- out _clientCredentials , out var expiry ) ;
304
- if ( resCode != SEC_E_OK )
305
- throw new Exception ( $ "{ nameof ( AcquireCredentialsHandle ) } failed") ;
306
300
}
307
301
308
302
#endregion
@@ -317,6 +311,7 @@ public byte[] InitializeClientSecurity()
317
311
{
318
312
EnsureDisposed ( ) ;
319
313
CloseClientContext ( ) ;
314
+ InitializeClientCredentials ( ) ;
320
315
_clientContext = new SecHandle ( ) ;
321
316
var clientTokenBuf = new SecBufferDesc ( MAX_TOKEN_SIZE ) ;
322
317
try
@@ -423,6 +418,16 @@ private void Dispose(bool disposing)
423
418
}
424
419
}
425
420
421
+ private void InitializeClientCredentials ( )
422
+ {
423
+ _clientCredentials = new SecHandle ( ) ;
424
+ var resCode = AcquireCredentialsHandle ( null , _securityPackage , SECPKG_CRED_OUTBOUND ,
425
+ IntPtr . Zero , IntPtr . Zero , 0 , IntPtr . Zero ,
426
+ out _clientCredentials , out var expiry ) ;
427
+ if ( resCode != SEC_E_OK )
428
+ throw new Exception ( $ "{ nameof ( AcquireCredentialsHandle ) } failed") ;
429
+ }
430
+
426
431
private void CloseClientContext ( )
427
432
{
428
433
if ( ! _clientContext . IsInvalid )
0 commit comments