问题
I am trying to encrypt a column in my prostrgres DB. The column name is "test" of type "bytea".
My enity code is below,
@ColumnTransformer(read = "pgp_sym_decrypt(" + " test, "
+ " current_setting('encrypt.key')"
+ ")", write = "pgp_sym_encrypt( " + " ?, "
+ " current_setting('encrypt.key')" + ") ")
@Column(columnDefinition = "bytea")
private String test;
postgresql.conf configuration file: encrypt.key = 'Wow! So much security.
Placed the postgresql.conf configuration file in src/main/resources of spring boot appln. But the encryption.key value is not being picked up. And is there a way to pass the key using application.properties?
回答1:
postgresql.conf
is the configuration file for the Postgres server. It's stored inside the data directory (aka "cluster") on the server.
You can't put it on the client side (where your application runs). It has no meaning there.
To change values in there, you need to edit the file (on the server) or use ALTER SYSTEM.
If you want to change a configuration setting for the current session, use SET or set_config()
The latter two are probably the ones you are looking for to initialize the custom property for your encryption/decryption functions.
来源:https://stackoverflow.com/questions/63245496/where-exactly-do-we-place-this-postgresql-conf-configuration-file-in-spring-boot