Implement encrypted connection to Oracle DB using Hibernate Spring JPA

Posted on

Have a requirement to connect to Oracle Database from spring application with an encryption.

In Oracle server the Native network encryption is added in Sqlnet.ora file as below
SQLNET.ENCRYPTION_TYPES_SERVER = (AES256)
SQLNET.ENCRYPTION_SERVER = accepted
SQLNET.CRYPTO_CHECKSUM_TYPES_SERVER= (SHA1)
SQLNET.CRYPTO_CHECKSUM_SERVER = accepted

The DB config properties are set as below in application
spring.jpa.database=default
<>.oracle.schema=
spring.datasource.initialize=true
spring.datasource.url=jdbc:oracle:thin:@:1521/
spring.datasource.driverClassName=oracle.jdbc.OracleDriver
spring.datasource.username=
spring.datasource.password=

Have set the below properties in datasource file, still there is no encrypted connection is established

Properties props = new Properties();
props.put("oracle.net.encryption_client", "REQUIRED");
props.put("oracle.net.encryption_types_client", "( AES256 )");
props.put("oracle.net.crypto_checksum_client", "REQUIRED");
props.put("oracle.net.crypto_checksum_types_client", "( SHA1 )");

Could you please help in configuring the Native network encryption properties in application to establish an encrypted connection to database.

Responses