关于mailgun接口调用出现ssl错误的处理方法

Skip to end of metadata


Go to start of metadata
在mailgun接口调用的过程中,如果出现下列问题:

  1. com.sun.jersey.api.client.ClientHandlerException: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

你可以尝试如下步骤的操作来解决问题。

1.如果你的服务器是centos,做如下操作:

yum -y update ca-certificates

2.导入目标网站证书:

keytool ``-import -alias mailgun20201229 ``-keystore $JAVA_HOME/jre/lib/security/cacerts ``-file /root/mailgun.cer ``-trustcacerts
输入密码:changeit
提示是否trust 输入:yes
完成

其中-keystore和-file修改为自己的路径即可。
目标网站mailgun的证书参考附件mailgun.cer

访问https://api.mailgun.net/v3/email.lightinthebox.com/messages,导出证书