-
Notifications
You must be signed in to change notification settings - Fork 438
Encrypted connection fails to connect when using SQL Server instance's IP address and custom Common Name (CN) in server certificate. #1388
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
Comments
Hi @jsimonweb, can you try to set the encrypt=false if this is not a hard restriction for you server? See if that works. I found a thread that may related to why "encrypt = true" may not works here: #903 (comment). |
Hi @jsimonweb, we did a bit more digging, and find that we do have a serverName. However, it is not really handled properly. We will make a fix for this and will let you know when the change is ready. |
Checking back in on this issue.. any updates? |
Hi @jsimonweb, I just raised a PR #1476, can you give it a try, see if this solve the your issue? |
I tested this PR but it does not appear to resolve the issue. Here are the steps I used to test the PR. Added PR to package.json$ npm install $ nano package-lock.json
Confirm that PR code is being used with npm list$ npm list --depth=1 │ └── tedious@0.0.0-dev (git+ssh://git@github.com/tediousjs/tedious.git#838a8c118133ff45dbd29ea00f060d7aa227bb75) Code snippet (from modified connect-tcp.js file) being run
Run the sample app$ npm start
|
Expected behavior:
Secure connection should succeed if a valid server certificate is provided along with a custom Common Name (CN) which matches a Common Name (CN) present in the server certificate.
Actual behavior:
Google Cloud SQL for SQL Server generated SSL server certificates include a Common Name (CN) formatted as:
project-id:instance-id
Example snippet from a generated SSL server certificate:
CN = my-project:test-sqlserver
When I attempt to make a tedious/node-mssql based connection to the SQL Server instance using its assigned IP Address along with setting
encrypt=true
andtrustServerCertificate=false
, while providing a server certificate, the connection fails with the error:This is a result of the SSL server certificate having the common name (CN)
my-project:test-sqlserver
which doesn't match the IP address set for theconfig.server
setting. I attempted settingconfig.options.serverName = "my-project:test-sqlserver"
to provide the common name (CN) to be used for the server certificate verification process but got the same connection error.Setting
trustServerCertificate=true
enables the connection to succeed and work as expected (confirming that the other non-SSL configuration values are valid).Configuration:
Software versions:
NodeJS: >=10.0.0
node-mssql: ^7.0.0 https://github.com/tediousjs/node-mssql
SQL Server: SQL Server 2017 Standard
The text was updated successfully, but these errors were encountered: