Re: [问题] Android 7.0 https无法连线的问题

楼主: joycece (joycece)   2017-03-15 10:40:17
糗了 我的程式里面本来就有加了 不知道是否还有其他线索可指点一下
感谢~
public int init() throws InterruptedException {
KeyStore ks;
try {
ks = KeyStore.getInstance("BKS");
String pkres;
pkres = GlbArgs.getString("SslKey");
ks.load(GlbArgs.getRes().openRawResource(GlbArgs.getResId(pkres)),
"000000".toCharArray());
TrustManagerFactory tmf = TrustManagerFactory
.getInstance(KeyManagerFactory.getDefaultAlgorithm());
tmf.init(ks);
SSLContext ctx = SSLContext.getInstance("TLS");
//SSLContext ctx = SSLContext.getDefault();
ctx.init(null, tmf.getTrustManagers(), null);
SSLSocketFactory sslFact = ctx.getSocketFactory();
mSock = (SSLSocket) sslFact.createSocket();
mSock.setEnabledCipherSuites(mSock.getSupportedCipherSuites());
String[] s={"TLSv1.2"};
mSock .setEnabledProtocols(s);
} catch (IOException | NoSuchAlgorithmException
| CertificateException | KeyStoreException | KeyManagementException e) {
e.printStackTrace();
return ERR_TCPSSL_INIT;
}
return ERR_OK;
}
※ 引述《benedict76 (ben)》之铭言:
: 我有遇过Android m可以但是在N不行,
: 后来发现N把RC4 cipher suites disable,
: 结果我连的server要的cipher suite默认都被
: 关掉,所以在我连线的时候,在sslsocket
: 哪边setenabledciphersuites,传
: getsupportedciphersuites()进去,后来就成
: 功连线,您可以试试看。
: ※ 引述《joycece (joycece)》之铭言:
: : 我也遇上了类似的问题
: : 在Android 5 & 6的 手机上可以正常SSL连线(TLS1.2)
: : 但在Android 7.1.1的手机就发生以下错误
: : javax.net.ssl.SSLHandshakeException:
: : java.security.cert.CertPathValidatorException:
: : Trust anchor for certification path not found.
: : 想请问是否能够给个方向怎样去修正或避免这个问题发生?
: : 谢谢
:
作者: benedict76 (ben)   2017-03-15 10:56:00
您这是用自己的certificate吗?不知道是不是要用networkconfigure 来做
作者: hh81tw (J)   2017-04-08 09:04:00
是不是少了https://developer.android.com/training/articles/security-config.html#manifest

Links booklink

Contact Us: admin [ a t ] ucptt.com