Access a java keystore file stored in docker container, inside a dependent jar

I have 1 main and 1 secondary java springboot based app. The secondary app is acting like a library project. The main app is dependent on secondary app which is clearly mentioned in pom.xml of main app.

I have a docker-compose.yml file in main app which takes care of running required containers. I am storing a jks file using volumes in docker-compose.yml inside /certs/xyz.jks path of the docker container and setting 2 environment variables in the same docker-compose.yml file for setting the path of the jks file + the password of keystore.

In docker-compose.yml,

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>environment:
- JAVAX_NET_SSL_TRUSTSTORE=/certs/truststore.jks
- JAVAX_NET_SSL_TRUSTSTOREPASSWORD=abcdef
volumes:
- ./src/main/resources/truststore.jks:/certs/truststore.jks
</code>
<code>environment: - JAVAX_NET_SSL_TRUSTSTORE=/certs/truststore.jks - JAVAX_NET_SSL_TRUSTSTOREPASSWORD=abcdef volumes: - ./src/main/resources/truststore.jks:/certs/truststore.jks </code>
environment: 
  - JAVAX_NET_SSL_TRUSTSTORE=/certs/truststore.jks
  - JAVAX_NET_SSL_TRUSTSTOREPASSWORD=abcdef
volumes:
  - ./src/main/resources/truststore.jks:/certs/truststore.jks

In order to connect to amazon documentDB, the secondary app needs to set the system properties – javax.net.ssl.trustStore and javax.net.ssl.trustStorePassword. If I run the main app locally without using docker-compose and by putting the values in application.yml file, It’s able to connect to documentDB successfully(via seconday app of course as seconday app is the one which is setting the system properties as mentioned above).

In application.yml,

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>javax:
net:
ssl:
trustStore: src/main/resources/truststore.jks
trustStorePassword: abcde
</code>
<code>javax: net: ssl: trustStore: src/main/resources/truststore.jks trustStorePassword: abcde </code>
javax:
  net:
    ssl:
      trustStore: src/main/resources/truststore.jks
      trustStorePassword: abcde

As part of running the above scenario using docker-compose, I am successfully able to access the properties(keystore path and password) from the environment variables set in docker-compose file of the main app, inside the secondary app. Basically, I am able to get the relative path of the keystore file (i.e /certs/xyz.jks) and the password in the secondary app as 2 Strings.

However, using these, I am not able to connect to documentDB as it fails with

org.mongodb.driver.cluster : Cluster description not yet available. Waiting for 30000 ms before timing out
[127.0.0.1:27019] org.mongodb.driver.cluster : Exception in monitor thread while connecting to server 127.0.0.1:27019

Hence, Can you please let me know if you think there could be an issue with passing the jks file properly from main app to secondary app in case of docker-compose? When it works fine locally in the secondary app, do I need to configure anything else from docker-compose’s side of the main app, in order to get it worked in secondary app?

Note: I referred these posts for implementing and getting it worked locally (without docker)

aws docuemntDB post 1

aws docDB post 2

Basically, the jks file is present inside /certs/xyz.jks path of the container and I am able to see the same in docker desktop as well.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật