A guide to Oracle Wallet

It is often necessary to make connections to the database from shell scripts held on the filesystem. This can be a major security issue if these scripts contain the database connection details. One solution is to use OS Authentication, but Oracle 10g Release 2 gives us the option of using a secure external password store where the Oracle login credentials are stored in a client-side Oracle wallet. This allows scripts to contain connections using the /@db_alias syntax.

The wallet is simply a directory on the server where the passwords are written (in an encrypted form) by the oracle mkstore commaand. You tell Oracle where to find the wallet by configuring specific parameters in the sqlnet.ora file and you retrieve/use a stored password by referencing a TNS alias configured in your tnsnames.ora file (detailed below). There are no services to start or stop, and nothing to be installed.

Creating a Wallet

Use the mkstore command on an empty directory as follows:

mkdir -p /oracle/admin/DBNAME/wallet
mkstore -wrl /oracle/admin/DBNAME/wallet -create

You will be prompted for a password to secure the wallet. Make sure it is something secure, and record the password in your central password store.

Next, add the following lines to your sqlnet.ora configuration file.


Note: There are implications for both Clusterware and OS authentication when using wallet_override:, so please see the section “Known Issues / Gotchas” at the end of the article)

Adding a username and password to the wallet

Before adding the username and password, we create an alias in the tnsnames.ora file that will be used whenever we want to log in using the stored credentials. Only one password may be stored in the wallet per TNS alias: In our example below, we have created an alias called “DBFS”:

# Connectiong string for DBFS Oracle Wallet

Now to add a username and password to an existing wallet, use the mkstore command with the -createCredential option as follows:

mkstore -wrl <wallet_location> -createCredential <TNS_alias> <username> <password>


mkstore -wrl /oracle/admin/DBNAME/wallet -createCredential DBFS dbfs_admin p@ssw0rd

Testing the Wallet

That’s it, your wallet is created and you’ve stored a username and password inside it. Now all you need to do is test it using the TNS alias you setup (DBFS in our example):

sqlplus /@DBFS

Administering the Wallet

Listing credentials stored in the wallet:

mkstore -wrl <wallet_location> -listCredential

Modifying credentials stored in the wallet:

mkstore -wrl <wallet_location> -modifyCredential <dbase_alias> <username> <password>

Deleting credentials stored in the wallet:

mkstore -wrl <wallet_location> -deleteCredential <db_alias>

Deleting the whole wallet:

rm -rf <wallet_location>

A note on Security

Remember that any user that has access to the wallet can use any password stored in the wallet. Therefore it is recommended that you create one wallet per user, rather than using a common wallet.

To that effect, I would recommend saving a sqlnet.ora and tnsnames.ora configured for wallet access separately from the common oracle TNS configuration. For example we could copy both files to the wallet directory, then set the environmental variable TNS_ADMIN to point to our wallet directory at the start of any script that needs to use the wallet.

Also, it is important to remember that the security of the wallet is only-file-based. Thus the security of the wallet is only marginally better than a hard-coded password within a shell script as both methods depend on OS file and directory permissions for their security. There is nothing to stop an attacker copying the wallet to another machine (if they have read access) and using it to authenticate with the database.

Known Issues  / Gotchas

#1 Using OS Authentication results in ORA-01017: Invalid username/password

If the WALLET_OVERRIDE=TRUE parameter is present in your sqlnet.ora file that any attempt to use OS authentication will result in an ORA-01017 error as shown below:

$ sqlplus /
SQL*Plus: Release - Production on Thu Aug 10 11:37:13 2006
Copyright (c) 1982, 2005, Oracle. All Rights Reserved.
ORA-01017: invalid username/password; logon denied

You cannot connect to Oracle using an external password in conjunction with the secret store. That would defeat the purpose. When using OS Authentication (an external password), your account is already authenticated to Oracle because the operating system has authenticated you. There would be no reason to keep an encrypted set of of credentials for you.

The sqlnet.ora parameter SQLNET.WALLET_OVERRIDE=TRUE is laterally telling Oracle client to use the wallet manager instead of OS Authentication.

If you want to connect to the same database with different accounts, then you would need separate entries in the tnsnames.ora file; however, you should be setting up services for this purpose and creating a new tnsnames.ora entry for each service. Connecting to the SID of the database is a <8i methodology and should not be practiced anymore.

Also, if you are using multiple accounts, each account should have its own wallet anyway. Therefore, they could share a common tnsnames.ora file, but use different credentials based on the entries in the wallet.

#2 Wallet and Grid Infrastructure (Clusterware)

If you add the WALLET_OVERRIDE parameter to the sqlnet.ora file used by the Grid Infrastructure the crsd service will fail during cluster initialisation and the logs will report misleading errors about being unable to read/access the OCR. See metalink Note 1153244.1

(I suspect this is directly related to issue #1 above, and the clusterware is using OS authentication during initialisation).

13 thoughts on “A guide to Oracle Wallet

Add yours

  1. I think you have a typo in this article. Under the “Creating a wallet” section, I believe the second line should be “mkstore”, not “mkdir”.


  2. Thanks for this excellent article!
    Most other articles on the subject forget to mention this very important part: “There is nothing to stop an attacker copying the wallet to another
    machine (if they have read access) and using it to authenticate with the


  3. If i have multiple users for same database (TNS Entry) then how would sqlplus responds.?
    Example:- Database is testdb and the users are test1 and test2 and are created in different wallets as tns name has to be unique per wallet. But how would ‘sqlplus /@testdb’ would respond, which user to will it connect?
    How to handle this multiple user for same database scenario?


      1. Thanks for your reply, it helped me.
        What about sqlldr? It also needs db password to connect and i want sqlldr to get that password from oracle wallet.
        When i used “sqlldr [test1]@testdb
        control = /home/infa_sgo/smarttrial_ODR_setup/sqlldr-add-new.ctl”
        it asked password..But I want to handle everything through shell script. Kindly suggest how to handle this one.
        Thanks in advance…


      2. sqlldr and sqlplus function in the same way, so you need to ensure you are using the correct tnsnames.ora and sqlnet.ora files.

        Is that a typo in your comment?
        [test1]@testdb is not a wallet style connection – it should be /@testdb


  4. Hi, My wallet created successfully but when I am running sqlplus /@pssdb04q command I am getting below error. Can someone help me.

    ORA-01017: invalid username/password; logon denied
    I tried SQLNET.WALLET_OVERRIDE = TRUE/FALSE but still I am getting same error.
    My sqlnet.ora file

    # sqlnet.ora Network Configuration File: /shared/product/12.1.0/client_1/network/admin/sqlnet.ora
    # Generated by Oracle configuration tools.


    #ADR_BASE = /shared

    (SOURCE =
    (DIRECTORY = /shared/oracleWallet)



  5. I dont see any file in the oracle home bin directory of my sql client.
    mksore or orapki
    can someone suggest how do I install wallet utility.
    I am using 12c client.


  6. Hi, I have created wallet (D://Mywallet) with alias name test_Wallet successfully but when I run the sqlplus/@test_Wallet command it gives the error as:
    SQL*Plus: Release Production on Sat Mar 10 16:25:04 2018

    Copyright (c) 1982, 2016, Oracle. All rights reserved.
    ORA-12154: TNS:could not resolve the connect identifier specified

    Enter user-name: Poonam
    Enter password:
    ORA-12543: TNS:destination host unreachable

    I have added following lines in sqlnet.ora file::

    ( SOURCE =
    ( METHOD = FILE)
    ( METHOD_DATA =( DIRECTORY = d:Mywallet)



    Also I have added following lines in the thsnames.ora file:

    test_Wallet =
    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))

    Can anyone tell me whats wrong with this code


    1. The first step would be to check that you can connect using the actual username and password @ test_wallet.
      If that doesn’t work, then the issue is with the entry in your tnsnames.ora file rather than the wallet configuration.
      Note that in the example above, you haven’t specified a value in the SERVICE_NAME section.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Blog at WordPress.com.

Up ↑

%d bloggers like this: