Permission denied, java web app can't read myTrustStore.jks generated by global-bundle.pem

0

I am unable to solve this. When I generate myTrustStore.jks file using global-bundle.pem to connect my java hibernate based application (deployed to ec2) to aws rds, the app is unable to read the myTrustStore.jks. Tried all the possible combinations but still couldn't make it work. This is the stack trace of the error I am getting. Have literally tried everything to figure it out but still couldn't get it to read the myTrustStore.jks file. Any help is always welcome.

java.io.FileNotFoundException: /home/ec2-user/myTrustStore.jks (Permission denied) java.base/java.io.FileInputStream.open0(Native Method) java.base/java.io.FileInputStream.open(FileInputStream.java:216) java.base/java.io.FileInputStream.<init>(FileInputStream.java:157) java.base/java.io.FileInputStream.<init>(FileInputStream.java:111) java.base/sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:86) java.base/sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:189) java.base/java.net.URL.openStream(URL.java:1161) com.mysql.cj.protocol.ExportControlled.getSSLContext(ExportControlled.java:515) com.mysql.cj.protocol.ExportControlled.performTlsHandshake(ExportControlled.java:301) com.mysql.cj.protocol.StandardSocketFactory.performTlsHandshake(StandardSocketFactory.java:188) com.mysql.cj.protocol.a.NativeSocketConnection.performTlsHandshake(NativeSocketConnection.java:99) com.mysql.cj.protocol.a.NativeProtocol.negotiateSSLConnection(NativeProtocol.java:352) com.mysql.cj.protocol.a.NativeAuthenticationProvider.negotiateSSLConnection(NativeAuthenticationProvider.java:777) com.mysql.cj.protocol.a.NativeAuthenticationProvider.proceedHandshakeWithPluggableAuthentication(NativeAuthenticationProvider.java:486) com.mysql.cj.protocol.a.NativeAuthenticationProvider.connect(NativeAuthenticationProvider.java:202) com.mysql.cj.protocol.a.NativeProtocol.connect(NativeProtocol.java:1449) com.mysql.cj.NativeSession.connect(NativeSession.java:165) com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:955) com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:825) com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:455) com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:240) com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:199) com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:95) com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:101) com.zaxxer.hikari.pool.BaseHikariPool.addConnection(BaseHikariPool.java:444) com.zaxxer.hikari.pool.BaseHikariPool.initializeConnections(BaseHikariPool.java:548) com.zaxxer.hikari.pool.BaseHikariPool.<init>(BaseHikariPool.java:172) com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:60) com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:48) com.zaxxer.hikari.HikariDataSource.<init>(HikariDataSource.java:80) com.zaxxer.hikari.hibernate.HikariConnectionProvider.configure(HikariConnectionProvider.java:82) org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:111) org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:234) org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:206) org.hibernate.engine.jdbc.internal.JdbcServicesImpl.buildJdbcConnectionAccess(JdbcServicesImpl.java:260) org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:94) org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:111) org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:234) org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:206) org.hibernate.cfg.Configuration.buildTypeRegistrations(Configuration.java:1885) org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1843) objects.HibernateUtil.getSessionFactory(HibernateUtil.java:65) objects.HibernateUtil.getSession(HibernateUtil.java:112) services.LoginService.Login(LoginService.java:38) Servlets.Login.doPost(Login.java:59) javax.servlet.http.HttpServlet.service(HttpServlet.java:515) javax.servlet.http.HttpServlet.service(HttpServlet.java:583) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)

Saurabh
asked 2 months ago69 views
1 Answer
0

The specific error is related to permission issue on the specific file myTrustStore.jks, refer this StackOverFlow link for troubleshooting permission denied errors.

Hope it helps and if it does, I would appreciate if answer can be accepted so that community can benefit for clarity when searching for similar enquirers in Repost, thank you ;)

AWS
answered 2 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions