ibmdb / python-ibmdb

Automatically exported from code.google.com/p/ibm-db
Apache License 2.0
304 stars 193 forks source link

Bug Report: SQL10013N The specified library "GSKit Error: 2" could not be loaded -> DEPEND ON CONNECTIONS ORDER #883

Closed RomeroGabriel closed 1 year ago

RomeroGabriel commented 1 year ago
import ibm_db

no_certificate_conn = ibm_db.connect("...SECURITY=SSL;...")
certificate_conn = ibm_db.connect("...SECURITY=SSL;SSLServerCertificate=<PATH_TO_CERTIFICATE>;")

Steps to Reproduce:

  1. The first connection should not have SSLServerCertificate set. The second one needs to have;

Context

I have a pipeline that’s encountering a strange issue when connecting to two databases. One database uses SSL but doesn't require a certificate. The other one also uses SSL and requires a .der certificate. ISSUE: If I first connect to .der certificate and then to the other one, I encounter the following error: [IBM][CLI Driver] SQL10013N The specified library "GSKit Error: 2" could not be loaded. SQLSTATE=42724 SQLCODE=-10013. However, if I connect to the one without .der file first there are no issues. This is happing for my macOS work notebook and also for the pipeline's docker image.

FROM python:3.10 as PYTHON_IMAGE

RUN apt-get update -y && \
    apt-get upgrade libp11-kit-dev -y && \
    apt-get upgrade libp11-kit0 -y && \
    apt-get upgrade linux-libc-dev -y && \
    apt-get upgrade libnss3 -y && \
    apt-get upgrade uuid-dev -y && \
    apt-get -y purge mysql* && \
    apt-get install -y git && \
    apt-get clean && \

# Keeps Python from generating .pyc files in the container
ENV PYTHONDONTWRITEBYTECODE=1
# Turns off buffering for easier container logging
ENV PYTHONUNBUFFERED=1

RUN mkdir /ibmdriver
RUN curl https://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/linuxx64_odbc_cli.tar.gz \
  | tar -xzf - -C /ibmdriver/
ENV IBM_DB_HOME /ibmdriver/clidriver
ENV LD_LIBRARY_PATH $LD_LIBRARY_PATH:$IBM_DB_HOME/lib
RUN chmod -R a+r /ibmdriver
RUN chown -R 1001 /ibmdriver

# Install dependecies
COPY ./requirements.txt .
RUN pip install --upgrade pip 
RUN pip install -r requirements.txt

WORKDIR /app
COPY file.der .
COPY ./src ./src

RUN chgrp -R 0 . && chmod -R g=u .
RUN chgrp -R 0 /app && chmod -R g=u /app

Infos

  1. Was tried with pconnect and connect functions;
  2. I can connect just fine with the .der file without another connection;
  3. Yes, I can connect without a certificate file;
  4. I'm a current IBM employee and if necessary contact me more directly;
  5. I have discussed this error on support channels, and is almost sure that is something with the library;
bimalkjha commented 1 year ago

@RomeroGabriel It is a known issue with GSKit library that comes with the downloaded clidriver https://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/linuxx64_odbc_cli.tar.gz. To fix this issue, update your script to download https://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/v11.5.4/linuxx64_odbc_cli.tar.gz. v11.5.4 clidriver do not has this problem. Thanks.

RomeroGabriel commented 1 year ago

@bimalkjha Thanks a lot!!! This really solves the problem.

paullilley commented 7 months ago

NB for those coming to this later the driver linked to above https://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/v11.5.4/linuxx64_odbc_cli.tar.gz is the 32-bit driver

bimalkjha commented 7 months ago

@paullilley How you concluded that its a 32bit driver? I downloaded https://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/v11.5.4/linuxx64_odbc_cli.tar.gz on my linux system, set the PATH and DYLD_LIBRARY_PATH env vars to point to this clidriver and then executed db2level command. It shows, its a 64bit driver. Also, 64bit python and node applications works fine with it.

bjha@qasdevdbctdev05: work/bjha/nodework> db2level
DB21085I  This instance or install (instance name, where applicable: "*") uses
"64" bits and DB2 code release "SQL11054" with level identifier "0605010F".
Informational tokens are "DB2 v11.5.4.0", "s2006161200", "DYN2006161200AMD64",
and Fix Pack "0".
Product is installed at "/work/bjha/nodework/clidriver".

bjha@qasdevdbctdev05: work/bjha/nodework>

So, this driver is 64 bit only. See the above db2level command output from this driver that mentions it is a 64bit driver.

Also, regarding the original issue: We have updated default clidriver at https://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/linuxx64_odbc_cli.tar.gz to Db2 V11.5.9.0 driver that contains fix for GSKit Error: 2 issue. So, no need to download v11.5.4 driver now. Just go with default installation steps. Thanks.

paullilley commented 7 months ago

Ah, my mistake - apologies. Previously I've had problems with libdb2.so vs libdb2o.so. Thanks also for the update of the default driver with fixed GSKit!