Connect Go Applications with a Wallet (mTLS)
You can connect Go applications to your Autonomous AI Database instance with a wallet.
Download an Oracle Wallet File
You must download an Oracle Wallet (mTLS) file to obtain client security credentials that enable you to connect to an Autonomous AI Database instance.
-
Download a wallet file from the Autonomous AI Database instance to obtain a compressed file that contains the client security credentials and network configuration settings required to access an Autonomous AI Database instance.
Depending on whether you are an Admin user or a non-Admin user, obtain the client security credentials (wallet.zip file) as follows:
-
ADMIN user: On the Oracle Cloud Infrastructure Console, click Database connection. See Download Client Credentials (Wallets).
-
Other user (non-administrator): Obtain the Oracle Wallet from the administrator for your Autonomous AI Database instance.
Note: Protect the
wallet.zipfile and its contents to prevent unauthorized database access. -
-
Unzip the client credentials file (
wallet.zip).
Run Go Applications with a Wallet (mTLS)
You can connect Go applications to your Autonomous AI Database instance with a wallet. You must download a compressed wallet file from the Autonomous AI Database instance that contains the client security credentials.
The godror driver requires Oracle Client Libraries. See Install Oracle Client Library to use Godror. The Oracle Client libraries are installed where you run the Go Application.
The wallet file is in a compressed archive format. The database service names can be found in the tnsnames.ora file in the compressed wallet file. In the following example, you will use the mydb_high network service name found in the tnsnames.ora file.
The following three files from the compressed wallet file are required:
-
tnsnames.ora: Contains the net service names used for application connection strings and maps the strings to your database services. -
sqlnet.ora: Specifies the SQLNet client side configuration. -
cwallet.sso: Contains the auto open SSO wallet.
Follow these steps to connect your Go application to an Autonomous AI Database instance using a wallet (mTLS):
-
Place the files
tnsnames.ora,sqlnet.ora, andcwallet.ssoon the optional (opt) directory of your Linux system. The /optdirectory is used to install optional or add-on software packages that are not part of the core operating system. You can place the files anywhere on your Microsoft Windows operating system. For example, subdirectory on C drive (C:) of your Microsoft Windows operating system.You can move the files to any accessible directory.
For example, on Linux move the files to the directory
/opt/OracleCloud/MYDBand editsqlnet.orato change the wallet location directory to the directory containing thecwallet.ssofile.For example, on Linux edit
sqlnet.oraas follows:WALLET_LOCATION = (SOURCE = (METHOD=file) (METHOD_DATA = (DIRECTORY="/opt/OracleCloud/MYDB"))) SSL_SERVER_DN_MATCH=yesWhen the configuration files are not in the default location, your Go application needs to indicate where they are with the
config_dirparameter.Note: Neither of these settings are needed, and you do not need to edit
sqlnet.oraif you put all the configuration files in thenetwork/admindirectory. -
In your Go application set the following connection parameters to connect to the Autonomous AI Database instance:
-
user: Specifies the Cloud Database user. -
password: Specifies the Cloud Database user's password. -
config_dir: Specifies the configuration directory where you are placing thetnsnames.oraandsqlnet.orafiles. This is required when the configuration files are placed in a directory outside of the instant client configuration directorynetwork/admin. -
dsn: Specifies the desired network alias from thetnsnames.orafile.
For example, to connect as the ADMIN user and connect with the
mydb_highnetwork service name (where the service name is found in/opt/OracleCloud/MYDB/tnsnames.ora):dsn := `user="admin" password="password" connectString="mydb_high" configDir="/opt/OracleCloud/MYDB"` db, _ := sql.Open("godror", dsn)You can use the previous code in your Go application to create a connection string and connect to the Autonomous AI Database.
-