Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ android {

dependencies {
api 'cz.msebera.android:httpclient:4.5.8'
compileOnly 'org.conscrypt:conscrypt-android:2.4.0'
}

project.afterEvaluate { project ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -531,4 +531,12 @@ public void cancelRequestsByTAG(Object TAG, boolean mayInterruptIfRunning) {
}
}
}

/**
* Call this method if your app target android below 4.4
* This method enable sni in android below 4.4
*/
public void useConscrypt(){
new ConscryptSSL().install();
}
}
19 changes: 19 additions & 0 deletions library/src/main/java/com/loopj/android/http/ConscryptSSL.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.loopj.android.http;

import android.util.Log;

import org.conscrypt.Conscrypt;

import java.security.Security;

public class ConscryptSSL {

public void install(){
try {
Security.insertProviderAt(Conscrypt.newProvider(),1);
}catch (NoClassDefFoundError ex){
Log.e(AsyncHttpClient.LOG_TAG, "java.lang.NoClassDefFoundError: org.conscrypt.Conscrypt, Please add org.conscrypt.Conscrypt to your dependency");
}

}
}