How to Implement TLSv1.3 in Applications

From wizarPOS
Revision as of 09:25, 29 June 2022 by Mahong (talk | contribs)

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());