Witha有效证书:java.security.cert.CertPathValidatorException:未找到证书路径的信任锚

时间:2018-01-13 09:12:35

标签: android ssl certificate ssl-certificate

最近我们更改了服务器中的证书,我们无法访问Android上的简单https请愿书;证书不是自签名的,但由可信验证器签名;

我们在Android中的代码是:

    protected String doInBackground(String... urls) {
        URL url = null;
        StringBuffer buffer = null;
        try {
            url = new URL("https://........com/test");
            HttpURLConnection urlConnection = null;
            urlConnection = (HttpURLConnection) url.openConnection();
            urlConnection.setRequestMethod("GET");
            urlConnection.connect();
            // Read the input stream into a String
            InputStream inputStream = null;
            inputStream = urlConnection.getInputStream();
            buffer = new StringBuffer();
            if (inputStream == null) {
                // Nothing to do.
                return null;
            }
            BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
            String line;
            while ((line = reader.readLine()) != null) {
                buffer.append(line + "\n");
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buffer.length() == 0) {
            return null;
        }
        String stringResult = buffer.toString();
        return stringResult;
    }

谢谢!

0 个答案:

没有答案