找不到PropertySource:Spring Cloud配置URL的PKIX路径构建失败

我在Spring Boot项目中使用spring-cloud-config,但是当我尝试将应用程序作为spring boot应用程序运行时,却出现以下异常

  

无法找到PropertySource:GET请求的I / O错误   “ https://spring-cloud-config-orgname.com/annuity-application-api/dev/master”:   sun.security.validator.ValidatorException:PKIX路径构建失败:   sun.security.provider.certpath.SunCertPathBuilderException:无法执行   找到到达要求目标的有效认证路径;嵌套异常为   javax.net.ssl.SSLHandshakeException:   sun.security.validator.ValidatorException:PKIX路径构建失败:   sun.security.provider.certpath.SunCertPathBuilderException:无法执行   找到到所请求目标的有效认证路径

我已使用以下命令在java truststore中添加了证书

keytool -importcert -trustcacerts -file C:\Users\patilp1\temp\sslcerts\spring-cloud-config.cer -alias "spring-cloud-config"

仍然我的应用程序给出了同样的异常。知道这背后的原因是什么,因为我已经将Java信任库中的证书添加到了

  

C:\Program Files\Java\jdk1.8.0_192\jre\lib\security

achievekey 回答:找不到PropertySource:Spring Cloud配置URL的PKIX路径构建失败

尝试一下: 1.使用配置服务器的证书创建一个密钥库/信任库 2.添加以下VM参数:

@Converter
public class EncryptDecrypt implements AttributeConverter<String,String> {

    private static SecretKeySpec secretKey;
    private static byte[] key;

    @Override
    public String convertToDatabaseColumn(String strToEncrypt) {
        try
        {
            String secret="secret";
            setKey("secret");
            Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
            cipher.init(Cipher.ENCRYPT_MODE,secretKey);
            return Base64.getEncoder().encodeToString(cipher.doFinal(strToEncrypt.getBytes("UTF-8")));
        } 
        catch (Exception e) 
        {
        }
        return null;
    }
}

希望这会有所帮助。

本文链接:https://www.f2er.com/3160758.html

大家都在问