Connect Node.js and other Scripting Languages (mTLS)
You can use programs in different languages, including Python, Node.js, PHP, Ruby, R, Go, and Perl to connect to an Autonomous Database instance using mTLS (with wallets). Security is enforced using client credentials.
These scripting languages have database access APIs or drivers that use the Oracle Call Interface libraries.
Oracle Call Interface (OCI) clients support mTLS authentication with a wallet if you are connecting using the following client versions:
-
Oracle Instant Client/Oracle Database Client: 18.19 (or later), 19.2 (or later), or 21 (base release or later).
For details on connecting Node.js or other scripting languages without a wallet, see Connect Node.js, and Other Scripting Languages Without a Wallet.
For additional details, see the following video:
Install the Language Driver and Client Libraries
To connect to Autonomous Database from your scripting language, first install the language driver and client libraries as follows:
-
Install Oracle Instant Client/Oracle Database Client: 18.19 (or later), 19.2 (or later), or 21 (base release or later).
The Instant Client works well for most applications. To install the Instant Client do the following:
-
Select your desired architecture from the Instant Client Downloads page and download a Basic Package (available on the download page): Oracle Instant Client Downloads.
Alternatively download the Basic Light Package from the download page for your desired architecture if the Basic Light globalization limitations suit your use.
-
If you are building a language API or driver from source code, you may also need to download the Instant Client SDK: Oracle Instant Client
-
Unzip the base package you selected. For example unzip to
C:\instantclient_12_2
or/home/myuser/instantclient_18_5.
If you also download the SDK, unzip it in the same directory. -
On Windows, add the path to the
PATH
variable in the "System variables" section of the Environment Variables pane (for example addC:\instantclient_12_2
). On Windows 8 access thePATH
variable setting area by navigating to Control Panel>System>Advanced System Settings>Environment Variables. If you have multiple versions of Oracle libraries installed make sure the new directory occurs first in the path. -
On non-Windows platforms, create a symbolic link if it does not exist. For example:
cd /home/myuser/instantclient_18_5 ln -s libclntsh.so.18.1 libclntsh.so
If there is no other Oracle software on your system that will be impacted, add Instant Client to the runtime link path. For example:
sudo sh -c "echo /home/myuser/instantclient_18_5 > /etc/ld.so.conf.d/oic.conf" sudo ldconfig
Alternatively set the library path in each shell that runs your application. For example:
export LD_LIBRARY_PATH=/home/myuser/instantclient_18_5:$LD_LIBRARY_PATH
Note
The Linux Instant Client download files are available as.zip
files or.rpm
files. You can use either version.
-
-
Install the relevant language driver for Oracle Database:
-
Node.js : To install node-oracledb for Node.js,, use the instructions on the following page: Installing node-oracledb.
-
ROracle: To install ROracle for R, use the instructions on the following page: ROracle
-
PHP: To install PHP OCI8 for PHP, use the instructions on the following page: Configuring PHP with OCI8.
Windows DLLs are available on http://php.net/downloads.php and are also available from PECL oci8.
-
PHP PDO_OCI: To install PHP PDO_OCI for PHP, use the instructions on the following page: Oracle Functions (PDO_OCI).
Windows DLLs are available on http://php.net/downloads.php included in PHP.
-
Ruby: To install ruby-oci8 for Ruby, use the instructions on the following page: Install for Oracle Instant Client
-
DBD for Perl: To install DBD::Oracle for Perl, set
ORACLE_HOME
and your library search path such asLD_LIBRARY_PATH
orPATH
to the Instant Client directory and use the instructions on the following page: Installing DBD-Oracle. -
Python: For instructions for connecting Python applications, see Connect Python Applications with a Wallet (mTLS)
-
Enable Oracle Network Connectivity and Obtain the Security Credentials (Oracle Wallet)
-
Obtain client security credentials to connect to Autonomous Database. You obtain a zip file containing client security credentials and network configuration settings required to access your database. You must protect this file and its contents to prevent unauthorized database access. Obtain the client security credentials file as follows:
-
ADMIN user: Click Database connection. See Download Client Credentials (Wallets).
-
Other user (non-administrator): Obtain the Oracle Wallet from the administrator for your Autonomous Database.
-
-
Extract the client credentials (wallet) files:
-
Unzip the client credentials zip file.
-
If you are using Instant Client, make a
network/admin
subdirectory hierarchy under the Instant Client directory if necessary. Then move the files to this subdirectory. For example depending on the architecture or your client system and where you installed Instant Client, the files should be in the directory:C:\instantclient_12_2\network\admin
or
/home/myuser/instantclient_18_5/network/admin
or
/usr/lib/oracle/18.5/client64/lib/network/admin
-
If you are using a full Oracle Client move the file to
$ORACLE_HOME/network/admin
.
-
-
Alternatively, put the unzipped wallet files in a secure directory and set the
TNS_ADMIN
environment variable to that directory name.
Note
From the zip file, only these files are required:tnsnames.ora
,sqlnet.ora
,cwallet.sso
, andewallet.p12
. -
-
If you are behind a proxy follow the steps in “Connections with an HTTP Proxy”, in Prepare for Oracle Call Interface, ODBC, and JDBC OCI Connections with Wallets (mTLS).
Run Your Application
-
Update your application to connect using your database username, your password, and the Oracle Net connect name given in the unzipped
tnsnames.ora
file. For example, user,adb_user
, password, anddb2022adb_low
as the connect string. -
Alternatively, change the connect string in
tnsnames.ora
to match the string used by your application. -
Run your application.