How to Implement TLSv1.3 in Applications: Difference between revisions
No edit summary |
No edit summary |
||
Line 2: | Line 2: | ||
[https://github.com/google/conscrypt GitHub project] | [https://github.com/google/conscrypt GitHub project] | ||
[https://source.android.google.cn/devices/architecture/modular-system/conscrypt | [https://source.android.google.cn/devices/architecture/modular-system/conscrypt#conscrypt-format Resouces] | ||
== Sample == | == Sample == |
Revision as of 09:21, 30 June 2022
References
Sample
Snippet Code:
/**
* dependencies implementation 'org.conscrypt:conscrypt-android:2.5.2'
* @param url
*/
private void tlsv13(String url) {
Provider conscrypt = Conscrypt.newProvider();
try {
SSLContext context = SSLContext.getInstance("TLSv1.3",conscrypt);
context.init(null/*keyManagers*/, null /*new CtsTrustManager[] {trustManager}*/, null);
SSLSocketFactory factory = context.getSocketFactory();
URL sslURL = new URL(url);
HttpsURLConnection con = (HttpsURLConnection) sslURL.openConnection();
con.setSSLSocketFactory(factory);
} catch (Exception e) {
e.printStackTrace();
}
}
Please download demo