基本的な暗号化

このページの内容

お困りですか?

アトラシアン コミュニティをご利用ください。

コミュニティに質問

パスワードをプレーン テキストで保存したくないものの、パスワードをエンコードするために特定の要件を満たす必要がないユーザーにはこのタイプのエンコーディングがおすすめです。

Encode the sensitive data

この方法では、機密データを簡単に難読化する方法である Base64 エンコーディングを使用します。

Step 1. Encode the sensitive data

データベース パスワードをエンコードする際は、以下のテーブルに記載されているように、いくつかのオプションの引数を指定できます。

引数

説明

-c,--class <arg>

暗号の正規クラス名。初期設定を使用するには空のままにします: com.atlassian.secrets.store.base64.Base64SecretStore

-h,--help

これらのオプションの引数を表示するヘルプ メッセージを出力します。

-m,--mode <arg>

指定されたパスワードに対して「encrypt」(既定) または「decrypt」を使用します。

-p,--password <arg>

暗号化したいプレーンテキストのパスワード。このパラメーターを省略すると、コンソールからパスワードの入力を求められます。

-s,--silent

最低限の情報をログに出力します。

データベース パスワードをエンコードするには、以下の手順に従います。

  1. <Bitbucket-installation-directory>/tools/atlassian-password に移動します。

  2. Run the following command to encode your password. Additionally, you can use optional arguments described above. 

    java -cp "./*" com.atlassian.secrets.cli.db.DbCipherTool

    このコマンドを実行すると、次のような出力が表示されます。

    2023-10-10 03:58:01,548 main INFO [com.atlassian.secrets.DefaultSecretStoreProvider] Initiating secret store class: com.atlassian.secrets.store.base64.Base64SecretStore
    2023-10-10 03:58:01,568 main DEBUG [secrets.store.base64.Base64SecretStore] Initiate Base64Cipher
    2023-10-10 03:58:01,583 main DEBUG [secrets.store.base64.Base64SecretStore] Encrypting data...
    2023-10-10 03:58:01,585 main DEBUG [secrets.store.base64.Base64SecretStore] Encryption done.
    Success!
    For Jira, set the following properties in dbconfig.xml:
    
    <atlassian-password-cipher-provider>com.atlassian.secrets.store.base64.Base64SecretStore</atlassian-password-cipher-provider>
    <password>c2VjcmV0</password>
    
    For Bitbucket, set the following properties in bitbucket.properties:
    
    jdbc.password.decrypter.classname=com.atlassian.secrets.store.base64.Base64SecretStore
    jdbc.password=c2VjcmV0
    
    For Bamboo, set the following properties in bamboo.cfg.xml:
    
    <property name="jdbc.password.decrypter.classname">com.atlassian.secrets.store.base64.Base64SecretStore</property>
    <property name="hibernate.connection.password">c2VjcmV0</property>
    
    For Confluence, set the following properties in confluence.cfg.xml:
    
    <property name="jdbc.password.decrypter.classname">com.atlassian.secrets.store.base64.Base64SecretStore</property>
    <property name="hibernate.connection.password">c2VjcmV0</property>

Step 2. Add the encoded data to bitbucket.properties

  1. Back up the <home-directory>/shared/bitbucket.properties file. Move the backup to a safe place outside of your instance.

  2. In the bitbucket.properties file, add or modify the encrypted-property.cipher.classname property to contain:

    com.atlassian.secrets.store.base64.Base64SecretStore
  3. In the bitbucket.properties file, add or modify the jdbc.password property to contain the Base64 encoded value prefixed with {ENC}:

    {ENC}c2VjcmV0
  4. 更新が完了したら、bitbucket.properties に次の内容が含まれていることを確認してください。

    encrypted-property.cipher.classname=com.atlassian.secrets.store.base64.Base64SecretStore
    jdbc.password={ENC}c2VjcmV0
  5. Restart Bitbucket.

Decode the sensitive data

To decode the sensitive data:

  1. Extend the command with the -m decrypt parameter:

    java -cp "./*" com.atlassian.secrets.cli.db.DbCipherTool -m decrypt
  2. パスワードを求められたら、bitbucket.properties ファイルから暗号化されたパスワードを指定します。

    2023-10-10 04:57:22,330 main INFO [com.atlassian.secrets.DefaultSecretStoreProvider] Initiating secret store class: com.atlassian.secrets.store.base64.Base64SecretStore
    2023-10-10 04:57:22,345 main DEBUG [secrets.store.base64.Base64SecretStore] Initiate Base64Cipher
    2023-10-10 04:57:22,360 main DEBUG [secrets.store.base64.Base64SecretStore] Decrypting data...
    2023-10-10 04:57:22,364 main DEBUG [secrets.store.base64.Base64SecretStore] Decryption done.
    Success! Decrypted password using cipher provider: com.atlassian.secrets.store.base64.Base64SecretStore decrypted password: secret


トラブルシューティング

Bitbucket fails to start after enabling database password encryption...

This means that Bitbucket couldn't connect to the database to access your configuration, most likely because of an error with decrypting your password.

To solve this problem, open <Bitbucket_home_directory>/log/atlassian-bitbucket.log, and check for DataSourcePasswordDecryptionException. For example:

com.atlassian.stash.internal.jdbc.DataSourcePasswordDecryptionException: java.lang.IllegalArgumentException: Illegal base64 character 25

The exception contains details about the error. If the error is java.lang.IllegalArgumentException, you will need to encrypt the password again.

'A fatal error has occurred' message displayed after restarting Bitbucket...

To investigate this problem, have a look at both the <Bitbucket_home_directory>/log/launcher.log and <Bitbucket_home_directory>/log/atlassian-bitbucket.log files, and check for JdbcSQLExceptions. The messages should be pretty clear as to what went wrong.

以下のメッセージが表示される場合があります。

 Wrong user name or password [28000-176]

This means that Bitbucket decrypted the password successfully, but the password itself is incorrect. You can verify that by completing these steps:

  1. Open the bitbucket.properties file, and copy the encrypted password.

  2. Decrypt the password.

  3. Check if the decrypted password is the same as the one in your backup bitbucket.properties file.

Disable database password encryption and revert changes...

To disable database password encryption, remove the jdbc.password.decrypter.classname property from the bitbucket.properties file, and change the value of jdbc.password to the unencrypted in your backup.

最終更新日 2023 年 11 月 10 日

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

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