Cannot connect via encrypted connection to SQL Server 2008 SP2
My app is trying to connect to SQL Server 2008 SP2. The connections are configured to be encrypted. The connection always times out at the configured connectionTimeout. I've talked to the DBA, and he's seeing the following error:
"The prelogin packet used to open the connection is structurally invalid; the connection has been closed. Please contact the vendor of the client library. [CLIENT: ...]"
Any ideas?
Have you set your connection options for encrypted before attempting to connect? options: { encrypt: true }
I have. When it's false I get a fast fail telling me that the server is configured only to accept encrypted connections.
On Thu, Aug 31, 2017 at 1:11 PM slmmm [email protected] wrote:
Have you set your connection options for encrypted before attempting to connect?
options: { encrypt: true }
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/tediousjs/tedious/issues/610#issuecomment-326361836, or mute the thread https://github.com/notifications/unsubscribe-auth/AAXhfnguWbgiTwqgSEW7LcJ29w5CIWnHks5sdukwgaJpZM4PJIgu .
I made a switch over to mssqlnodev8, it connects fine. But, this locks me to using windows boxes only.
@eplowe try enabling the debug log in driver to get more details. If you need assistance, you can share the logs either in github or via email.
options: {
debug: {
packet: true,
data: true,
payload: true,
token: true,
log: true
}
}
I'm also experiencing this exact issue. Any assistance for this would be greatly appreciated.
SQL Server doesn't respond after successful handshake 😞 One odd thing I noticed while looking at this issue is during Login7, a single packet shows 2 TLS exchange in wireshark, for SQL Server 2008. This would need more investigation.
@v-suhame the server not responding after the handshake seemed to be happening to me too. I also saw 2 TLS exchanges in wireshark. This makes me think that's what is causing the "structurally invalid" error, since it's only supposed to be sending a single Login7 packet.
How did you gather this from looking at debug_output.txt referenced above?
I found Microsoft Message Analyzer to be more helpful than wireshark with better parsing of TDS messages. https://technet.microsoft.com/en-us/library/dn727244.aspx
@ferm10n I couldn't gather much from the debug_output.txt. I had an instance of SQL Server 2008 in internal test lab, I was able to repro it there 😉, and +1 for informing about Microsoft Message Analyzer, that will come handy.
After some digging, I found that cipher suite negotiated during handshake is not supported in SQL Server 2008, possibly for versions < SQL Server 2008 SP4, as they only support TLSv1.0, details here.
Specifying proper cipher suite in config does the trick, e.g.
options: {
cryptoCredentialsDetails: { ciphers: 'RC4-MD5' }
}
List of supported specs: https://msdn.microsoft.com/en-us/library/aa380512.aspx https://msdn.microsoft.com/en-us/library/aa380124.aspx
--Updates--
Cipher name to use in config for the specs in the link above is in https://www.openssl.org/docs/man1.0.2/apps/ciphers.html#CIPHER-SUITE-NAMES
@eplowe @ferm10n can you test the solution suggested?
@v-suhame Thank you very much! That did the trick. It's interesting that it negotiates to use a cipher suite that isn't supported. Any idea why that happens?
Yes, it is weird! I couldn't dig much as it was taken care by the tls package and SQL Server, nothing to do with Tedious directly.
Thanks for testing @ferm10n the solution, I'll close this issue :)
This worked for me! Thank you!
On Thu, Oct 26, 2017 at 5:56 PM Suraiya Hameed [email protected] wrote:
@ferm10n https://github.com/ferm10n I couldn't gather much from the debug_output.txt. I had an instance of SQL Server 2008 in internal test lab, I was able to repro it there 😉 After some digging, I found that cipher suite negotiated during handshake is not supported in SQL Server 2008, possibly for versions < SQL Server 2008 SP4, as they only support TLSv1.0, details here https://support.microsoft.com/en-ca/help/3135244/tls-1-2-support-for-microsoft-sql-server .
Specifying proper cipher suite in config does the trick, e.g.
options: { cryptoCredentialsDetails: { ciphers: 'RC4-MD5' } }List of supported suites: https://msdn.microsoft.com/en-us/library/aa380512.aspx https://msdn.microsoft.com/en-us/library/aa380124.aspx
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/tediousjs/tedious/issues/610#issuecomment-339812682, or mute the thread https://github.com/notifications/unsubscribe-auth/AAXhfn0rEy5OXTVD_N_d2KtETdxap86wks5swQAUgaJpZM4PJIgu .