Tuesday, December 30, 2025

Secure password storage for SQL*Plus

Create the C:\Program Files\instantclient\mkstore.bat

@echo off
rem inspiration: https://andriydmytrenko.wordpress.com/2013/07/01/using-the-secure-external-password-store-with-instant-client/

setlocal

rem get the command line arguments
set args=
:loop
  if !%1==! goto :done
  set args=%args% %1
  shift
  goto :loop
:done

rem set classpath for mkstore - align this to your local SQLcl installation
set sqlcl="C:\Program Files\sqldeveloper\sqldeveloper\lib"
set classpath=%sqlcl%\oraclepki.jar
set classpath=%classpath%;%sqlcl%\osdt_core.jar
set classpath=%classpath%;%sqlcl%\osdt_cert.jar

rem simulate mkstore command
java -classpath %classpath% oracle.security.pki.OracleSecretStoreTextUI %args%

endlocal

Create the wallet and store the credential

mdkir "C:\oracle_wallets"
mkstore -wrl "C:\oracle_wallets" -create
mkstore -wrl "C:\oracle_wallets" -createCredential paris chiup XXXXXXXX
mkstore -wrl "C:\oracle_wallets" -listCredential

Create C:\Program Files\instantclient\network\admin\sqlnet.ora

WALLET_LOCATION =
  (SOURCE =
    (METHOD = FILE)
    (METHOD_DATA =
      (DIRECTORY = C:\oracle_wallets)
    )
  )
SQLNET.WALLET_OVERRIDE = TRUE

Test it with SQL*Plus

sqlplus /@paris

No comments:

Post a Comment