README.md

September 3, 2026 ยท View on GitHub

Encrypting Properties

RsaPropertySource is useful for decrypting property values in RSA format. One manual step less when conducting production release.
Generate an RSA private/public key:

openssl genpkey -algorithm RSA -out private2048.pem -pkeyopt rsa_keygen_bits:2048
openssl rsa -pubout -in private2048.pem -out public2048.pem

Encrypt password using public key:

echo -n "dbSecret123" | openssl pkeyutl -encrypt \
  -pubin -inkey public2048.pem \
  -pkeyopt rsa_padding_mode:oaep \
  -pkeyopt rsa_oaep_md:sha256 | base64

Enable RSA decryption in the code at the beginning of the main package:

import _ "github.com/go-external-config/rsa"

Safely commit encrypted property with the code at feature development time.

my.secret=RSA:m+WQ5zMBqwMmEEP...

Provide rsa.privateKey.path on the environment to decrypt at runtime.