您也必须以编程方式创建信任库 请参阅下面的代码以供参考
// Declare path of trust store and create file
String trustStorePath = "/tmp/trust";
// try creating above directory and path if you get error no such file
// Create Truststore using Key store api
KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
// locate the default truststore
String filename = System.getProperty("java.home")
+ "/lib/security/cacerts".replace('/', File.separatorChar);
try (FileInputStream fis = new FileInputStream(filename)) {
keyStore.load(fis, "changeit".toCharArray());
}
// Add Certificate to Key store
CertificateFactory certF = CertificateFactory.getInstance("X.509");
Certificate cert = certF.generateCertificate(new FileInputStream("your certificate path"));
keyStore.setCertificateEntry("any alias", cert);
// Write Key Store
try (FileOutputStream out = new FileOutputStream(trustStoreFile)) {
keyStore.store(out, "changeit".toCharArray());
}
// Set Certificates to System properties
System.setProperty("javax.net.ssl.trustStore", trustStorePath);
System.setProperty("javax.net.ssl.trustStorePassword", "changeit");
您也可以在 aws lambda 上进行本地测试。希望这能解决问题