While configuring a tomcat with a jndi datasource to connect using ssl authentication to a postgres server (see providing certificates to tomcat jndi connection to postgresql) I have the following error:
[main] WARN org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator - HHH000342: Could not obtain connection to query metadata : Cannot create PoolableConnectionFactory (Could not find a java cryptographic algorithm: Cannot find any provider supporting 1.2.840.113549.1.5.13.)
(this is a warning in initialization time, but when I actually try to use the connection, I see the same as an error preventing to access the database).
Based on this answer: Reading PKCS8 in PEM format: Cannot find provider I have tried to modify /usr/lib/jvm/java-11-openjdk-amd64/conf/security/java.security
by adding org.bouncycastle.jce.provider.BouncyCastleProvider
as the first security provider. I also tried to add the jar bcprov-jdk15on-1.64.jar to /usr/lib/jvm/java-11-openjdk-amd64/lib
and /usr/share/java
(there was no lib/ext directory anywhere).
The problem still persists.
How should I tell to use the Bouncy Castle security provider either to the java runtime or tomcat or hibernate?
Update: Also tried to install libbcprov-java and set the security provider in java.security, but no success.