Skip to content

Cannot connect via encrypted connection to SQL Server 2008 SP2 #610

Closed

Description

@eplowe

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?

Activity

  1. slmmm commented on Aug 31, 2017

    @slmmm

    Have you set your connection options for encrypted before attempting to connect?
    options: {
    encrypt: true
    }

  2. eplowe commented on Aug 31, 2017

    @eplowe
    Author
  3. eplowe commented on Aug 31, 2017

    @eplowe
    Author

    I made a switch over to mssqlnodev8, it connects fine. But, this locks me to using windows boxes only.

  4. Suraiya-Hameed commented on Aug 31, 2017

    @Suraiya-Hameed
    Member

    @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
        }
    }
    
  5. eplowe commented on Aug 31, 2017

    @eplowe
    Author

    Sure thing. See attached.

    debug_output.txt

  6. ferm10n commented on Oct 16, 2017

    @ferm10n

    I'm also experiencing this exact issue. Any assistance for this would be greatly appreciated.

  7. Suraiya-Hameed commented on Oct 26, 2017

    @Suraiya-Hameed
    Member

    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.

  8. ferm10n commented on Oct 26, 2017

    @ferm10n

    @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

  9. Suraiya-Hameed commented on Oct 26, 2017

    @Suraiya-Hameed
    Member

    @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

  10. Suraiya-Hameed commented on Oct 26, 2017

    @Suraiya-Hameed
    Member

    @eplowe @ferm10n can you test the solution suggested?

  11. ferm10n commented on Oct 31, 2017

    @ferm10n

    @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?

  12. Suraiya-Hameed commented on Oct 31, 2017

    @Suraiya-Hameed
    Member

    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.

  13. Suraiya-Hameed commented on Oct 31, 2017

    @Suraiya-Hameed
    Member

    Thanks for testing @ferm10n the solution, I'll close this issue :)

  14. eplowe commented on Oct 31, 2017

    @eplowe
    Author
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions