我正在尝试使用 Camel 配置 Spring Boot,以便能够使用 smtps 发送邮件。我有简单的路线
@Component
public class EmailRoute extends RouteBuilder {
public static final String IN = "seda://email";
public static final String OUT = "smtps://myhost:465?myuser&password=mypass&debugMode=true";
@Override
public void configure() throws Exception {
from(IN).to(OUT);
}
当我使用这条路线发送东西时出现错误:
javax.mail.MessagingException: Could not connect to SMTP host : myhost
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
我有 pem 文件证书(没有密钥,只有证书),我已将其导入 jks 钥匙串文件
向 EmailRoute 类添加了一个用于创建 SSLContextParameters 参数的方法
private SSLContextParameters sslContextParameters(){
KeyStoreParameters store = new KeyStoreParameters();
store.setResource("pathToJskFile/cert.jks");
store.setPassword("123456");
TrustManagersParameters trust = new TrustManagersParameters();
trust.setKeyStore(store);
SSLContextParameters parameters = new SSLContextParameters();
parameters.setTrustManagers(trust);
return parameters;
}
现在不确定如何使用 camel 和 spring boot 连接两个,因为来自http://camel.apache.org/mail.html的示例与注册表不是 100% 清楚