title: configure tomcat/hibernate to have a cryptographic provider supporting 1.2.840.113549.1.5.13
body: <p>While configuring a tomcat with a jndi datasource to connect using ssl authentication to a postgres server (see <a href="https://stackoverflow.com/questions/58487055/providing-certificates-to-tomcat-jndi-connection-to-postgresql">providing certificates to tomcat jndi connection to postgresql</a>) I have the following error:</p>
  
  <pre><code>[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.)
  </code></pre>
  
  <p>(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).</p>
  
  <p>Based on this answer: <a href="https://stackoverflow.com/questions/46767281/reading-pkcs8-in-pem-format-cannot-find-provider/46770084#46770084">Reading PKCS8 in PEM format: Cannot find provider</a> I have tried to modify <code>/usr/lib/jvm/java-11-openjdk-amd64/conf/security/java.security</code> by adding <code>org.bouncycastle.jce.provider.BouncyCastleProvider</code> as the first security provider. I also tried to add the jar bcprov-jdk15on-1.64.jar to <code>/usr/lib/jvm/java-11-openjdk-amd64/lib</code> and <code>/usr/share/java</code> (there was no lib/ext directory anywhere).</p>
  
  <p>The problem still persists.</p>
  
  <p>How should I tell to use the Bouncy Castle security provider either to the java runtime or tomcat or hibernate?</p>
  
  <p>Update:
  Also tried to install libbcprov-java and set the security provider in java.security, but no success.</p>