Encrypting the database password

To add extra security to your Crowd instance, you can encrypt the database password that is stored in the crowd.cfg.xml file used by Crowd to access your database.

Crowd supports encryption using the AES algorithm.

はじめる前に

JSON オブジェクトを準備する

You need to provide all arguments required to encrypt your password in a JSON object. Prepare it beforehand using the following information and example.

フィールド説明
plainTextPaswordPassword in plain text
algorithmAES/CBC/PKCS5Padding
algorithmKeyAES
View example JSON object
{"plainTextPassword":"yourPassword","algorithm":"AES/CBC/PKCS5PADDING","algorithmKey":"AES"}

Encrypting the password

Complete the following steps to encrypt the password.

Step 1: Encrypt the password

  1. <Crowd-installation-directory> に移動します。

  2. 次のコマンドを実行してパスワードを暗号化します。以下に示すオプションのパラメータを使用することもできます。 

    java -cp "./*" com.atlassian.db.config.password.tools.CipherTool -c com.atlassian.db.config.password.ciphers.algorithm.AesOnlyAlgorithmCipher
  3. After running the command, you'll be asked to provide the required arguments in a JSON object. You can read more about them in the Before you begin section.

View optional parameters
  • -- silent -s: ロギングを最小限に制限します

  • -- help -h: すべてのパラメータを含むヘルプ メッセージを出力します

  • -- mode -m: パスワードの処理方法を暗号化または 復号化に定義します。省略した場合は "暗号化" が使用されます。

  • -- password -p: 必要な引数を持つ JSON オブジェクト。省略した場合、入力を求められます。パスワードが履歴に保存されないように、このパラメータを省略することをおすすめします。

暗号化ツールによって、パスワードの暗号化に使用された 3 つのファイルが生成され、後に crowd.cfg.xml ファイルに追加する出力 JSON オブジェクトが出力されました。

Step 2: Secure the generated files

Move the files generated by the tool to a place that’s accessible in a multi-node configuration and that won’t be overwritten by an upgrade (e.g. ${crowd_home}/shared/keys/db), and change them to read-only. Crowd needs to be able to access and read those files to decrypt your password and connect to the database.

次のファイルが生成されています。

  • javax.crypto.SealedObject_[timestamp]  
    File with the encrypted password.
  • javax.crypto.spec.SecretKeySpec_[timestamp] 
    パスワードの暗号化に使用されたキー。このファイルは、パスワードを復号化するために必要です。
  • java.security.AlgorithmParameters_[timestamp]
    Algorithm parameters used to encrypt your password. You will need this file only if you wanted to recreate an encrypted password. 

Step 3: Add the encrypted password to crowd.cfg.xml

Add the output JSON object to the crowd.cfg.xml file, replacing your current password.

  1. Go to Crowd home directory and back up the crowd.cfg.xml file. Move the backup to a safe place outside of your Crowd server.

  2. crowd.cfg.xml ファイルを編集します。

  3. Replace the "hibernate.connection.password" property with the output JSON object. Adjust the JSON object based on the following examples:

    • UNIX Make sure to update the paths included in the snippet. The output should look like on the following example: 

      <property name="jdbc.password.decrypter.classname">com.atlassian.db.config.password.ciphers.algorithm.AesOnlyAlgorithmCipher</property>
      <property name="hibernate.connection.password">{"sealedObjectFilePath":"<Crowd-home-directory>/shared/keys/db/javax.crypto.SealedObject_1666647204564","keyFilePath":"<Crowd-home-directory>/shared/keys/db/javax.crypto.spec.SecretKeySpec_1666647204521"}</property>

    • WINDOWS Make sure to update the paths included in the snippet. You need to additionally escape the file paths and change double quotes (") surrounding the path to single quotes (') to avoid JSON parsing errors. The paths should look like the following example: 

      <property name="jdbc.password.decrypter.classname">com.atlassian.db.config.password.ciphers.algorithm.AesOnlyAlgorithmCipher</property>
      <property name="hibernate.connection.password">{"sealedObjectFilePath":"<Crowd-home-directory>/shared/keys/db/javax.crypto.SealedObject_1666647204564","keyFilePath":"<Crowd-home-directory>/shared/keys/db/javax.crypto.spec.SecretKeySpec_1666647204521"}</property>
  4. Restart Crowd.

パスワードの復号化

パスワードを復号化するには、-m decrypt パラメータを使用してコマンドを拡張します。

java -cp "./*" com.atlassian.db.config.password.tools.CipherTool -c com.atlassian.db.config.password.ciphers.algorithm.AesOnlyAlgorithmCipher -m decrypt

JSON オブジェクトを求められたら、crowd.cfg.xml ファイルのいずれかのオブジェクトを指定します。

SAMPLE JSON OBJECT WHEN USING FILE PATHS
{"sealedObjectFilePath":"<Crowd-home-directory>/shared/keys/db/javax.crypto.SealedObject_1666647204564","keyFilePath":"<Crowd-home-directory>/shared/keys/db/javax.crypto.spec.SecretKeySpec_1666647204521"}

暗号化されたパスワードの再作成

When you lose the encrypted password and encrypt the plain text password again, the new encrypted password will look differently. That’s not an issue, as it will still represent the same plain text password. However, in some cases, you might want to re-create an encrypted password.

以前とまったく同じ方法でパスワードを暗号化するには、元のパスワードの暗号化に使用したキーとアルゴリズム パラメータが必要です。いずれもも暗号化ツールによって生成され、以下のファイルに保存されています。

  • Key: javax.crypto.spec.SecretKeySpec_[timestamp]
  • Algorithm parameters: java.security.AlgorithmParameters_[timestamp]

これらのファイルを見つけたら、JSON オブジェクトで 2 つの追加フィールドを使用して暗号化ツールでその場所を指すことができます。これらのフィールドの説明とサンプル JSON オブジェクトは次のとおりです。

フィールド説明
keyFilePath

Path to a file that contains the key used to encrypt your original password, e.g. javax.crypto.spec.SecretKeySpec_[timestamp]

ファイル パスを環境変数として保存した場合、このパラメータを省略できます。

algorithmParametersFilePath

Path to a file that contains the algorithm parameters used to encrypt your original password, e.g. java.security.AlgorithmParameters_[timestamp]
Example JSON object with all fields
{"plainTextPassword":"yourPassword", "algorithm":"AES/CBC/PKCS5PADDING", "algorithmKey":"AES", "algorithmParametersFilePath":"java.security.AlgorithmParameters_1666647204502", "keyFilePath":"java.security.AlgorithmParameters_1666647204502"}

パスワードを暗号化するには、「ステップ1: パスワードの暗号化」に従い、JSON オブジェクトをキーとアルゴリズム パラメータで使用します。

最終更新日 2022 年 11 月 21 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.