Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

218
Views
Where exactly do we place this postgresql.conf configuration file in spring boot application?

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?

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

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.

over 4 years ago · Santiago Trujillo Report

0

The way to use encrypt.key, not only for current session, it's store it in postgresql.conf.

The correct place is at the end of this file, in the "Customized Options" section:

#------------------------------------------------------------------------------
# CUSTOMIZED OPTIONS
#------------------------------------------------------------------------------

# Add settings for extensions here
encrypt.key=123456

Reload the configuration of the database server:

systemctl reload postgresql.service

To testing if it's working correctly. Open a pgsql session and type:

mydb=# show encrypt.key;
 encrypt.key
-------------
 123456
(1 row)

Example of encrypt:

mydb=# select pgp_sym_encrypt('Hola mundo',current_setting('encrypt.key'));
                                                                      pgp_sym_encrypt
------------------------------------------------------------------------------------------------------------------------------------------------------------
 \xc30d04070302255230e388dfe25e7dd23b01c5b8e62d148088a3417d3c27ed2cc11655d863b271672b9f076fffb82f1a7f074f2ecbe973df04642cd7a4f76ca5cff4a13b9a71e7cc6e693827
(1 row)

Example of decrypt:

mydb=# select pgp_sym_decrypt('\xc30d04070302255230e388dfe25e7dd23b01c5b8e62d148088a3417d3c27ed2cc11655d863b271672b9f076fffb82f1a7f074f2ecbe973df04642cd7a4f76ca5cff4a13b9a71e7cc6e693827',current_setting('encrypt.key'));
 pgp_sym_decrypt
-----------------
 Hola mundo
(1 row)
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!