내 안드로이드 애플리케이션에서 https를 통해 연결합니다. 연결할 자체 서명 된 인증서를 사용하고 있습니다. 그것은 (로이드 누가 전) API 레벨 24 나누었다 안드로이드에 누가는 SSL 핸드 예외가 발생 장치 아래에서 작동 :안드로이드에서 자체 서명 된 인증서를 사용하여 https를 통해 연결하는 동안 SSL 핸드 셰이크 예외 Nougat
javax.net.ssl.SSLHandshakeException : java.security.cert.CertPathValidatorException : 인증 경로에 대한 트러스트 앵커를 찾을 수 없습니다. 나는 다음과 같은 link을 시도
SSLContext context = null; try { KeyStore keyStore = KeyStore.getInstance("PKCS12"); // Get the raw resource, which contains the keystore with // your trusted certificates (root and any intermediate certs) InputStream input = new BufferedInputStream(context.getAssets().open(pkcsFilename)); try { // Initialize the keystore with the provided trusted certificates // Also provide the password of the keystore keyStore.load(input, password.toCharArray()); } finally { input.close(); } KeyManagerFactory keyFactory = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); keyFactory.init(keyStore, "".toCharArray()); // Load CAs from an InputStream // (could be from a resource or ByteArrayInputStream or ...) CertificateFactory cf = CertificateFactory.getInstance("X.509"); Certificate ca = null; input = new BufferedInputStream(context.getAssets().open(certificateFilename)); try { ca = cf.generateCertificate(input); } finally { input.close(); } KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType()); trustStore.load(null, null); trustStore.setCertificateEntry("server", ca); // Create a TrustManager that trusts the CAs in our KeyStore TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); tmf.init(trustStore); // Create an SSLContext that uses our TrustManager context = SSLContext.getInstance("TLS"); context.init(keyFactory.getKeyManagers(), tmf.getTrustManagers(), null); HttpsURLConnection urlConnection = (HttpsURLConnection) url.openConnection();
, 그러나 그것은 도움이되지 않습니다 - :
이 내가 HTTPS를 통해 연결하는 방법입니다.
이것은 내 네트워크 구성 파일입니다. AndroidManifest.xml 파일에 추가했습니다.
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config>
<domain includeSubdomains="true">xyz.com</domain>
<trust-anchors>
<certificates src="@raw/root_ca" />
</trust-anchors>
</domain-config>
</network-security-config>
이 문제를 해결하는 방법을 알려주세요.