Last active
March 8, 2017 02:42
-
-
Save erlangparasu/d98c2de76d7b2ba14a87cf43dd3ccab4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CaUtil { | |
private static final String TAG = "Tag.CaUtil"; | |
public static String getCaString(Context context) { | |
try { | |
/* Get certificate string (for HTTPS connection) */ | |
InputStream caInput = new BufferedInputStream(context.getAssets().open("customCA.crt")); | |
InputStreamReader inputStreamReader = new InputStreamReader(caInput); | |
BufferedReader bufferedReader = new BufferedReader(inputStreamReader); | |
String line; | |
StringBuilder builder = new StringBuilder(""); | |
while ((line = bufferedReader.readLine()) != null) { | |
builder.append(line + "\n"); | |
} | |
return builder.toString(); | |
} catch (Exception e) { | |
Log.d(TAG, "getCaString: e: " + e.getMessage()); | |
e.printStackTrace(); | |
return null; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment