1. プロパティの暗号化
1.1 セキュアプロパティツールJarファイルをダウンロードします。
セキュアプロパティツールを使用してプロパティを暗号化するからダウンロードできます。
1.2 プロパティ(文字列)を暗号化します。
java -cp secure-properties-tool.jar com.mulesoft.tools.SecurePropertiesTool \
string \
encrypt \
Blowfish \
CBC \
mulesoft \
"password"
1.3 プロパティファイルに暗号化したプロパティを追加します。
properties-dev-secure.yamlファイルを作成し、暗号化したプロパティを![]で追加します。
tls:
keystore:
keyPassword: "![Qvg+/L86Aw7HxUc+4uszNw==]"
password: "![Qvg+/L86Aw7HxUc+4uszNw==]"
2. Muleアプリケーションの設定
2.1 Anypoint Studioで「Mule Secure Configuration Properties Extension Module」を追加します。
「Search in Exchange」をクリックします。
「secure」で検索し「Mule Secure Configuration Properties Extension Module」をAddします。
2.2 1.3で作成したプロパティファイルを「Secure Configuration Properties」に登録します。
Global Elements画面で「Create」をクリックし、「Secure Properties Config」を検索します。
必要な情報を設定します。
<secure-properties:config
name="securePropertiesConfig"
doc:name="Secure Properties Config"
doc:id="66d97761-a04b-4323-9c8c-19f0adfc9677"
file="properties-${env}-secure.yaml"
key="${secure.key}">
<secure-properties:encrypt
algorithm="Blowfish" />
</secure-properties:config>
2.3 登録したセキュアなプロパティファイル内の値にアクセスします。
セキュアなプロパティファイル内の値にアクセスするには、値が暗号化されていない場合でも secure:: プレフィックスを使用する必要があります。
例えば以下のようにアクセスできます。
<tls:context
name="TLS_Context"
doc:name="TLS Context"
doc:id="95e36dfe-ba2a-43cf-b21c-5fe01e7124ab">
<tls:key-store
type="${tls.keystore.type}"
path="${tls.keystore.path}"
alias="${tls.keystore.alias}"
keyPassword="${secure::tls.keystore.keyPassword}"
password="${secure::tls.keystore.password}" />
</tls:context>
3. Safely Hide Application Properties
4. Muleアプリケーションのデプロイ
Anypoint StudioでMule Appを実行する場合、JVM引数を設定する必要があります。
-M-Denv=dev -M-Dsecure.key=mulesoft
CloudHubへデプロイする際に、Runtime Manager画面にてPropertiesのenvとsecure.keyを入力します。
デプロイ後のPropertiesのsecure.keyとanypoint.platform.client_secretがSafely Hideになっていることが確認できます。