ibmdb / vscode-extension

vscode extenstion for db2 as db2connect
7 stars 2 forks source link

Cannot connect to DB2 LUW with SSL #41

Closed dorudumitru-hh closed 2 years ago

dorudumitru-hh commented 2 years ago

When trying to connect to a database that requires a SSL connection this happens: Screenshot 2022-02-28 at 08 05 25

I tried connecting with both Option 1 and Option 3 Ex Option 1: DATABASE=mydb;HOSTNAME=myhost;UID=myuser;PWD=mypass;PORT=51000;PROTOCOL=TCPIP;Security=SSL;SSLServerCertificate=/absolute/path/to/cert

When trying to connect to a database that does not require a SSL connection everything is fine.

amukherjee28 commented 2 years ago

@dorudumitru-hh I am checking on this. I have acquired a similar configured mac system to reproduce the issue. Will have an update once tested.

Thanks

amukherjee28 commented 2 years ago

@dorudumitru-hh

I was able to reproduce the problem. So this issue is seen in mac new OS Monterey and above with respect to the changes made in the internal library of the mac. The library thats causing the issue is libstdc++.6.dylib.

Since the system library is missing the soft link we are shipping this library as part of the clidriver package and now in case of node because of library loading issue this causes a problem.

While we are yet to find a permanent solution to this, you can try the following work around which will allow you to work with SSL connection strings.

  1. Remove the library libstdc++.6.dylib from the clidriver lib folder. You may navigate to following path /Users/USERNAME/.vscode/extensions/ibm.db2connect-2.3.0/node_modules/ibm_db/installer/clidriver/lib. Use terminal to navigate to the path and folder may not show directory starting with dot(.). Once you are in this path rename the library libstdc++.6.dylib to something else like libstdc++.6.dylib_bkp

  2. Once you do this we are all set to go. Restart the vscode session and try the SSL connection. Things should fine for you. Please let me know if this works for you now.

dorudumitru-hh commented 2 years ago

@amukherjee28 thanks for looking into this.

I know about this workaround from node ibm_db and I already tried it. It works fine in my node apps but not here. If a rename the lib libstdc++.6.dylib located in /Users/USERNAME/.vscode/extensions/ibm.db2connect-2.3.0/node_modules/ibm_db/installer/clidriver/lib and try a SSL connection I get this in vscode status bar

Screenshot 2022-03-02 at 13 42 50

I waited for about 15 minutes before giving up.

dorudumitru-hh commented 2 years ago

@amukherjee28 thanks for looking into this.

I know about this workaround from node ibm_db and I already tried it. It works fine in my node apps but not here. If a rename the lib libstdc++.6.dylib located in /Users/USERNAME/.vscode/extensions/ibm.db2connect-2.3.0/node_modules/ibm_db/installer/clidriver/lib and try a SSL connection I get this in vscode status bar

Screenshot 2022-03-02 at 13 42 50

I waited for about 15 minutes before giving up.

I hit the connect button and forgot about vscode, and now, 3 hours later, it's working fine. Don't know exactly what happened.

amukherjee28 commented 2 years ago

Its good to know that you are already aware of the work around for now. Coming to time taken for the driver to establish the connection, it depends on multiple things.

It is very difficult to determine as to what exactly caused the delay in the connection to the server. However you may try multiple times to check if the communication with the server is really that slow.

To cross check you can also try connecting to the same server using the same SSL server certificate via a simple node application. Ideally vscode uses the same logic to establish the connection.

But with the change in the clidriver library we are able to avoid the error previously faced.

dorudumitru-hh commented 2 years ago

I think the issue comes from the database I'm trying to connect. It has hundreds of schemas and if the extension is scanning all of those schemas on the first connection it takes a long time. After the first connection I assume that it does some caching and that's why the waiting period disappears. If this is the issue, maybe it will be useful to add an optional "schema" field in the profile so the connection will go directly to that schema, avoiding scanning everything else.

Thanks a lot for all the help.

amukherjee28 commented 2 years ago

Yes that is quite possible, as VSCODE extension not only connects to the server but also runs META DATA query on the databases to fetch the details from the database and populate the same in the tree view. If the connected server is heavily loaded with Schema, functions, Stored Procedures, routines and others we can expect a time in running all the queries and loading them in the tree view.

If this resolved this issue please close the issue.