4

I have added self-signed certificate for client-server communication using "TLSv1" protocol working perfectly in all device, but in Android Q preview during the handshake process getting the following exception

The error can be generated from procedtoUnsafe or adding exception from browser enter image description here

D/FA: Logging event (FE): user_engagement(_e), Bundle[{firebase_event_origin(_o)=auto, engagement_time_msec(_et)=9551, firebase_screen_class(_sc)=HomeActivity, firebase_screen_id(_si)=-2452361814686810599}]
    D/FA: Connected to remote service
    W/antra.rdservic: Accessing hidden method Ljava/net/InetAddress;->holder()Ljava/net/InetAddress$InetAddressHolder; (greylist, reflection, allowed)
    W/antra.rdservic: Accessing hidden method Ljava/net/InetAddress$InetAddressHolder;->getOriginalHostName()Ljava/lang/String; (greylist-max-o, reflection, denied)
    W/antra.rdservic: Accessing hidden method Ldalvik/system/CloseGuard;->close()V (greylist,core-platform-api, linking, allowed)
    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@17122037@17.1.22 (100400-245988633):35)
    W/System.err:     at com.google.android.gms.org.conscrypt.ConscryptFileDescriptorSocket.waitForHandshake(:com.google.android.gms@17122037@17.1.22 (100400-245988633):1)
    W/System.err:     at com.google.android.gms.org.conscrypt.ConscryptFileDescriptorSocket.getOutputStream(:com.google.android.gms@17122037@17.1.22 (100400-245988633):5)
    W/System.err:     at com.mantra.rdservice.sslservice.SslServer.runSecureServer(SslServer.java:121)
    W/System.err:     at com.mantra.rdservice.sslservice.SslServer.runServer(SslServer.java:157)
    W/System.err:     at com.mantra.rdservice.sslservice.SslServer.findPort(SslServer.java:106)
    W/System.err:     at com.mantra.rdservice.sslservice.SecureService$1.run(SecureService.java:74)
    W/System.err:     at java.lang.Thread.run(Thread.java:919)
    W/System.err: Caused by: javax.net.ssl.SSLProtocolException: SSL handshake aborted: ssl=0xc386a398: Failure in SSL library, usually a protocol error
    W/System.err: error:10000416:SSL routines:OPENSSL_internal:SSLV3_ALERT_CERTIFICATE_UNKNOWN (third_party/openssl/boringssl/src/ssl/tls_record.cc:587 0xc5e7a888:0x00000001)
    W/System.err:     at com.google.android.gms.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method)
    W/System.err:     at com.google.android.gms.org.conscrypt.NativeSsl.doHandshake(:com.google.android.gms@17122037@17.1.22 (100400-245988633):7)
    W/System.err:     at com.google.android.gms.org.conscrypt.ConscryptFileDescriptorSocket.startHandshake(:com.google.android.gms@17122037@17.1.22 (100400-245988633):14)
    W/System.err:   ... 7 more
    W/antra.rdservic: Accessing hidden method Ljava/net/InetAddress$InetAddressHolder;->getOriginalHostName()Ljava/lang/String; (greylist-max-o, reflection, denied)
    W/antra.rdservic: Accessing hidden method Ljava/net/InetAddress$InetAddressHolder;->getOriginalHostName()Ljava/lang/String; (greylist-max-o, reflection, denied)

i have added function that created connection

Loopback ="127.0.0.1";
private void runSecureServer(final int port) throws Exception {
        final ServerSocket socket = createSSLSocket();
        socket.bind(new InetSocketAddress(Loopback, port));
        socket.setReuseAddress(true);
        this._url = "https://" + Loopback + ":" + String.valueOf(port) + "/";
        while (true) {
            try {
                Socket client = socket.accept();
                PrintWriter outputStream = new PrintWriter(client.getOutputStream(), true);
                BufferedReader inputStream = new BufferedReader(new InputStreamReader(client.getInputStream()));
                StringBuilder finalData = new StringBuilder();
                String inputLine;
                while ((inputLine = inputStream.readLine()) != null && !inputLine.equals("")) {
                    finalData.append(inputLine).append("\r\n");
                }
                executorService.execute(new HttpProcessor(ctx, _url, client, outputStream, inputStream, finalData.toString()));
            } catch (Exception ex) {
                ex.printStackTrace();
                socket.close();
                runServer(port);
                break;
            }
        }

    }

I have referred StackOverflow question but no solution found

AMD
  • 1,662
  • 18
  • 39
  • your code already bugs out, when it tries to resolve the host-name ...which most likely isn't available in public DNS ...simply using a valid DNS A record with a SSL certificate might be the least effort (even if one can add exclusions - or certificates to the local trust-store). I mean, if you'd add the A record to public DNS, it might bug out elsewhere, because the certificate is still not authoritative. – Martin Zeitler May 30 '19 at 11:14
  • combine [Cloud DNS](https://cloud.google.com/dns) and [letsencrypt.org](https://letsencrypt.org) to have it properly fixed (needs 1 public IP address). – Martin Zeitler May 30 '19 at 11:20
  • my app working on localHost and wonking on all current device in market,i have edited question – AMD May 30 '19 at 11:20
  • the stack-trace tells it all... who shall connect your local host name? they might receive an error much earlier (which probably is being handled and won't throw an exception), because that host-name does not resolve at all. – Martin Zeitler May 30 '19 at 11:23
  • @MartinZeitler i donot require to obtain public ipaddress it working on all device via local host:port call browser will work as client and call secureSocket server created in my app – AMD May 30 '19 at 11:25
  • search for `SSLProtocolException: SSL handshake aborted` and `localhost`... excluding `SSLv3` seems to work; at least accoring to that [question](https://stackoverflow.com/questions/29916962/javax-net-ssl-sslhandshakeexception-javax-net-ssl-sslprotocolexception-ssl-han), which appears to be the actual duplicate. – Martin Zeitler May 30 '19 at 11:30
  • 1
    i have tried solution of ProviderInstaller.installIfNeeded(ApplicationContext) and also tried upgrading TLSV1.2 and TLSV1.3 but not woking – AMD May 30 '19 at 11:37

0 Answers0