小编Gul*_*aye的帖子

javax.net.ssl.SSLHandshakeException:连接在com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(本机方法)上由peer关闭

在api level 24之前,我的代码工作正常,但它给了我api level 24(7.0牛轧糖)的错误.我没有得到我的代码出了什么问题.

第一种方法在这里:

 <?xml version="1.0" encoding="utf-8"?> <network-security-config>
   <base-config> <trust-anchors> <certificates src="system"/>
   <certificates src="user"/> </trust-anchors> </base-config>
   <domain-config> <domain includeSubdomains="true">xyz.com</domain>
   <trust-anchors> <certificates src="@raw/my_ca"/> </trust-anchors>
   </domain-config> </network-security-config>
Run Code Online (Sandbox Code Playgroud)

内部清单文件:

android:network Security Config = "@xml/network_security_config" 我已经包含network_security_config在内部res/xml/network_security_config,ca证书在里面res/raw/my_ca.pem

第二种方法是:

 import org.apache.http.client.HttpClient; 
 import org.apache.http.conn.ClientConnectionManager;  
 import org.apache.http.conn.scheme.Scheme; 
 import org.apache.http.conn.scheme.SchemeRegistry; 
 import org.apache.http.conn.ssl.SSLSocketFactory; 
 import org.apache.http.impl.client.DefaultHttpClient; 
 import java.io.IOException; import java.net.Socket; 
 import java.net.UnknownHostException; 
 import java.security.KeyManagementException; 
 import java.security.KeyStore;
 import java.security.KeyStoreException; 
 import java.security.NoSuchAlgorithmException; 
 import java.security.UnrecoverableKeyException; 
 import java.security.cert.CertificateException; 
 import java.security.cert.X509Certificate; import javax.net.ssl.SSLContext;
 import javax.net.ssl.TrustManager; 
 import javax.net.ssl.X509TrustManager; …
Run Code Online (Sandbox Code Playgroud)

ssl android handshake sslhandshakeexception

14
推荐指数
1
解决办法
8748
查看次数

标签 统计

android ×1

handshake ×1

ssl ×1

sslhandshakeexception ×1