How to Implement TLSv1.3 in Applications

From wizarPOS
Revision as of 09:14, 29 June 2022 by Mahong (talk | contribs) (Created page with "== References == [https://github.com/google/conscrypt GitHub project] [https://source.android.google.cn/devices/architecture/modular-system/conscrypt?hl=zh-cn#conscrypt-format...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

References

GitHub project Resouces

Sample

Snippet Code:

  Provider conscrypt = Conscrypt.newProvider();
  // Add as provider
  Security.insertProviderAt(conscrypt, 1);
  SSLContext context = SSLContext.getInstance("TLSv1.3");

  context.init(null/*keyManagers*/, null /*new CtsTrustManager[] {trustManager}*/, null);
  SSLSocketFactory factory = context.getSocketFactory();
  URL sslURL = new URL("https://www.vpslala.com/");
  HttpsURLConnection con = (HttpsURLConnection) sslURL.openConnection();
  con.setSSLSocketFactory(factory);
  Log.d("SQLTest", "SQLTestTLS13. "+con.getResponseMessage());