1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Oracle Databaseの認証情報をTextファイルに保存するのは止めましょう! -外部パスワード・ストア活用のすすめ-

Last updated at Posted at 2022-02-07

外部パスワード・ストアとは

Oracle Databaseへ接続するための認証情報を保存した外部のWalletファイルになります。
外部パスワード・ストアを作成すると認証情報をそこから読み取るので、以下のようにバッチスクリプトなどにパスワードを書く必要がなくなり、セキュリティの向上につながります。

$sqlplus /@<接続識別子>
もしくは
SQL> connect /@<接続識別子>

上記に付随して、パスワードを変更してもスクリプトの修正が不要となる利点もあります。
また外部パスワード・ストアには暗号化された状態で認証情報が保存されます。

ちなみに私は19cの環境で試しましたが、機能自体は10gR2からあります。
19cのマニュアルは以下になります。
安全性の高い外部パスワード・ストアについて

利用手順

最初にWalletファイルを作成するため mkstore コマンドを実行します。
パスの部分は環境に合わせて変更してください。

$ mkstore -wrl /u01/app/oracle/product/19.0.0/dbhome_1/network/admin/wallet/ -create
Oracle Secret Store Tool Release 19.0.0.0.0 - Production
19.3.0.0.0: バージョン{1}
Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved.

パスワードの入力:
パスワードの再入力:

無事に作成できますと指定したディレクトリ配下に以下のファイルが作成されます。

  • cwallet.sso
  • cwallet.sso.lck
  • ewallet.p12
  • ewallet.p12.lck

作成したWalletファイルにデータベースの認証情報を保存します。
この際も mkstore コマンドを実行します。

$ mkstore -wrl /u01/app/oracle/product/19.0.0/dbhome_1/network/admin/wallet/ -createCredential TSTPDB1 test
Oracle Secret Store Tool Release 19.0.0.0.0 - Production
19.3.0.0.0: バージョン{1}
Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved.

コマンド・ラインでシークレット/パスワードが欠落しています
シークレット/パスワード入力:
シークレット/パスワード再入力:
ウォレット・パスワードを入力してください:

パスには作成したWalletファイルまでのパスを、createCredentialオプションには「接続識別子」と接続に使う「ユーザ名」を指定します。
コマンドを実行するとパスワードの入力を求められるので、指定したユーザのパスワードを入力します。
最後にWalletファイルに設定したパスワードを入力します。

続いて sqlnet.ora に以下を追記します。

WALLET_LOCATION =
  (SOURCE =
    (METHOD = FILE)
    (METHOD_DATA =
  (DIRECTORY = /u01/app/oracle/product/19.0.0/dbhome_1/network/admin/wallet)
  )
 )
SQLNET.WALLET_OVERRIDE = TRUE

DIRECTORY にて指定するパスはWalletファイルの配置先を指定します。
これで準備が整いました。
外部パスワード・ストアを利用して接続してみます。

$ sqlplus /@TSTPDB1

以上になります。
セキュリティ向上のために是非ご活用ください。

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?