当前位置: 首页 > 知识库问答 >
问题:

Android System.err:javax.net.ssl.SSLHandshake异常:握手失败

汲涵育
2023-03-14

有人能告诉我如何在Android中解决SSLHandshakeException?下面是我试图使用HttpURLConnection对象访问的这个URL的错误。

W/bile.allfundin: Accessing hidden field Ljava/net/Socket;->impl:Ljava/net/SocketImpl; (light greylist, reflection)
W/bile.allfundin: Accessing hidden method Ldalvik/system/CloseGuard;->get()Ldalvik/system/CloseGuard; (light greylist, linking)
W/bile.allfundin: Accessing hidden method Ldalvik/system/CloseGuard;->open(Ljava/lang/String;)V (light greylist, linking)
W/bile.allfundin: Accessing hidden field Ljava/io/FileDescriptor;->descriptor:I (light greylist, JNI)
I/DynamiteModule: Considering local module com.google.android.gms.ads.dynamite:0 and remote module com.google.android.gms.ads.dynamite:21001
    Selected remote version of com.google.android.gms.ads.dynamite, version >= 21001
D/DynamitePackage: Instantiated singleton DynamitePackage.
    Instantiating com.google.android.gms.ads.ChimeraMobileAdsSettingManagerCreatorImpl
I/Ads: Updating ad debug logging enablement.
V/NativeCrypto: SSL handshake aborted: ssl=0x78ce68f9c8: Failure in SSL library, usually a protocol error
    error:1000042e:SSL routines:OPENSSL_internal:TLSV1_ALERT_PROTOCOL_VERSION (third_party/openssl/boringssl/src/ssl/tls_record.cc:592 0x78ce688688:0x00000001)
W/bile.allfundin: Accessing hidden method Ldalvik/system/BlockGuard;->getThreadPolicy()Ldalvik/system/BlockGuard$Policy; (light greylist, linking)
W/bile.allfundin: Accessing hidden method Ldalvik/system/BlockGuard$Policy;->onNetwork()V (light greylist, linking)
    Accessing hidden method Ldalvik/system/CloseGuard;->close()V (light greylist, linking)
I/WebViewFactory: Loading com.android.chrome version 79.0.3945.93 (code 394509337)
I/WebViewFactory: SystemProperties GMSVERSION = 9_201910
    Get WebViewChromiumFactoryProviderForO
I/cr_LibraryLoader: Time to load native libraries: 5 ms
V/NativeCrypto: SSL handshake aborted: ssl=0x78ce68f9c8: Failure in SSL library, usually a protocol error
    error:1000042e:SSL routines:OPENSSL_internal:TLSV1_ALERT_PROTOCOL_VERSION (third_party/openssl/boringssl/src/ssl/tls_record.cc:592 0x78ce688688:0x00000001)
W/System.err: javax.net.ssl.SSLHandshakeException: Handshake failed
W/System.err:     at com.google.android.gms.org.conscrypt.ConscryptFileDescriptorSocket.startHandshake(:com.google.android.gms@19831029@19.8.31 (100406-284611645):38)
        at com.android.okhttp.internal.io.RealConnection.connectTls(RealConnection.java:192)
        at com.android.okhttp.internal.io.RealConnection.connectSocket(RealConnection.java:149)
        at com.android.okhttp.internal.io.RealConnection.connect(RealConnection.java:112)
        at com.android.okhttp.internal.http.StreamAllocation.findConnection(StreamAllocation.java:184)
        at com.android.okhttp.internal.http.StreamAllocation.findHealthyConnection(StreamAllocation.java:126)
W/System.err:     at com.android.okhttp.internal.http.StreamAllocation.newStream(StreamAllocation.java:95)
        at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:281)
        at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:224)
        at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:461)
        at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:407)
        at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:244)
        at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getInputStream(DelegatingHttpsURLConnection.java:210)
        at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:26)
        at com.techlinemobile.allfunding.utilities.NetworkUtils.getResponseFromHttpUrl(NetworkUtils.java:55)
        at com.techlinemobile.allfunding.MainActivity$scholarshipQueryTask.doInBackground(MainActivity.java:92)
W/System.err:     at com.techlinemobile.allfunding.MainActivity$scholarshipQueryTask.doInBackground(MainActivity.java:84)
        at android.os.AsyncTask$2.call(AsyncTask.java:333)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:764)
W/System.err: Caused by: javax.net.ssl.SSLProtocolException: SSL handshake aborted: ssl=0x78ce68f9c8: Failure in SSL library, usually a protocol error
    error:1000042e:SSL routines:OPENSSL_internal:TLSV1_ALERT_PROTOCOL_VERSION (third_party/openssl/boringssl/src/ssl/tls_record.cc:592 0x78ce688688:0x00000001)
        at com.google.android.gms.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method)
        at com.google.android.gms.org.conscrypt.NativeSsl.doHandshake(:com.google.android.gms@19831029@19.8.31 (100406-284611645):6)
        at com.google.android.gms.org.conscrypt.ConscryptFileDescriptorSocket.startHandshake(:com.google.android.gms@19831029@19.8.31 (100406-284611645):14)
        ... 22 more
I/chromium: [INFO:library_loader_hooks.cc(51)] Chromium logging enabled: level = 0, default verbosity = 0
I/cr_LibraryLoader: Expected native library version number "79.0.3945.93", actual native library version number "79.0.3945.93"
W/cr_ChildProcLH: Create a new ChildConnectionAllocator with package name = com.android.chrome, sandboxed = true

请参阅下面我的方法的代码

 public static String getResponseFromHttpUrl(URL url) throws IOException {
        HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
        try {
            InputStream in = urlConnection.getInputStream();
            Scanner scanner = new Scanner(in);
            scanner.useDelimiter("\\A");

            boolean hasInput = scanner.hasNext();
            if (hasInput) {
                return scanner.next();
            } else {
                return null;
            }
        } finally {
            urlConnection.disconnect();
        }
    }

共有1个答案

宗政欣可
2023-03-14

我不能相信这篇文章,但这将向您展示需要安装哪些软件包来修复TLS/SSLv3问题。

你可能需要做的另一件事是添加

<application
  android:usesCleartextTraffic="true"
  ...
>

给你的AndroidManifest。xml,这是我在单元测试期间需要做的事情。

 类似资料:
  • 问题内容: 我试图安装Oracle Entitlements服务器客户端。当我打电话 我有这个异常: 你能帮我找到原因吗? 问题答案: 键控器”键控器”)在评论中给出了答案的方向。 问题出在密钥的长度上。简而言之:“从7u40开始,限制使用长度小于1024位的RSA密钥的x.509证书。” 因此,解决此问题的正确方法是使用密钥长度至少为2048位的证书。

  • 我正在学习SSL通信,我遇到了这个问题。我正在编写一个简单的客户端,它试图与本地apache服务器握手。服务器启用https。我将服务器证书添加到所有可能的信任存储(jdk中的一个 注意:我从以下教程中获取了代码: http://docs.oracle.com/javase/7/docs/technotes/guides/security/jsse/JSSERefGuide.html#KRB 停留

  • 我通过受ssl v3保护的cxf使用soap服务。我从服务器下载.cer文件,并通过keytool使用以下指令创建JKS文件: 在java代码中,我将此代码用于客户端配置: 对于调用此代码的服务: 当我运行代码时,会发生此错误: 我搜索此错误,我意识到该错误是针对不良信任存储的。但我不知道如何生成正确的信任库。

  • 我在使用硒测试时收到此错误 我现在的代码是 是否有其他方法可以忽略/解决此错误?

  • 我正在对我们的数据库服务进行超文本传输协议请求的大循环。一切都很好,但是每当我运行它时,在成功查询(看似随机)数量后,我都会收到以下错误:

  • 我已经创建了一个SSLClient和SSLServer,也创建了密钥库作为"server.jks"为SSLServer和"client.jks"为SSLClient.它抛出一个异常""。我不知道为什么我得到这个异常。我遵循http://ruchirawageesha.blogspot.in/2010/07/how-to-create-clientserver-keystores.html为服务器和