Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - Video streaming over local HTTPS server: SSL certificate rejected

I need to stream video over a local HTTPS server (of course to do some background DRM) in Android. The Android media player is then connecting to the local server, 'streaming' the video content to the screen.

It all works fine with a HTTP server but as soon as I enable SSL, the video player stops.

If i connect to the HTTPS server from outside my app using a browser, I get an SSL warning which i can ignore and then the video player starts.

Is there a way to disable the strict certificate handling for the media player module? I have seen a lot of posts on how to do this using my own HTTP connection, but nothing on how to do this for the media player.

Thanks!

UPDATE: Google for 'intranet certificate' or 'instant certificate' and you will find something that's supposed to work. Will try it out tomorrow and post the answer here.

like image 483
KPK Avatar asked Oct 19 '11 22:10

KPK


1 Answers

You Should Try this for Sure,

    // Create a trust manager that does not validate certificate chains
    TrustManager[] trustAllCerts = new TrustManager[]{
        new X509TrustManager() {
            public java.security.cert.X509Certificate[] getAcceptedIssuers() {
                return null;
            }
            public void checkClientTrusted(
                java.security.cert.X509Certificate[] certs, String authType) {
            }
            public void checkServerTrusted(
                java.security.cert.X509Certificate[] certs, String authType) {
            }
        }
    };

    // Install the all-trusting trust manager
    // Try "SSL" or Replace with "TLS"
    try {
        SSLContext sc = SSLContext.getInstance("SSL");
        sc.init(null, trustAllCerts, new java.security.SecureRandom());
        HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
    } catch (Exception e) {
    }

    // Now you can access an https URL without having the certificate in the truststore 
           // Your Code Goes Here

Here are More Solutions for This
Certificate Validation in an HTTPS Connection
Android: Trusting SSL certificates
https://stackoverflow.com/a/6378872/1008278

like image 62
VenomVendor Avatar answered Nov 03 '22 12:11

VenomVendor