npgsql: Exception when opening connection using SSPI/GSS authentication from Windows Server 2012 R2 with version 7.0.1
Steps to reproduce
Open a connection using SSPI authentication from a Windows Server 2012 R2 client (or Windows 8.1) using version 7.0.1 of Npgsql.
The issue
Getting an ‘Exception while reading from stream’ when opening a connection using SSPI authentication and version 7.0.1 of Npgsql from a Windows Server 2012 R2 client (or Windows 8.1).
Non-SSPI, ie standard username/password, authentication works fine.
Npgsql version 6.0.8 is unaffected.
Windows 10 clients are unaffected.
Exception message:
Exception while reading from stream
Stack trace:
at Npgsql.Internal.NpgsqlReadBuffer.<Ensure>g__EnsureLong|42_0(NpgsqlReadBuffer buffer, Int32 count, Boolean async, Boolean readingNotifications)
at Npgsql.Internal.NpgsqlConnector.<ReadMessage>g__ReadMessageLong|226_0(NpgsqlConnector connector, Boolean async, DataRowLoadingMode dataRowLoadingMode, Boolean readingNotifications, Boolean isReadingPrependedMessage)
at Npgsql.Internal.NpgsqlConnector.AuthenticateGSS(Boolean async)
at Npgsql.Internal.NpgsqlConnector.Authenticate(String username, NpgsqlTimeout timeout, Boolean async, CancellationToken cancellationToken)
at Npgsql.Internal.NpgsqlConnector.<Open>g__OpenCore|208_1(NpgsqlConnector conn, SslMode sslMode, NpgsqlTimeout timeout, Boolean async, CancellationToken cancellationToken, Boolean isFirstAttempt)
at Npgsql.Internal.NpgsqlConnector.Open(NpgsqlTimeout timeout, Boolean async, CancellationToken cancellationToken)
at Npgsql.PoolingDataSource.OpenNewConnector(NpgsqlConnection conn, NpgsqlTimeout timeout, Boolean async, CancellationToken cancellationToken)
at Npgsql.PoolingDataSource.<Get>g__RentAsync|28_0(NpgsqlConnection conn, NpgsqlTimeout timeout, Boolean async, CancellationToken cancellationToken)
at Npgsql.NpgsqlConnection.<Open>g__OpenAsync|45_0(Boolean async, CancellationToken cancellationToken)
at Npgsql.NpgsqlConnection.Open()
Further technical details
Npgsql version: 7.0.1 .NET version: 7.0.101 PostgreSQL version: 15.1 Operating system: Windows Server 2012 R2 (and also Windows 8.1)
Other details about my project setup: Works fine when not using SSPI. Works fine when connecting from Windows 10 clients. Works fine when using Npgsql version 6.0.8. Also affects Windows 8.1 which I realise is EOL however Windows Server 2012 R2 is supposedly still in support.
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 1
- Comments: 28 (16 by maintainers)
Commits related to this issue
- Fix a possible timeout with gss/sspi auth (#5028) Fixes #4888 — committed to npgsql/npgsql by vonzshik a year ago
- Fix a possible timeout with gss/sspi auth (#5028) Fixes #4888 (cherry picked from commit ae3309f259db536be5ca16a327550f2d654b670c) — committed to npgsql/npgsql by vonzshik a year ago
@vmiwouter and others, can you please try out version 7.0.4-ci.20230407T140348 or above the patch feed, which contains @vonzshik’s fix? Let us know if that resolves the issue - it will be released with 7.0.4.
@vmiwouter OK. The problem with the package with the revert is that there is a typo which leads to this exception. I’ve notified @roji about it.
7.0.4-ci.20230407T140348 works.
Goodjob
Submitted #5028
@roji Here is the console application. Later i will make a VM with an emtpy 15.2 database. ConsoleApp1.zip
FYI I’ve fixed the typo found by @vonzshik (thanks!) and uploaded a rebased RevertGSS version to https://github.com/npgsql/npgsql/releases/tag/v7.0.2.
@vmiwouter and anyone else hitting this, can you please give that package a try and report if it fixes the issue for you?
@vmiwouter could you try with npgsql 7.0.1 (with reverted gss change) @roji linked above?