Demo entry 6634585

java

   

Submitted by anonymous on Aug 11, 2017 at 08:01
Language: Java. Code size: 1.1 kB.

public SslWebViewClient2(Context context) {
        try {
            TrustManager[] trustManagers = prepareTrustManager(context.getResources().getAssets().open("server.cer"));
            KeyManager[] keyManagers = prepareKeyManager(context.getResources().getAssets().open("client.bks"), "defonds");
            sslContext = SSLContext.getInstance("TLS");
            X509TrustManager trustManager = null;
            if (null != trustManagers){
                trustManager = new MyTrustManager(chooseTrustManager(trustManagers));
            }else {
                trustManager = new UnSafeTrustManager();
            }
            sslContext.init(keyManagers, new TrustManager[]{trustManager}, new SecureRandom());
        } catch (IOException e) {
            e.printStackTrace();
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        } catch (KeyStoreException e) {
            e.printStackTrace();
        } catch (KeyManagementException e) {
            e.printStackTrace();
        }
    }

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).