Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send TDS version 8 in Login7 when in strict mode #1870

Merged
merged 3 commits into from
Jul 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions src/main/java/com/microsoft/sqlserver/jdbc/IOBuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,11 @@ private ExtendedSocketOptions() {}


final class TDS {
// TDS protocol versions
static final String VER_TDS80 = "tds/8.0"; // TLS-first connections
// application protocol
static final String PROTOCOL_TDS80 = "tds/8.0"; // TLS-first connections

// TDS versions
static final int VER_TDS80 = 0x8000000; // TDS 8.0
static final int VER_DENALI = 0x74000004; // TDS 7.4
static final int VER_KATMAI = 0x730B0003; // TDS 7.3B(includes null bit compression)
static final int VER_YUKON = 0x72090002; // TDS 7.2
Expand Down Expand Up @@ -1768,7 +1770,7 @@ else if (con.getTrustManagerClass() != null) {

// set ALPN values
SSLParameters sslParam = sslSocket.getSSLParameters();
sslParam.setApplicationProtocols(new String[] {TDS.VER_TDS80});
sslParam.setApplicationProtocols(new String[] {TDS.PROTOCOL_TDS80});
sslSocket.setSSLParameters(sslParam);
} else {
// don't close proxy when SSL socket is closed
Expand All @@ -1793,9 +1795,9 @@ else if (con.getTrustManagerClass() != null) {

// check negotiated ALPN
if (null != negotiatedProtocol && !(negotiatedProtocol.isEmpty())
&& negotiatedProtocol.compareToIgnoreCase(TDS.VER_TDS80) != 0) {
&& negotiatedProtocol.compareToIgnoreCase(TDS.PROTOCOL_TDS80) != 0) {
MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_ALPNFailed"));
Object[] msgArgs = {TDS.VER_TDS80, negotiatedProtocol};
Object[] msgArgs = {TDS.PROTOCOL_TDS80, negotiatedProtocol};
con.terminate(SQLServerException.DRIVER_ERROR_SSL_FAILED, form.format(msgArgs));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6037,8 +6037,11 @@ final boolean complete(LogonCommand logonCommand, TDSReader tdsReader) throws SQ
byte netAddress[] = new byte[6];
int dataLen = 0;

// TDS version 8 if strict mode
// Denali --> TDS 7.4, Katmai (10.0) & later 7.3B, Prelogin disconnects anything older
if (serverMajorVersion >= 11) {
if (encryptOption.compareToIgnoreCase(EncryptOption.Strict.toString()) == 0) {
tdsVersion = TDS.VER_TDS80;
} else if (serverMajorVersion >= 11) {
tdsVersion = TDS.VER_DENALI;
} else if (serverMajorVersion >= 10) {
tdsVersion = TDS.VER_KATMAI;
Expand Down