use of eu.siacs.conversations.utils.TLSSocketFactory in project Conversations by siacs.
the class HttpConnectionManager method setupTrustManager.
public void setupTrustManager(final HttpsURLConnection connection, final boolean interactive) {
final X509TrustManager trustManager;
final HostnameVerifier hostnameVerifier;
if (interactive) {
trustManager = mXmppConnectionService.getMemorizingTrustManager().getInteractive();
hostnameVerifier = mXmppConnectionService.getMemorizingTrustManager().wrapHostnameVerifier(new StrictHostnameVerifier());
} else {
trustManager = mXmppConnectionService.getMemorizingTrustManager().getNonInteractive();
hostnameVerifier = mXmppConnectionService.getMemorizingTrustManager().wrapHostnameVerifierNonInteractive(new StrictHostnameVerifier());
}
try {
final SSLSocketFactory sf = new TLSSocketFactory(new X509TrustManager[] { trustManager }, mXmppConnectionService.getRNG());
connection.setSSLSocketFactory(sf);
connection.setHostnameVerifier(hostnameVerifier);
} catch (final KeyManagementException | NoSuchAlgorithmException ignored) {
}
}
use of eu.siacs.conversations.utils.TLSSocketFactory in project Conversations by siacs.
the class HttpConnectionManager method setupTrustManager.
private void setupTrustManager(final OkHttpClient.Builder builder, final boolean interactive) {
final X509TrustManager trustManager;
if (interactive) {
trustManager = mXmppConnectionService.getMemorizingTrustManager().getInteractive();
} else {
trustManager = mXmppConnectionService.getMemorizingTrustManager().getNonInteractive();
}
try {
final SSLSocketFactory sf = new TLSSocketFactory(new X509TrustManager[] { trustManager }, mXmppConnectionService.getRNG());
builder.sslSocketFactory(sf, trustManager);
builder.hostnameVerifier(new StrictHostnameVerifier());
} catch (final KeyManagementException | NoSuchAlgorithmException ignored) {
}
}
Aggregations