Skip to content

If encrypt not specified, escalate if required by default - #606

Closed
ciaranj wants to merge 1 commit into
tediousjs:masterfrom
ciaranj:escalate_to_encrypted_by_default
Closed

ciaranj wants to merge 1 commit into
tediousjs:masterfrom
ciaranj:escalate_to_encrypted_by_default

Conversation

@ciaranj

@ciaranj ciaranj commented Jul 31, 2017 •

Copy link
Copy Markdown
Contributor

Changes the behaviour of the pre-login to automatically try again if the server requires
encryption to be enabled but the user hasn't configured the client in that way.

Still allows for the user to explicitly state that they do not ever want to use
encryption by specifying the value as false. Or to always use and require encryption by setting the value as true.

This commit partially undoes the work done in ceaa8dc and is a change in the behaviour, but brings this driver more inline with other TDS drivers such as jTDS.

…ires it, escalate by default.

Changes the behaviour of the pre-login to automatically try again if the server requires
encryption to be enabled but the user hasn't configured the client in that way.

Still allows for the user to explicitly state that they do not ever want to use
encryption but specifying the value as false.

Partially undoes the work done in ceaa8dc and is a
change in the behaviour, but brings this driver more inline with other TDS
drivers such as jTDS.
@ciaranj

ciaranj commented Jul 31, 2017

Copy link
Copy Markdown
Contributor Author

That thing where you've not worked on a project for so long you discover you're no longer a maintainer ;) doh!

@Suraiya-Hameed

Suraiya-Hameed commented Sep 14, 2017 •

Copy link
Copy Markdown
Member

@ciaranj Did you get to test if retry works? Just noticed that driver sends ENCRYPT_NOT_SUP instead of ENCRYPT_OFF, if encrypt is not enabled.
As per TDS doc (in 2.26.5 Prelogin section), for client with ENCRYPT_NOT_SUP and server with ENCRYPT_ON combination, server response is ENCRYPT_REQ (connection terminated). Curious if this impacts retry.
It would be good if driver could send ENCRYPT_OFF in first attempt and then ENCRYPT_ON on receiving ENCRYPT_REQ, it would make it a bit more compliant with TDS spec.

@ciaranj

ciaranj commented Sep 14, 2017

Copy link
Copy Markdown
Contributor Author

Retry does work definitely. However the server does have errors in the event view, I wonder if that's related :)

@Suraiya-Hameed

Copy link
Copy Markdown
Member

Most likely they are related :) Can you try sending ENCRYPT_OFF in prelogin? Hopefully that will clear the error. I don't foresee any side effects if we make this switch from ENCRYPT_NOT_SUP.

Comment thread src/connection.js
this.debug.log('connection to ' + this.config.server + ':' + this.config.options.port + ' closed');
if (this.state === this.STATE.REROUTING) {
this.debug.log('Rerouting to ' + this.routingData.server + ':' + this.routingData.port);
if (typeof this.routingData !== 'undefined') {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change here seems unrelated? 🤔 If it's not related to the other changes, could you revert this?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, no, I see that you're re-using the re-routing logic here. I'm not sure how I feel about this, but if that's working, why not? 👍

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I had the same feeling if I'm honest, but I traded that against the scale of change I'd need to do to encapsulate a 'reconnect' state change :/

Comment thread src/connection.js
enableArithAbort: false,
enableAnsiNullDefault: true,
encrypt: false,
encrypt: undefined,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 for sane defaults!

Comment thread src/connection.js
this.debug.log('connection to ' + this.config.server + ':' + this.config.options.port + ' closed');
if (this.state === this.STATE.REROUTING) {
this.debug.log('Rerouting to ' + this.routingData.server + ':' + this.routingData.port);
if (typeof this.routingData !== 'undefined') {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, no, I see that you're re-using the re-routing logic here. I'm not sure how I feel about this, but if that's working, why not? 👍

Comment thread src/connection.js
if (this.config.options.encrypt === false) {
this.emit('connect', ConnectionError("Server requires encryption, set 'encrypt' config option to true.", 'EENCRYPT'));
return this.close();
} else if (typeof this.config.options.encrypt === 'undefined') {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about changing the conditions here to be a bit more explicit?

if (this.config.options.encrypt === true) {
  ...
} else if (this.config.options.encrypt === false) {
  ...
} else {
  ...
}

@ciaranj ciaranj Oct 19, 2017 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't mind tbh. Semantically I guess it would still be the same?

@arthurschreiber

Copy link
Copy Markdown
Collaborator

Also, as @v-suhame already suggested, can you change the prelogin payload to send ENCRYPT_OFF?

@ciaranj

ciaranj commented Oct 19, 2017

Copy link
Copy Markdown
Contributor Author

Yeah, it's on my list :/ ( to change the payload)

@arthurschreiber

Copy link
Copy Markdown
Collaborator

Do you think just changing the default for the encrypt option to true would be a simpler and more straightforward fix for this? I don't really see any negative effect of doing this, and I even believe we could do this without bumping the major version. 🤔

@v-suhame What do you think about this ☝️ proposal? It'd solve the same issue as the code in this pull request, but without adding more code to Tedious.

@ciaranj

ciaranj commented Nov 9, 2017

Copy link
Copy Markdown
Contributor Author

Sure thing, it was only done this way so as to not negatively impact any existing consumers of the driver (but you’re right we could rely on semver for that)

@Suraiya-Hameed

Copy link
Copy Markdown
Member

I was on same page as @ciaranj regarding backward compatibility. After some reading, figured its version older than SQL Server 2000 that doesn't support SSL, that hopefully has a very small customer base(or none at all).
It's a thumbs-up for making encrypt true by default.

@arthurschreiber

Copy link
Copy Markdown
Collaborator

This will be solved by #694, as we'll default to an encrypted connection instead. #694 will be part of the next semver-major release of tedious.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants