public static SafeFreeCredentials AcquireCredentialsHandle(ISSPIInterface secModule, string package, Interop.SspiCli.CredentialUse intent, Interop.SspiCli.SCHANNEL_CRED scc) { if (NetEventSource.IsEnabled) { NetEventSource.Enter(null, package); NetEventSource.Log.AcquireCredentialsHandle(package, intent, scc); } SafeFreeCredentials outCredential = null; int errorCode = secModule.AcquireCredentialsHandle( package, intent, ref scc, out outCredential); if (errorCode != 0) { if (NetEventSource.IsEnabled) { NetEventSource.Error(null, SR.Format(SR.net_log_operation_failed_with_error, nameof(AcquireCredentialsHandle), $"0x{errorCode:X}")); } throw new Win32Exception(errorCode); } if (NetEventSource.IsEnabled) { NetEventSource.Exit(null, outCredential); } return(outCredential); }
internal static SecurityPackageInfoClass GetVerifyPackageInfo(ISSPIInterface secModule, string packageName, bool throwIfMissing) { SecurityPackageInfoClass[] supportedSecurityPackages = EnumerateSecurityPackages(secModule); if (supportedSecurityPackages != null) { for (int i = 0; i < supportedSecurityPackages.Length; i++) { if (string.Equals(supportedSecurityPackages[i].Name, packageName, StringComparison.OrdinalIgnoreCase)) { return(supportedSecurityPackages[i]); } } } if (NetEventSource.IsEnabled) { NetEventSource.Log.SspiPackageNotFound(packageName); } if (throwIfMissing) { throw new NotSupportedException(SR.net_securitypackagesupport); } return(null); }
internal static SecurityPackageInfoClass[] EnumerateSecurityPackages(ISSPIInterface secModule) { if (NetEventSource.IsEnabled) { NetEventSource.Enter(null); } if (secModule.SecurityPackages == null) { lock (secModule) { if (secModule.SecurityPackages == null) { int moduleCount = 0; SafeFreeContextBuffer arrayBaseHandle = null; try { int errorCode = secModule.EnumerateSecurityPackages(out moduleCount, out arrayBaseHandle); if (NetEventSource.IsEnabled) { NetEventSource.Info(null, $"arrayBase: {arrayBaseHandle}"); } if (errorCode != 0) { throw new Win32Exception(errorCode); } var securityPackages = new SecurityPackageInfoClass[moduleCount]; int i; for (i = 0; i < moduleCount; i++) { securityPackages[i] = new SecurityPackageInfoClass(arrayBaseHandle, i); if (NetEventSource.IsEnabled) { NetEventSource.Log.EnumerateSecurityPackages(securityPackages[i].Name); } } secModule.SecurityPackages = securityPackages; } finally { arrayBaseHandle?.Dispose(); } } } } if (NetEventSource.IsEnabled) { NetEventSource.Exit(null); } return(secModule.SecurityPackages); }
internal static int AcceptSecurityContext(ISSPIInterface secModule, SafeFreeCredentials credential, ref SafeDeleteSslContext context, Interop.SspiCli.ContextFlags inFlags, Interop.SspiCli.Endianness datarep, ReadOnlySpan <SecurityBuffer> inputBuffers, ref SecurityBuffer outputBuffer, ref Interop.SspiCli.ContextFlags outFlags) { if (NetEventSource.IsEnabled) { NetEventSource.Log.AcceptSecurityContext(credential, context, inFlags); } int errorCode = secModule.AcceptSecurityContext(credential, ref context, inputBuffers, inFlags, datarep, ref outputBuffer, ref outFlags); if (NetEventSource.IsEnabled) { NetEventSource.Log.SecurityContextInputBuffers(nameof(AcceptSecurityContext), inputBuffers.Length, outputBuffer.size, (Interop.SECURITY_STATUS)errorCode); } return(errorCode); }
internal static int InitializeSecurityContext(ISSPIInterface secModule, ref SafeFreeCredentials?credential, ref SafeDeleteSslContext?context, string?targetName, Interop.SspiCli.ContextFlags inFlags, Interop.SspiCli.Endianness datarep, InputSecurityBuffers inputBuffers, ref SecurityBuffer outputBuffer, ref Interop.SspiCli.ContextFlags outFlags) { if (NetEventSource.Log.IsEnabled()) { NetEventSource.Log.InitializeSecurityContext(credential, context, targetName, inFlags); } int errorCode = secModule.InitializeSecurityContext(ref credential, ref context, targetName, inFlags, datarep, inputBuffers, ref outputBuffer, ref outFlags); if (NetEventSource.Log.IsEnabled()) { NetEventSource.Log.SecurityContextInputBuffers(nameof(InitializeSecurityContext), inputBuffers.Count, outputBuffer.size, (Interop.SECURITY_STATUS)errorCode); } return(errorCode); }
public static unsafe SafeFreeCredentials AcquireCredentialsHandle(ISSPIInterface secModule, string package, Interop.SspiCli.CredentialUse intent, Interop.SspiCli.SCH_CREDENTIALS *scc) { int errorCode = secModule.AcquireCredentialsHandle( package, intent, scc, out SafeFreeCredentials outCredential); if (errorCode != 0) { if (NetEventSource.Log.IsEnabled()) { NetEventSource.Error(null, SR.Format(SR.net_log_operation_failed_with_error, nameof(AcquireCredentialsHandle), $"0x{errorCode:X}")); } throw new Win32Exception(errorCode); } return(outCredential); }
public static SafeFreeCredentials AcquireDefaultCredential(ISSPIInterface secModule, string package, Interop.SspiCli.CredentialUse intent) { if (NetEventSource.Log.IsEnabled()) { NetEventSource.Log.AcquireDefaultCredential(package, intent); } SafeFreeCredentials?outCredential = null; int errorCode = secModule.AcquireDefaultCredential(package, intent, out outCredential); if (errorCode != 0) { if (NetEventSource.Log.IsEnabled()) { NetEventSource.Error(null, SR.Format(SR.net_log_operation_failed_with_error, nameof(AcquireDefaultCredential), $"0x{errorCode:X}")); } throw new Win32Exception(errorCode); } return(outCredential); }
public static SafeFreeCredentials AcquireCredentialsHandle(ISSPIInterface secModule, string package, Interop.SspiCli.CredentialUse intent, ref SafeSspiAuthDataHandle authdata) { if (NetEventSource.IsEnabled) { NetEventSource.Log.AcquireCredentialsHandle(package, intent, authdata); } SafeFreeCredentials credentialsHandle = null; int errorCode = secModule.AcquireCredentialsHandle(package, intent, ref authdata, out credentialsHandle); if (errorCode != 0) { if (NetEventSource.IsEnabled) { NetEventSource.Error(null, SR.Format(SR.net_log_operation_failed_with_error, nameof(AcquireCredentialsHandle), $"0x{errorCode:X}")); } throw new Win32Exception(errorCode); } return(credentialsHandle); }
internal static int CompleteAuthToken(ISSPIInterface secModule, ref SafeDeleteSslContext context, in SecurityBuffer inputBuffer)