'SSL HandShake Exception:No appropriate protocol (protocol is disabled or cipher suites are inappropriate);

I am connecting email using imap

Store store = session.getStore("imaps");
store.connect(server, username, password);

The code is working fine and email is connected while running the project inlocal

But if we run the project in docker container. Below error is thrown.

javax.mail.MessagingException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate);
  nested exception is:
        javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate)
        at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:665)

Docker File

FROM markhobson/maven-chrome:latest

WORKDIR /app

ARG ENVUrl=''

ENV ENVUrl $ENVUrl

ENV JAVA_OPTS="-Djava.awt.headless=true -Dmail.smtp.starttls.enable=true -Dmail.smtp.ssl.protocols=TLSv1.2"

COPY ./Framework .


Solution 1:[1]

Check your IMAP server's supported TLS protocol and cipher

Solution 2:[2]

Faced similar issue. It's due to java version you are using in docker. If your are using java version 8u291 or later TLS V1.0,1.1 may be disabled. Please check the Solution here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Dips
Solution 2 Saravanan Shanmugaraj