Resolving javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed Error?

后端 未结 22 2900
名媛妹妹
名媛妹妹 2020-11-21 05:59

Edit :- Tried to format the question and accepted answer in more presentable way at mine Blog

Here is the original issue.

22条回答
  •  生来不讨喜
    2020-11-21 06:11

    DEPLOYABLE SOLUTION (Alpine Linux)

    To be able to fix this issue in our application environments, we have prepared Linux terminal commands as follows:

    cd ~
    

    Will generate cert file in home directory.

    apk add openssl
    

    This command installs openssl in alpine Linux. You can find proper commands for other Linux distributions.

    openssl s_client -connect  < /dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > public.crt
    

    Generated the needed cert file.

    sudo $JAVA_HOME/bin/keytool -import -alias server_name -keystore $JAVA_HOME/lib/security/cacerts -file public.crt -storepass changeit -noprompt
    

    Applied the generated file to the JRE with the program 'keytool'.

    Note: Please replace your DNS with

    Note2: Please gently note that -noprompt will not prompt the verification message (yes/no) and -storepass changeit parameter will disable password prompt and provide the needed password (default is 'changeit'). These two properties will let you use those scripts in your application environments like building a Docker image.

    Note3 If you are deploying your app via Docker, you can generate the secret file once and put it in your application project files. You won't need to generate it again and again.

提交回复
热议问题