Example usage for android.net SSLCertificateSocketFactory setKeyManagers

List of usage examples for android.net SSLCertificateSocketFactory setKeyManagers

Introduction

In this page you can find the example usage for android.net SSLCertificateSocketFactory setKeyManagers.

Prototype

public void setKeyManagers(KeyManager[] keyManagers) 

Source Link

Document

Sets the KeyManager s to be used for connections made by this factory.

Usage

From source file:com.android.beyondemail.SSLUtils.java

/**
 * Returns a {@link org.apache.http.conn.ssl.SSLSocketFactory SSLSocketFactory} for use with the
 * Apache HTTP stack./*from   ww w  . ja  v a 2s. c o m*/
 */
public static SSLSocketFactory getHttpSocketFactory(boolean insecure, KeyManager keyManager) {
    SSLCertificateSocketFactory underlying = getSSLSocketFactory(insecure);
    if (keyManager != null) {
        underlying.setKeyManagers(new KeyManager[] { keyManager });
    }
    SSLSocketFactory wrapped = new SSLSocketFactory(underlying);
    if (insecure) {
        wrapped.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
    }
    return wrapped;
}

From source file:com.android.emailcommon.utility.SSLUtils.java

/**
 * Returns a {@link org.apache.http.conn.ssl.SSLSocketFactory SSLSocketFactory} for use with the
 * Apache HTTP stack./*from   w  w  w  .  j  av a 2s  .c  o m*/
 */
public static SSLSocketFactory getHttpSocketFactory(Context context, HostAuth hostAuth, KeyManager keyManager,
        boolean insecure) {
    SSLCertificateSocketFactory underlying = getSSLSocketFactory(context, hostAuth, insecure);
    if (keyManager != null) {
        underlying.setKeyManagers(new KeyManager[] { keyManager });
    }
    SSLSocketFactory wrapped = new SSLSocketFactory(underlying);
    if (insecure) {
        wrapped.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
    }
    return wrapped;
}