gpt4 book ai didi

android - OpenSSLSocketImpl.getSession 崩溃

转载 作者:太空宇宙 更新时间:2023-11-03 14:32:29 36 4
gpt4 key购买 nike

在某些设备上我遇到以下崩溃:

//崩溃信息

SIGABRT

00 pc 00041300 /system/lib/libc.so (tgkill+12) [armeabi-v7a::1b317667710e940729198acd09513c97]

01 pc 000401b5 /system/lib/libc.so (pthread_kill+32) [armeabi-v7a::1b317667710e940729198acd09513c97]

02 pc 0001c893 /system/lib/libc.so (raise+10) [armeabi-v7a::1b317667710e940729198acd09513c97]

03 pc 00019af1 /system/lib/libc.so (__libc_android_abort+34) [armeabi-v7a::1b317667710e940729198acd09513c97]

04 pc 000176b8 /system/lib/libc.so (abort+4) [armeabi-v7a::1b317667710e940729198acd09513c97]

05 pc 0001b553 /system/lib/libc.so (__libc_fatal+16) [armeabi-v7a::1b317667710e940729198acd09513c97]

06 pc 0001b56b /system/lib/libc.so (__fortify_chk_fail+18) [armeabi-v7a::1b317667710e940729198acd09513c97]

07 pc 00046315 /system/lib/libc.so (__FD_SET_chk+24) [armeabi-v7a::1b317667710e940729198acd09513c97]

08 pc 000092f5 /system/lib/libjavacrypto.so [armeabi-v7a::3bdb8758762753b0649e6940a3fc1a62] java:

com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:324) com.android.org.conscrypt.OpenSSLSocketImpl.waitForHandshake(OpenSSLSocketImpl.java:629) com.android.org.conscrypt.OpenSSLSocketImpl.getSession(OpenSSLSocketImpl.java:793) com.thirdparty.afinal.utils.HttpsHelper$a.createSocket(SourceFile:786) org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:170) org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:169) org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:124) org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:366) org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:596) org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:517) com.thirdparty.afinal.f.c.a(SourceFile:80) com.thirdparty.afinal.f.c.b(SourceFile:117) com.thirdparty.afinal.c.d$2.call(SourceFile:146) java.util.concurrent.FutureTask.run(FutureTask.java:237) java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) java.lang.Thread.run(Thread.java:833)

//代码如下

私有(private)静态最终类 MySSLSocketFactory 扩展 SSLSocketFactory {

    private KeyStore mKeystore;

public MySSLSocketFactory(KeyStore truststore) throws NoSuchAlgorithmException,
KeyManagementException, KeyStoreException, UnrecoverableKeyException {
super(truststore);
mKeystore = truststore;
}

final static HostnameVerifier hostnameVerifier = new StrictHostnameVerifier();

@SuppressLint("NewApi")
@Override
public Socket createSocket(Socket socket, String host, int port, boolean autoClose) throws IOException {

if (autoClose) {
socket.close();
}

SSLCertificateSocketFactory sslSocketFactory =
(SSLCertificateSocketFactory) SSLCertificateSocketFactory.getDefault(0);
try {
sslSocketFactory.setTrustManagers(new TrustManager[] { new MyX509TrustManager(mKeystore)});
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (KeyStoreException e) {
e.printStackTrace();
}
@SuppressLint("SSLCertificateSocketFactoryCreateSocket")
SSLSocket ssl = (SSLSocket)sslSocketFactory.createSocket(InetAddress.getByName(host), port);


if (socket instanceof SSLSocket) {
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT_WATCH
&& Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
ssl.setEnabledProtocols(ssl.getSupportedProtocols());
}
}

sslSocketFactory.setHostname(ssl, host);

SSLSession session = ssl.getSession();
if (!hostnameVerifier.verify(host, session)){
throw new SSLPeerUnverifiedException("Cannot verify hostname: " + host + " peer=" + session.getPeerHost());
}

return ssl;
}
}

最佳答案

您的应用可能试图一次创建太多套接字连接。

Android 对每个应用的文件描述符数量有限制(不超过 1024)。

关于android - OpenSSLSocketImpl.getSession 崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51452319/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com