0

I am attempting to connect to an Oracle Database using Python cx_Oracle package and Oracle instantclient_19_8. I keep getting this error - OORA-29024: Certificate validation failure.

  1. I downloaded and installed Oracle InstantClient_19_8.
  2. Within the [...]instantclient_19_8/network/admin directory, I copied the cwallet.sso and ewallet.p12 files I received from a DBA.
  3. I created a sqlnet.ora file in the network/admin directory:

WALLET_LOCATION = (SOURCE = (METHOD = FILE) (METHOD_DATA = (DIRECTORY = /instantclient_19_8/network/admin) ) ) SQLNET.WALLET_OVERRIDE = TRUE

  1. I created a tnsnames.ora file in the network/admin diretory (though this might not be necessary):

ora_conn = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCPS) (HOST = {HOST}) (PORT = 1525) ) ) (CONNECT_DATA = (SERVICE_NAME = {SVC_NAME) ) )

  1. In Pycharm, I set the TNS_ADMIN environment variable and pointed it to [...]/instantclient_19_8/network/admin.

My Python connection info is:

dsn=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCPS)(HOST={HOST_ADDRESS})(PORT={PORT_NBR})))(CONNECT_DATA=(SERVICE_NAME={SVC_NAME})))

cx_Oracle.init_oracle_client(lib_dir='[...]/instantclient_19_8') 

ora_conn = cx_Oracle.connect(user=usr
                              , password=pw
                              , dsn=dsn
                              , encoding="UTF-8")

cursor = ora_conn.cursor()

I've seen several blog posts about using orapki, but it is not clear how to use orapki with instant client. If the DBA created the wallet, are they the only ones who can add a cert file to the wallet? Or, would I be able to if I got orapki to work?

Any suggestions/guidance would be great!

Thank you!

4

1 回答 1

0

设置DIRECTORY = /instantclient_19_8/network/admin 看起来很可疑。你真的instantclient_19_8在根文件系统中有一个目录吗?我希望看到类似的东西/Users/you/instantclient_19_8/network/admin

但是,由于您将文件移动到默认位置,您甚至不需要编辑 sqlnet.ora。默认的 DIRECTORY 路径(以 开头?)自动工作。当文件位于此默认位置时,您也不需要设置 TNS_ADMIN。

使用像 cx_Oracle 这样的 C 语言代码,您不需要 .p12 文件。您只需要 .sso 文件 sqlnet.ora 和 tnsnames.ora。

cx_Oracle 文档Connecting to Oracle Cloud Autononmous Databases显示了两种选择:当您将钱包文件放在默认位置时,以及当您没有时。

您可能还想查看博客文章如何连接到 Oracle 自治云数据库

于 2021-11-16T21:31:43.087 回答