Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/389.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Mqtt ExaException:找不到请求目标的有效证书路径_Java_Amazon Web Services_Certificate_Mqtt_Symantec - Fatal编程技术网

Java Mqtt ExaException:找不到请求目标的有效证书路径

Java Mqtt ExaException:找不到请求目标的有效证书路径,java,amazon-web-services,certificate,mqtt,symantec,Java,Amazon Web Services,Certificate,Mqtt,Symantec,我试着做一些事情,比如: public static void main(String[] args) throws FileNotFoundException, IOException { try (InputStream keyStoreStream = new FileInputStream(Configuration.KEYSTOREPATH_CLAIM.toAbsolutePath().toFile())) { String keysto

我试着做一些事情,比如:

    public static void main(String[] args) throws FileNotFoundException, IOException {
        try (InputStream keyStoreStream = new FileInputStream(Configuration.KEYSTOREPATH_CLAIM.toAbsolutePath().toFile())) {
            String keystoreClaimPass = new String(Files.readAllBytes(Configuration.KEYSTOREPATH_CLAIM_PASS));
            KeyStore keyStoreClaim = KeyStore.getInstance(Configuration.KEYSTORE_TYPE);
            keyStoreClaim.load(keyStoreStream, keystoreClaimPass.toCharArray());
            
            System.out.println("KeyStore with claim certificate is loaded successfully");
            
            AWSIotMqttClient iotClient = new AWSIotMqttClient(Configuration.IOT_CLIENT_ENDPOINT,
                    "not_existing_id",
                    keyStoreClaim,
                    keystoreClaimPass);
                        
            iotClient.connect();
            
            System.out.println("Temporary IoT client is loaded successfully");
        } catch (NoSuchAlgorithmException | CertificateException | KeyStoreException e) {
            throw new IOException("Creation temporary keystore by claim for IoT client is failed", e);
        } catch (AWSIotException e) {
            throw new IOException("Connection to IoT through claim certificate is failed", e);
        }

    }
它在windows(jdk-1.8.0)中工作,在Raspberry Buster(openjdk-8)中不工作

所以,如果我将
cacerts
文件从windows复制到raspberry,并在
java.security
文件中注释这一行

#jdk.security.caDistrustPolicies=SYMANTEC_TLS
它也起作用

我的问题是:

  • 我的解决方案行吗?也许是安全问题
  • 是否存在更优雅的解决方案